jglick commented on a change in pull request #612:
URL: https://github.com/apache/maven-mvnd/pull/612#discussion_r832184567



##########
File path: common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java
##########
@@ -271,23 +271,33 @@ private void reset() {
     private static final int PROCESS_ID = getProcessId0();
 
     private static int getProcessId0() {
-        String pid = null;
         try {
             final Path self = Paths.get("/proc/self");
             if (Files.exists(self)) {
-                pid = self.toRealPath().getFileName().toString();
+                String pid = self.toRealPath().getFileName().toString();
+                if (pid.equals("self")) {
+                    LOGGER.debug("/proc/self symlink could not be followed");
+                } else {
+                    LOGGER.debug("loading own PID from /proc/self link: {}", 
pid);
+                    try {
+                        return Integer.parseInt(pid);
+                    } catch (NumberFormatException x) {
+                        LOGGER.warn("Unable to determine PID from malformed 
/proc/self link `" + pid + "`");
+                    }
+                }
             }
         } catch (IOException ignored) {
+            LOGGER.debug("could not load /proc/self", ignored);
         }
-        if (pid == null) {
-            pid = ManagementFactory.getRuntimeMXBean().getName().split("@", 
0)[0];
-        }
-        if (pid == null) {

Review comment:
       AFAICT this branch was impossible previously (`pid` would have been set 
above), so 
https://github.com/apache/maven-mvnd/blob/3b100839a810ce9ae2555c1592b5edb623223924/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java#L286-L288
 dating back to e3b58e80e5e9afca3dc84f137bbac70d6f2edcc5 was dead code?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to