Date: Wed, 31 May 2023 09:22:26 +0000
Subject: [PATCH 05/59] 8196743: jstatd doesn't see new Java processes inside Docker container

Bug url: https://bugs.openjdk.org/browse/JDK-8196743
---
 .../perfdata/monitor/protocol/local/LocalVmManager.java   | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java
index 35d25700d..4be281f65 100644
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,6 @@ import java.io.*;
  */
 public class LocalVmManager {
     private String userName;                 // user name for monitored jvm
-    private List<String> tmpdirs;
     private Pattern userPattern;
     private Matcher userMatcher;
     private FilenameFilter userFilter;
@@ -77,9 +76,7 @@ public class LocalVmManager {
     public LocalVmManager(String user) {
         this.userName = user;
 
-
         if (userName == null) {
-            tmpdirs = PerfDataFile.getTempDirectories(null, 0);
             userPattern = Pattern.compile(PerfDataFile.userDirNamePattern);
             userMatcher = userPattern.matcher("");
 
@@ -89,8 +86,6 @@ public class LocalVmManager {
                     return userMatcher.lookingAt();
                 }
             };
-        } else {
-            tmpdirs = PerfDataFile.getTempDirectories(userName, 0);
         }
 
         filePattern = Pattern.compile(PerfDataFile.fileNamePattern);
@@ -134,6 +129,7 @@ public class LocalVmManager {
          * we'd see strange file names being matched by the matcher.
          */
         Set<Integer> jvmSet = new HashSet<Integer>();
+        List<String> tmpdirs = PerfDataFile.getTempDirectories(userName, 0);
 
         for (String dir : tmpdirs) {
             File tmpdir = new File(dir);
-- 
2.22.0

