@@ -553,10 +553,6 @@ private static void writeWouldBlock(final Ruby runtime, final boolean exception,
553553 result [0 ] = WRITE_WOULD_BLOCK_RESULT ;
554554 }
555555
556- private void doHandshake (final boolean blocking ) throws IOException {
557- doHandshake (blocking , true );
558- }
559-
560556 // might return :wait_readable | :wait_writable in case (true, false)
561557 private IRubyObject doHandshake (final boolean blocking , final boolean exception ) throws IOException {
562558 while (true ) {
@@ -706,11 +702,15 @@ public int write(ByteBuffer src, boolean blocking) throws SSLException, IOExcept
706702 }
707703
708704 public int read (final ByteBuffer dst , final boolean blocking ) throws IOException {
705+ return read (dst , blocking , true );
706+ }
707+
708+ private int read (final ByteBuffer dst , final boolean blocking , final boolean exception ) throws IOException {
709709 if ( initialHandshake ) return 0 ;
710710 if ( engine .isInboundDone () ) return -1 ;
711711
712712 if ( ! appReadData .hasRemaining () ) {
713- int appBytesProduced = readAndUnwrap (blocking );
713+ int appBytesProduced = readAndUnwrap (blocking , exception );
714714 if (appBytesProduced == -1 || appBytesProduced == 0 ) {
715715 return appBytesProduced ;
716716 }
@@ -722,6 +722,10 @@ public int read(final ByteBuffer dst, final boolean blocking) throws IOException
722722 }
723723
724724 private int readAndUnwrap (final boolean blocking ) throws IOException {
725+ return readAndUnwrap (blocking , true );
726+ }
727+
728+ private int readAndUnwrap (final boolean blocking , final boolean exception ) throws IOException {
725729 final int bytesRead = socketChannelImpl ().read (netReadData );
726730 if ( bytesRead == -1 ) {
727731 if ( ! netReadData .hasRemaining () ||
@@ -769,7 +773,7 @@ private int readAndUnwrap(final boolean blocking) throws IOException {
769773 handshakeStatus == SSLEngineResult .HandshakeStatus .NEED_TASK ||
770774 handshakeStatus == SSLEngineResult .HandshakeStatus .NEED_WRAP ||
771775 handshakeStatus == SSLEngineResult .HandshakeStatus .FINISHED ) ) {
772- doHandshake (blocking );
776+ doHandshake (blocking , exception );
773777 }
774778 return appReadData .remaining ();
775779 }
@@ -852,7 +856,7 @@ private IRubyObject sysreadImpl(final ThreadContext context, final IRubyObject l
852856 if ( engine == null ) {
853857 read = socketChannelImpl ().read (dst );
854858 } else {
855- read = read (dst , blocking );
859+ read = read (dst , blocking , exception );
856860 }
857861
858862 if ( read == -1 ) {
0 commit comments