changeset 11855:a5e61ab8c2d4

8027668: sun/tools/jstatd/TestJstatdPort.java: java.net.ConnectException: Connection refused: connect Reviewed-by: jbachorik, sla
author ykantser
date Tue, 07 Apr 2015 14:47:33 +0200
parents 194ce0d739b9
children c6f3a4853e2d
files src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java test/ProblemList.txt test/sun/tools/jstatd/JstatdTest.java
diffstat 3 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java	Fri Apr 03 13:46:22 2015 -0700
+++ b/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/test/ProblemList.txt	Fri Apr 03 13:46:22 2015 -0700
+++ b/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/test/sun/tools/jstatd/JstatdTest.java	Fri Apr 03 13:46:22 2015 -0700
+++ b/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 {