Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8217617

[CentOS] JConsole not showing threads when run from the process being monitored

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      CentOS 7 64bit, openjdk-11.0.2_linux-x64

      A DESCRIPTION OF THE PROBLEM :
      When running JConsole via ProcessBuilder from the process being monitored the Threads view does not update, see code example. JConsole works as expected when run separately and connected to the application via the New Connection dialog.

      Note that this works fine in Windows (openjdk-11.0.2_windows-x64) and on CentOS with jdk-8u202-ea-bin-b03-linux-x64.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See code example (available as gist here: https://gist.github.com/bjorndarri/843afdd5400abe3979192daf14340a6e)

      Here is a working code example for Java 8: https://gist.github.com/bjorndarri/1e4a5efe6bfe5197bbda6678fa789e04

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Threads view should update.
      ACTUAL -
      Threads view does not update.

      ---------- BEGIN SOURCE ----------
      import java.io.File;
      import java.io.IOException;
      import java.util.concurrent.Executors;

      public class JConsole11Test {

        public static void main(String[] args) throws IOException {
          Executors.newSingleThreadExecutor().execute(() -> {
            try {
              Thread.sleep(1000);
            }
            catch (InterruptedException e) {
              e.printStackTrace();
            }
          });

          String javaBin = System.getProperty("java.home") + System.getProperty("file.separator") + "bin";

          new ProcessBuilder().directory(new File(javaBin))
                  .command("jconsole", getProcessId())
                  .start();
        }

        private static String getProcessId() {
          return Long.toString(ProcessHandle.current().pid());
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Haven't found a workaround.

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: