Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/io/vertx/core/streams/impl/PipeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public void to(WriteStream<T> ws, Handler<AsyncResult<Void>> completionHandler)
ws.drainHandler(drainHandler);
}
});
src.resume();
result.future().onComplete(ar -> {
try {
src.handler(null);
Expand All @@ -109,6 +108,7 @@ public void to(WriteStream<T> ws, Handler<AsyncResult<Void>> completionHandler)
handleFailure(err, completionHandler);
}
});
src.resume();
}

private void handleSuccess(Handler<AsyncResult<Void>> completionHandler) {
Expand Down
20 changes: 17 additions & 3 deletions src/test/java/io/vertx/test/fakestream/FakeStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public class FakeStream<T> implements ReadStream<T>, WriteStream<T> {

private static final Object END_SENTINEL = new Object();
private static final Object ERR_SENTINEL = new Object();

static class Op<T> {
final T item;
Expand Down Expand Up @@ -143,10 +144,21 @@ public void end(Handler<AsyncResult<Void>> h) {
}

public synchronized void fail(Throwable err) {
Handler<Throwable> handler = exceptionHandler;
if (handler != null) {
exceptionHandler.handle(err);
synchronized(this) {
if (ended) {
throw new IllegalStateException();
}
ended = true;
Promise<Void> promise = Promise.promise();
promise.future().onComplete(ar -> {
Handler<Throwable> handler = exceptionHandler;
if (handler != null) {
handler.handle(err);
}
});
pending.add(new Op<>((T)ERR_SENTINEL, promise));
}
checkPending();
}

@Override
Expand Down Expand Up @@ -178,6 +190,8 @@ private void checkPending() {
}
if (op.item == END_SENTINEL) {
end.onComplete(op.ack);
} else if(op.item == ERR_SENTINEL) {
op.ack.complete();
} else {
Handler<T> handler = itemHandler;
try {
Expand Down