8179273: sun.net.httpserver.LeftOverInputStream should stop attempting to drain the stream when the server is stopped

Reviewed-by: chegar
This commit is contained in:
Daniel Fuchs 2017-04-26 11:10:54 +01:00
parent bbd1ecb6b7
commit f9ad6da8b5
2 changed files with 9 additions and 2 deletions

View File

@ -41,8 +41,8 @@ import com.sun.net.httpserver.spi.*;
* 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 @@ abstract class LeftOverInputStream extends FilterInputStream {
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;

View File

@ -179,6 +179,10 @@ class ServerImpl implements TimeSource {
return httpsConfig;
}
public final boolean isFinishing() {
return finished;
}
public void stop (int delay) {
if (delay < 0) {
throw new IllegalArgumentException ("negative delay parameter");