mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8256818: SSLSocket that is never bound or connected leaks socket resources
Reviewed-by: xuelei
This commit is contained in:
parent
692b273ec5
commit
93b6ab56ae
5 changed files with 114 additions and 32 deletions
|
@ -553,7 +553,7 @@ public final class SSLSocketImpl
|
|||
// locks may be deadlocked.
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (tlsIsClosed) {
|
||||
if (isClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -562,19 +562,16 @@ public final class SSLSocketImpl
|
|||
}
|
||||
|
||||
try {
|
||||
// shutdown output bound, which may have been closed previously.
|
||||
if (!isOutputShutdown()) {
|
||||
duplexCloseOutput();
|
||||
}
|
||||
if (isConnected()) {
|
||||
// shutdown output bound, which may have been closed previously.
|
||||
if (!isOutputShutdown()) {
|
||||
duplexCloseOutput();
|
||||
}
|
||||
|
||||
// shutdown input bound, which may have been closed previously.
|
||||
if (!isInputShutdown()) {
|
||||
duplexCloseInput();
|
||||
}
|
||||
|
||||
if (!isClosed()) {
|
||||
// close the connection directly
|
||||
closeSocket(false);
|
||||
// shutdown input bound, which may have been closed previously.
|
||||
if (!isInputShutdown()) {
|
||||
duplexCloseInput();
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
// ignore the exception
|
||||
|
@ -582,7 +579,19 @@ public final class SSLSocketImpl
|
|||
SSLLogger.warning("SSLSocket duplex close failed", ioe);
|
||||
}
|
||||
} finally {
|
||||
tlsIsClosed = true;
|
||||
if (!isClosed()) {
|
||||
// close the connection directly
|
||||
try {
|
||||
closeSocket(false);
|
||||
} catch (IOException ioe) {
|
||||
// ignore the exception
|
||||
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
|
||||
SSLLogger.warning("SSLSocket close failed", ioe);
|
||||
}
|
||||
} finally {
|
||||
tlsIsClosed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue