Close 'InternalStreamConnection' when `stream.openAsync`/`writeAsync`/`readAsync` fails or completes abruptly
@@ -224,10 +224,12 @@ public class InternalStreamConnection implements InternalConnection {
@Override
public void failed(final Throwable t) {
+ close();
callback.onResult(null, t);
}
});
} catch (Throwable t) {
+ close();
callback.onResult(null, t);
}
}
@@ -583,6 +585,7 @@ public class InternalStreamConnection implements InternalConnection {
}
private void writeAsync(final List<ByteBuf> byteBuffers, final SingleResultCallback<Void> callback) {
+ try {
stream.writeAsync(byteBuffers, new AsyncCompletionHandler<Void>() {
@Override
public void completed(final Void v) {
@@ -595,6 +598,10 @@ public class InternalStreamConnection implements InternalConnection {
callback.onResult(null, translateWriteException(t));
}
});
+ } catch (Throwable t) {
+ close();
+ callback.onResult(null, t);
+ }
}
@Override
@@ -642,6 +649,7 @@ public class InternalStreamConnection implements InternalConnection {
}
});
} catch (Exception e) {
+ close();
callback.onResult(null, translateReadException(e));
}
}
