8179273: sun.net.httpserver.LeftOverInputStream should stop attempting to drain the stream when the server is stopped
Reviewed-by: chegar
--- 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");