Integrated: JDK-8315422: getSoTimeout() would be in try block in SSLSocketImpl

John Jiang jjiang at openjdk.org
Thu Aug 31 22:29:48 UTC 2023


On Thu, 31 Aug 2023 02:34:58 GMT, John Jiang <jjiang at openjdk.org> wrote:

> The method `SSLSocketImpl::closeSocket` has the below code snippet,
> 
> 
> 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
>     } finally {
>         if (soTimeout == 0)
>             setSoTimeout(soTimeout);
>         appInput.readLock.unlock();
>     }
> }
> 
> 
> If `getSoTimeout()` throws an exception, say `SocketException`, `appInput.readLock.unlock()` cannot be called.

This pull request has now been integrated.

Changeset: 2264667b
Author:    John Jiang <jjiang at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/2264667bba2311b568257a933813fa76a9e75313
Stats:     19 lines in 1 file changed: 6 ins; 3 del; 10 mod

8315422: getSoTimeout() would be in try block in SSLSocketImpl

Reviewed-by: jnimeh

-------------

PR: https://git.openjdk.org/jdk/pull/15503


More information about the security-dev mailing list