8027668: sun/tools/jstatd/TestJstatdPort.java: java.net.ConnectException: Connection refused: connect
authorykantser
Tue, 07 Apr 2015 14:47:33 +0200
changeset 30347 8afd3d1eac9d
parent 30335 b7b1fab1fb2f
child 30349 09ee9c48f1c3
8027668: sun/tools/jstatd/TestJstatdPort.java: java.net.ConnectException: Connection refused: connect Reviewed-by: jbachorik, sla
jdk/src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java
jdk/test/ProblemList.txt
jdk/test/sun/tools/jstatd/JstatdTest.java
--- a/jdk/src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java	Fri Apr 03 13:46:22 2015 -0700
+++ b/jdk/src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java	Tue Apr 07 14:47:33 2015 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2015, 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
@@ -142,6 +142,8 @@
             RemoteHost stub = (RemoteHost) UnicastRemoteObject.exportObject(
                     remoteHost, 0);
             bind(name.toString(), remoteHost);
+            System.out.println("jstatd started (bound to " + name.toString() + ")");
+            System.out.flush();
         } catch (MalformedURLException e) {
             if (rminame != null) {
                 System.out.println("Bad RMI server name: " + rminame);
--- a/jdk/test/ProblemList.txt	Fri Apr 03 13:46:22 2015 -0700
+++ b/jdk/test/ProblemList.txt	Tue Apr 07 14:47:33 2015 +0200
@@ -318,13 +318,7 @@
 # 8072131
 sun/tools/jmap/heapconfig/JMapHeapConfigTest.java macosx-all
 
-# 8027668
-sun/tools/jstatd/TestJstatdDefaults.java                generic-all
-sun/tools/jstatd/TestJstatdServer.java                  generic-all
-sun/tools/jstatd/TestJstatdPort.java                    generic-all
-sun/tools/jstatd/TestJstatdPortAndServer.java                    generic-all
-
-# 8046285 8027668
+# 8046285
 sun/tools/jstatd/TestJstatdExternalRegistry.java                generic-all
 
 # 6456333
--- a/jdk/test/sun/tools/jstatd/JstatdTest.java	Fri Apr 03 13:46:22 2015 -0700
+++ b/jdk/test/sun/tools/jstatd/JstatdTest.java	Tue Apr 07 14:47:33 2015 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -22,7 +22,6 @@
  */
 
 import java.io.File;
-import java.io.IOException;
 import java.net.UnknownHostException;
 import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
@@ -130,8 +129,6 @@
     private OutputAnalyzer runJps() throws Exception {
         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jps");
         launcher.addVMArg("-XX:+UsePerfData");
-        // Run jps with -v flag to obtain -Dparent.pid.<pid>
-        launcher.addToolArg("-v");
         launcher.addToolArg(getDestination());
 
         String[] cmd = launcher.getCommand();
@@ -277,8 +274,6 @@
         assertTrue(policy.exists() && policy.isFile(),
                 "Security policy " + policy.getAbsolutePath() + " does not exist or not a file");
         launcher.addVMArg("-Djava.security.policy=" + policy.getAbsolutePath());
-        // -Dparent.pid.<pid> will help to identify jstad process started by this test
-        launcher.addVMArg("-Dparent.pid." + ProcessTools.getProcessId());
         if (port != null) {
             launcher.addToolArg("-p");
             launcher.addToolArg(port);
@@ -295,7 +290,7 @@
 
     private ProcessThread tryToSetupJstatdProcess() throws Throwable {
         ProcessThread jstatdThread = new ProcessThread("Jstatd-Thread",
-                getJstatdCmd());
+                JstatdTest::isJstadReady, getJstatdCmd());
         try {
             jstatdThread.start();
             // Make sure jstatd is up and running
@@ -315,6 +310,10 @@
         return jstatdThread;
     }
 
+    private static boolean isJstadReady(String line) {
+        return line.startsWith("jstatd started (bound to ");
+    }
+
     public void doTest() throws Throwable {
         ProcessThread jstatdThread = null;
         try {