Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8252117: com/sun/jdi/BadHandshakeTest.java failed with "ConnectException: Connection refused: connect" #972

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2020, 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
@@ -112,28 +112,51 @@ public static void main(String args[]) throws Exception {
throw error;
}

log("cleaning...");
// Attach to server debuggee and resume it so it can exit
log("final attach...");
// Attach to server debuggee to ensure it's still available to attach and resume it so it can exit
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map<String, Argument> conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
retryDelay = 20;
for (int retry = 0; retry < 5; retry++) {
if (error != null) {
try {
Thread.sleep(retryDelay);
} catch (InterruptedException ex) {
// ignore
}
retryDelay *= 2;
error = null;
}
try {
log("retry: " + retry);
Map<String, Argument> conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);

// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event : evtSet) {
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}

// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event : evtSet) {
if (event instanceof VMStartEvent) {
vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();
break;
} catch (ConnectException ex) {
log("got exception: " + ex.toString());
error = ex;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
if (error != null) {
throw error;
}

vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();

// give the debuggee some time to exit before forcibly terminating it
debuggee.waitFor(10, TimeUnit.SECONDS);
}
}