8179273: sun.net.httpserver.LeftOverInputStream should stop attempting to drain the stream when the server is stopped
authordfuchs
Wed, 26 Apr 2017 11:10:54 +0100
changeset 44913 1b08f0eb012e
parent 44912 d852532f406b
child 44914 406bfc68eae7
8179273: sun.net.httpserver.LeftOverInputStream should stop attempting to drain the stream when the server is stopped Reviewed-by: chegar
jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java
jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java
--- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java	Wed Apr 26 15:01:43 2017 +0530
+++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java	Wed Apr 26 11:10:54 2017 +0100
@@ -41,8 +41,8 @@
  * isEOF() returns true, when all expected bytes have been read
  */
 abstract class LeftOverInputStream extends FilterInputStream {
-    ExchangeImpl t;
-    ServerImpl server;
+    final ExchangeImpl t;
+    final ServerImpl server;
     protected boolean closed = false;
     protected boolean eof = false;
     byte[] one = new byte [1];
@@ -109,6 +109,9 @@
         int bufSize = 2048;
         byte[] db = new byte [bufSize];
         while (l > 0) {
+            if (server.isFinishing()) {
+                break;
+            }
             long len = readImpl (db, 0, bufSize);
             if (len == -1) {
                 eof = true;
--- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java	Wed Apr 26 15:01:43 2017 +0530
+++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java	Wed Apr 26 11:10:54 2017 +0100
@@ -179,6 +179,10 @@
         return httpsConfig;
     }
 
+    public final boolean isFinishing() {
+        return finished;
+    }
+
     public void stop (int delay) {
         if (delay < 0) {
             throw new IllegalArgumentException ("negative delay parameter");