]> source.dussan.org Git - jgit.git/commitdiff
Use Java 11 ProcessHandle to get pid of the current process 63/200063/1
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 22 Feb 2023 00:06:06 +0000 (01:06 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 22 Feb 2023 00:06:06 +0000 (01:06 +0100)
Change-Id: I790f218601c1d5e1b39c4101e3b2708e76b9d782

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

index 4e8164c77f828d351b51d866a41e6f90620b4795..080af97cbcce769110e1072986f87a8eb618cc82 100644 (file)
@@ -1713,17 +1713,7 @@ public class GC {
                }
 
                private long getPID() {
-                       String processName = java.lang.management.ManagementFactory
-                                       .getRuntimeMXBean().getName();
-                       if (processName != null && processName.length() > 0) {
-                               try {
-                                       return Long.parseLong(processName.split("@")[0]); //$NON-NLS-1$
-                               } catch (Exception e) {
-                                       return 0;
-                               }
-                       }
-
-                       return 0;
+                       return ProcessHandle.current().pid();
                }
 
                private String getHostName() {