@@ -326,16 +326,18 @@ public void run() {
326
326
conn = (WebSocketImpl ) key .attachment ();
327
327
ByteBuffer buf = takeBuffer ();
328
328
try {
329
- if ( SocketChannelIOHelper .read ( buf , conn , (ByteChannel ) conn .channel ) ) {
330
- assert ( buf .hasRemaining () );
331
- conn .inQueue .put ( buf );
332
- queue ( conn );
333
- i .remove ();
334
- if ( conn .channel instanceof WrappedByteChannel ) {
335
- if ( ( (WrappedByteChannel ) conn .channel ).isNeedRead () ) {
336
- iqueue .add ( conn );
329
+ if ( SocketChannelIOHelper .read ( buf , conn , conn .channel ) ) {
330
+ if ( buf .hasRemaining () ) {
331
+ conn .inQueue .put ( buf );
332
+ queue ( conn );
333
+ i .remove ();
334
+ if ( conn .channel instanceof WrappedByteChannel ) {
335
+ if ( ( (WrappedByteChannel ) conn .channel ).isNeedRead () ) {
336
+ iqueue .add ( conn );
337
+ }
337
338
}
338
- }
339
+ } else
340
+ pushBuffer ( buf );
339
341
} else {
340
342
pushBuffer ( buf );
341
343
}
@@ -346,7 +348,7 @@ public void run() {
346
348
}
347
349
if ( key .isWritable () ) {
348
350
conn = (WebSocketImpl ) key .attachment ();
349
- if ( SocketChannelIOHelper .batch ( conn , ( ByteChannel ) conn .channel ) ) {
351
+ if ( SocketChannelIOHelper .batch ( conn , conn .channel ) ) {
350
352
if ( key .isValid () )
351
353
key .interestOps ( SelectionKey .OP_READ );
352
354
}
@@ -359,9 +361,12 @@ public void run() {
359
361
try {
360
362
if ( SocketChannelIOHelper .readMore ( buf , conn , c ) )
361
363
iqueue .add ( conn );
362
- assert ( buf .hasRemaining () );
363
- conn .inQueue .put ( buf );
364
- queue ( conn );
364
+ if ( buf .hasRemaining () ) {
365
+ conn .inQueue .put ( buf );
366
+ queue ( conn );
367
+ } else {
368
+ pushBuffer ( buf );
369
+ }
365
370
} catch ( IOException e ) {
366
371
pushBuffer ( buf );
367
372
throw e ;
0 commit comments