8154144: Tests in com/sun/jdi fails intermittently with "jdb input stream closed prematurely"
Summary: Don't print stream closed message during shutdown
Reviewed-by: dcubed, sla, dsamersoff
Contributed-by: sharath.ballal@oracle.com
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java Thu May 05 11:44:01 2016 -0700
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java Fri May 06 11:47:45 2016 +0300
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@@ -133,6 +133,10 @@
if (!vmDied) {
vmDisconnectEvent(event);
}
+ /*
+ * Inform jdb command line processor that jdb is being shutdown. JDK-8154144.
+ */
+ ((TTY)notifier).setShuttingDown(true);
Env.shutdown(shutdownMessageKey);
return false;
} else {
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java Thu May 05 11:44:01 2016 -0700
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java Fri May 06 11:47:45 2016 +0300
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,6 +56,16 @@
*/
private static final String progname = "jdb";
+ private volatile boolean shuttingDown = false;
+
+ public void setShuttingDown(boolean s) {
+ shuttingDown = s;
+ }
+
+ public boolean isShuttingDown() {
+ return shuttingDown;
+ }
+
@Override
public void vmStartEvent(VMStartEvent se) {
Thread.yield(); // fetch output
@@ -750,7 +760,13 @@
while (true) {
String ln = in.readLine();
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";
}