Skip to content

Commit a98bd60

Browse files
committedJul 18, 2024
8315422: getSoTimeout() would be in try block in SSLSocketImpl
Backport-of: 2264667bba2311b568257a933813fa76a9e75313
1 parent 69aab6a commit a98bd60

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed
 

‎src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java

+16-13
Original file line numberDiff line numberDiff line change
@@ -1781,21 +1781,24 @@ private void closeSocket(boolean selfInitiated) throws IOException {
17811781
if (conContext.inputRecord instanceof
17821782
SSLSocketInputRecord inputRecord && isConnected) {
17831783
if (appInput.readLock.tryLock()) {
1784-
int soTimeout = getSoTimeout();
17851784
try {
1786-
// deplete could hang on the skip operation
1787-
// in case of infinite socket read timeout.
1788-
// Change read timeout to avoid deadlock.
1789-
// This workaround could be replaced later
1790-
// with the right synchronization
1791-
if (soTimeout == 0)
1792-
setSoTimeout(DEFAULT_SKIP_TIMEOUT);
1793-
inputRecord.deplete(false);
1794-
} catch (java.net.SocketTimeoutException stEx) {
1795-
// skip timeout exception during deplete
1785+
int soTimeout = getSoTimeout();
1786+
try {
1787+
// deplete could hang on the skip operation
1788+
// in case of infinite socket read timeout.
1789+
// Change read timeout to avoid deadlock.
1790+
// This workaround could be replaced later
1791+
// with the right synchronization
1792+
if (soTimeout == 0)
1793+
setSoTimeout(DEFAULT_SKIP_TIMEOUT);
1794+
inputRecord.deplete(false);
1795+
} catch (java.net.SocketTimeoutException stEx) {
1796+
// skip timeout exception during deplete
1797+
} finally {
1798+
if (soTimeout == 0)
1799+
setSoTimeout(soTimeout);
1800+
}
17961801
} finally {
1797-
if (soTimeout == 0)
1798-
setSoTimeout(soTimeout);
17991802
appInput.readLock.unlock();
18001803
}
18011804
}

0 commit comments

Comments
 (0)