@@ -608,7 +608,8 @@ private void closeSilently() {
608608 @ Override
609609 public int read (ByteBuffer dst ) throws IOException {
610610 // are we in the middle of closing or closed?
611- if (closing || closed ) {
611+ SSLEngine sslEngine = this .sslEngine ;
612+ if (closing || closed || sslEngine == null ) {
612613 return -1 ;
613614 }
614615 // did we finish our handshake?
@@ -695,7 +696,8 @@ public int read(ByteBuffer dst) throws IOException {
695696 @ Override
696697 public long read (ByteBuffer [] dsts , int offset , int length ) throws IOException {
697698 // are we in the middle of closing or closed?
698- if (closing || closed ) {
699+ SSLEngine sslEngine = this .sslEngine ;
700+ if (closing || closed || sslEngine == null ) {
699701 return -1 ;
700702 }
701703 // did we finish our handshake?
@@ -826,7 +828,8 @@ public int write(ByteBuffer src) throws IOException {
826828 return sc .write (src );
827829 } else {
828830 // Are we closing or closed?
829- if (closing || closed ) {
831+ SSLEngine sslEngine = this .sslEngine ;
832+ if (closing || closed || sslEngine == null ) {
830833 throw new IOException (sm .getString ("channel.nio.ssl.closing" ));
831834 }
832835
@@ -869,7 +872,8 @@ public int write(ByteBuffer src) throws IOException {
869872 public long write (ByteBuffer [] srcs , int offset , int length ) throws IOException {
870873 checkInterruptStatus ();
871874 // Are we closing or closed?
872- if (closing || closed ) {
875+ SSLEngine sslEngine = this .sslEngine ;
876+ if (closing || closed || sslEngine == null ) {
873877 throw new IOException (sm .getString ("channel.nio.ssl.closing" ));
874878 }
875879
0 commit comments