diff --git a/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java b/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java index 085f38d89df..8135e6006d8 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java @@ -255,7 +255,11 @@ final class SSLSocketInputRecord extends InputRecord implements SSLRecord { // Decrypt the fragment // ByteBuffer fragment; + recordLock.lock(); try { + if (isClosed) { + return null; + } Plaintext plaintext = readCipher.decrypt(contentType, recordBody, null); fragment = plaintext.fragment; @@ -264,6 +268,8 @@ final class SSLSocketInputRecord extends InputRecord implements SSLRecord { throw bpe; } catch (GeneralSecurityException gse) { throw new SSLProtocolException("Unexpected exception", gse); + } finally { + recordLock.unlock(); } if (contentType != ContentType.HANDSHAKE.id && diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index df508909503..e3a6af26bea 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -616,7 +616,6 @@ com/sun/security/sasl/gsskerb/NoSecurityLayer.java 8039280 generic- sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.java 8039280 generic-all sun/security/provider/PolicyParser/ExtDirsChange.java 8039280 generic-all sun/security/provider/PolicyParser/PrincipalExpansionError.java 8039280 generic-all -sun/security/ssl/SSLSessionImpl/NoInvalidateSocketException.java 8277970 linux-all,macosx-x64 ############################################################################ diff --git a/test/jdk/sun/security/ssl/SSLSessionImpl/NoInvalidateSocketException.java b/test/jdk/sun/security/ssl/SSLSessionImpl/NoInvalidateSocketException.java index 2b60fdd7a44..ed488b946c0 100644 --- a/test/jdk/sun/security/ssl/SSLSessionImpl/NoInvalidateSocketException.java +++ b/test/jdk/sun/security/ssl/SSLSessionImpl/NoInvalidateSocketException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022, 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 @@ -30,7 +30,7 @@ /* * @test - * @bug 8274736 + * @bug 8274736 8277970 * @summary Concurrent read/close of SSLSockets causes SSLSessions to be * invalidated unnecessarily * @library /javax/net/ssl/templates