File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/main/java/org/java_websocket Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,10 @@ public int write( ByteBuffer src ) throws IOException {
197197
198198 }
199199
200+ /**
201+ * Blocks when in blocking mode until at least one byte has been decoded.<br>
202+ * When not in blocking mode 0 may be returned.
203+ **/
200204 public int read ( ByteBuffer dst ) throws IOException {
201205 if ( !dst .hasRemaining () )
202206 return 0 ;
@@ -231,8 +235,12 @@ public int read( ByteBuffer dst ) throws IOException {
231235 }
232236 inCrypt .flip ();
233237 unwrap ();
234- return transfereTo ( inData , dst );
235238
239+ int transfered = transfereTo ( inData , dst );
240+ if ( transfered == 0 && isBlocking () ) {
241+ return read ( dst ); // "transfered" may be 0 when not enough bytes were received or during rehandshaking
242+ }
243+ return transfered ;
236244 }
237245
238246 private int readRemaining ( ByteBuffer dst ) throws SSLException {
You can’t perform that action at this time.
0 commit comments