changeset 11701:7ced0993caf4

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
author csahu
date Fri, 03 Jun 2016 09:24:52 +0000
parents 979b0634e600
children 267a03dfb105
files src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java src/share/classes/com/sun/tools/example/debug/tty/TTY.java
diffstat 2 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java	Fri Jun 03 12:46:32 2016 +0300
+++ b/src/share/classes/com/sun/tools/example/debug/tty/EventHandler.java	Fri Jun 03 09:24:52 2016 +0000
@@ -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/src/share/classes/com/sun/tools/example/debug/tty/TTY.java	Fri Jun 03 12:46:32 2016 +0300
+++ b/src/share/classes/com/sun/tools/example/debug/tty/TTY.java	Fri Jun 03 09:24:52 2016 +0000
@@ -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";
                 }