8154144: Tests in com/sun/jdi fails intermittently with "jdb input stream closed prematurely"

Don't print stream closed message during shutdown

Reviewed-by: dcubed, sla, dsamersoff
This commit is contained in:
Sharath Ballal 2016-05-06 11:47:45 +03:00 committed by Dmitry Samersoff
parent b52c5bbd67
commit 096e59e6c9
2 changed files with 23 additions and 3 deletions
jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -133,6 +133,10 @@ public class EventHandler implements Runnable {
if (!vmDied) { if (!vmDied) {
vmDisconnectEvent(event); vmDisconnectEvent(event);
} }
/*
* Inform jdb command line processor that jdb is being shutdown. JDK-8154144.
*/
((TTY)notifier).setShuttingDown(true);
Env.shutdown(shutdownMessageKey); Env.shutdown(shutdownMessageKey);
return false; return false;
} else { } else {

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -56,6 +56,16 @@ public class TTY implements EventNotifier {
*/ */
private static final String progname = "jdb"; private static final String progname = "jdb";
private volatile boolean shuttingDown = false;
public void setShuttingDown(boolean s) {
shuttingDown = s;
}
public boolean isShuttingDown() {
return shuttingDown;
}
@Override @Override
public void vmStartEvent(VMStartEvent se) { public void vmStartEvent(VMStartEvent se) {
Thread.yield(); // fetch output Thread.yield(); // fetch output
@ -750,7 +760,13 @@ public class TTY implements EventNotifier {
while (true) { while (true) {
String ln = in.readLine(); String ln = in.readLine();
if (ln == null) { if (ln == null) {
MessageOutput.println("Input stream closed."); /*
* Jdb is being shutdown because debuggee exited, ignore any 'null'
* returned by readLine() during shutdown. JDK-8154144.
*/
if (!isShuttingDown()) {
MessageOutput.println("Input stream closed.");
}
ln = "quit"; ln = "quit";
} }