Skip to content

Commit

Permalink
8315422: getSoTimeout() would be in try block in SSLSocketImpl
Browse files Browse the repository at this point in the history
Reviewed-by: jnimeh
  • Loading branch information
John Jiang committed Aug 31, 2023
1 parent d5973bd commit 2264667
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1782,21 +1782,24 @@ private void closeSocket(boolean selfInitiated) throws IOException {
if (conContext.inputRecord instanceof
SSLSocketInputRecord inputRecord && isConnected) {
if (appInput.readLock.tryLock()) {
int soTimeout = getSoTimeout();
try {
// deplete could hang on the skip operation
// in case of infinite socket read timeout.
// Change read timeout to avoid deadlock.
// This workaround could be replaced later
// with the right synchronization
if (soTimeout == 0)
setSoTimeout(DEFAULT_SKIP_TIMEOUT);
inputRecord.deplete(false);
} catch (java.net.SocketTimeoutException stEx) {
// skip timeout exception during deplete
int soTimeout = getSoTimeout();
try {
// deplete could hang on the skip operation
// in case of infinite socket read timeout.
// Change read timeout to avoid deadlock.
// This workaround could be replaced later
// with the right synchronization
if (soTimeout == 0)
setSoTimeout(DEFAULT_SKIP_TIMEOUT);
inputRecord.deplete(false);
} catch (java.net.SocketTimeoutException stEx) {
// skip timeout exception during deplete
} finally {
if (soTimeout == 0)
setSoTimeout(soTimeout);
}
} finally {
if (soTimeout == 0)
setSoTimeout(soTimeout);
appInput.readLock.unlock();
}
}
Expand Down

1 comment on commit 2264667

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.