8199329: Remove code that attempts to read bytes after connection reset reported

Reviewed-by: redestad, clanger, chegar
This commit is contained in:
Alan Bateman 2018-03-15 11:02:22 +00:00
parent 3a7f72200c
commit fc927f60c3
4 changed files with 17 additions and 85 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2018, 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
@ -40,8 +40,7 @@ import sun.net.ConnectionResetException;
* @author Jonathan Payne
* @author Arthur van Hoff
*/
class SocketInputStream extends FileInputStream
{
class SocketInputStream extends FileInputStream {
static {
init();
}
@ -163,8 +162,6 @@ class SocketInputStream extends FileInputStream
+ " off == " + off + " buffer length == " + b.length);
}
boolean gotReset = false;
// acquire file descriptor and do the read
FileDescriptor fd = impl.acquireFD();
try {
@ -173,29 +170,11 @@ class SocketInputStream extends FileInputStream
return n;
}
} catch (ConnectionResetException rstExc) {
gotReset = true;
impl.setConnectionReset();
} finally {
impl.releaseFD();
}
/*
* We receive a "connection reset" but there may be bytes still
* buffered on the socket
*/
if (gotReset) {
impl.setConnectionResetPending();
impl.acquireFD();
try {
n = socketRead(fd, b, off, length, timeout);
if (n > 0) {
return n;
}
} catch (ConnectionResetException rstExc) {
} finally {
impl.releaseFD();
}
}
/*
* If we get here we are at EOF, the socket has been closed,
* or the connection has been reset.
@ -203,9 +182,6 @@ class SocketInputStream extends FileInputStream
if (impl.isClosedOrPending()) {
throw new SocketException("Socket closed");
}
if (impl.isConnectionResetPending()) {
impl.setConnectionReset();
}
if (impl.isConnectionReset()) {
throw new SocketException("Connection reset");
}