< prev index next >

src/java.base/share/classes/sun/security/ssl/InputRecord.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2018, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -29,11 +29,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.BufferUnderflowException;
 import java.nio.ByteBuffer;
-import java.util.concurrent.locks.ReentrantLock;
 import javax.crypto.BadPaddingException;
 import sun.security.ssl.SSLCipher.SSLReadCipher;
 
 /**
  * {@code InputRecord} takes care of the management of SSL/TLS/DTLS input

@@ -42,25 +41,23 @@
  * @author David Brownell
  */
 abstract class InputRecord implements Record, Closeable {
     SSLReadCipher       readCipher;
     // Needed for KeyUpdate, used after Handshake.Finished
-    TransportContext    tc;
+    TransportContext            tc;
 
     final HandshakeHash handshakeHash;
-    volatile boolean    isClosed;
+    boolean             isClosed;
 
     // The ClientHello version to accept. If set to ProtocolVersion.SSL20Hello
     // and the first message we read is a ClientHello in V2 format, we convert
     // it to V3. Otherwise we throw an exception when encountering a V2 hello.
     ProtocolVersion     helloVersion;
 
     // fragment size
     int                 fragmentSize;
 
-    final ReentrantLock recordLock = new ReentrantLock();
-
     InputRecord(HandshakeHash handshakeHash, SSLReadCipher readCipher) {
         this.readCipher = readCipher;
         this.helloVersion = ProtocolVersion.TLS10;
         this.handshakeHash = handshakeHash;
         this.isClosed = false;

@@ -93,23 +90,18 @@
     /**
      * Prevent any more data from being read into this record,
      * and flag the record as holding no data.
      */
     @Override
-    public void close() throws IOException {
-        recordLock.lock();
-        try {
-            if (!isClosed) {
-                isClosed = true;
-                readCipher.dispose();
-            }
-        } finally {
-            recordLock.unlock();
+    public synchronized void close() throws IOException {
+        if (!isClosed) {
+            isClosed = true;
+            readCipher.dispose();
         }
     }
 
-    boolean isClosed() {
+    synchronized boolean isClosed() {
         return isClosed;
     }
 
     // apply to SSLSocket and SSLEngine
     void changeReadCiphers(SSLReadCipher readCipher) {
< prev index next >