Skip to content

Commit 85efa0a

Browse files
committed
1 parent f382d6f commit 85efa0a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/org/java_websocket/SSLSocketChannel2.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)