diff --git a/AndroidAsync/src/com/koushikdutta/async/Util.java b/AndroidAsync/src/com/koushikdutta/async/Util.java index c065b5201..e8f6f43e5 100644 --- a/AndroidAsync/src/com/koushikdutta/async/Util.java +++ b/AndroidAsync/src/com/koushikdutta/async/Util.java @@ -34,7 +34,12 @@ public static void emitAllData(DataEmitter emitter, ByteBufferList list) { throw new RuntimeException("mDataHandler failed to consume data, yet remains the mDataHandler."); } } - if (list.remaining() != 0 && !emitter.isPaused()) { + if (list.remaining() != 0 && handler == null) { + // The emitter was closed or cancelled while processing data. Lets just eat the remaining. + System.out.println("emitter: " + emitter); + list.recycle(); + } + else if (list.remaining() != 0 && !emitter.isPaused()) { // not all the data was consumed... // call byteBufferList.recycle() or read all the data to prevent this assertion. // this is nice to have, as it identifies protocol or parsing errors.