From 0ef006faca2759d84edc0e6d0e0c6891c71c7c43 Mon Sep 17 00:00:00 2001 From: Katja Kantserova Date: Tue, 7 Apr 2015 14:47:33 +0200 Subject: [PATCH] 8027668: sun/tools/jstatd/TestJstatdPort.java: java.net.ConnectException: Connection refused: connect Reviewed-by: jbachorik, sla --- .../share/classes/sun/tools/jstatd/Jstatd.java | 4 +++- jdk/test/ProblemList.txt | 8 +------- jdk/test/sun/tools/jstatd/JstatdTest.java | 13 ++++++------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/jdk/src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java b/jdk/src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java index 09a17803cfa..ff2cca02269 100644 --- a/jdk/src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java +++ b/jdk/src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java @@ -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 @@ public class Jstatd { 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); diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index b460c3600bb..31319caf8e9 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -318,13 +318,7 @@ sun/tools/jcmd/TestJcmdSanity.java windows-all # 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 diff --git a/jdk/test/sun/tools/jstatd/JstatdTest.java b/jdk/test/sun/tools/jstatd/JstatdTest.java index 73a625cef7c..39110123b84 100644 --- a/jdk/test/sun/tools/jstatd/JstatdTest.java +++ b/jdk/test/sun/tools/jstatd/JstatdTest.java @@ -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 @@ public final class JstatdTest { private OutputAnalyzer runJps() throws Exception { JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jps"); launcher.addVMArg("-XX:+UsePerfData"); - // Run jps with -v flag to obtain -Dparent.pid. - launcher.addToolArg("-v"); launcher.addToolArg(getDestination()); String[] cmd = launcher.getCommand(); @@ -277,8 +274,6 @@ public final class JstatdTest { 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. 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 @@ public final class JstatdTest { 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 @@ public final class JstatdTest { return jstatdThread; } + private static boolean isJstadReady(String line) { + return line.startsWith("jstatd started (bound to "); + } + public void doTest() throws Throwable { ProcessThread jstatdThread = null; try {