Skip to content

Commit

Permalink
Minor refactor in Http2ServerRequestImpl the error notification
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Mar 2, 2019
1 parent 4bc9c35 commit 695ad8c
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/main/java/io/vertx/core/http/impl/Http2ServerRequestImpl.java
Expand Up @@ -110,24 +110,34 @@ void handleInterestedOpsChanged() {


@Override @Override
void handleException(Throwable cause) { void handleException(Throwable cause) {
boolean notify;
synchronized (conn) {
notify = !ended;
}
if (notify) {
notifyException(cause);
}
response.handleException(cause);
}

private void notifyException(Throwable failure) {
Handler<Throwable> handler; Handler<Throwable> handler;
synchronized (conn) { synchronized (conn) {
handler = ended ? null : exceptionHandler; handler = exceptionHandler;
} }
if (handler != null) { if (handler != null) {
handler.handle(cause); handler.handle(failure);
} }
response.handleException(cause);
} }


@Override @Override
void handleClose() { void handleClose() {
Handler<Throwable> handler; boolean notify;
synchronized (conn) { synchronized (conn) {
handler = streamEnded ? null : exceptionHandler; notify = !streamEnded;
} }
if (handler != null) { if (notify) {
handler.handle(new ClosedChannelException()); notifyException(new ClosedChannelException());
} }
response.handleClose(); response.handleClose();
} }
Expand Down Expand Up @@ -187,13 +197,13 @@ void handleEnd(MultiMap trailers) {


@Override @Override
void handleReset(long errorCode) { void handleReset(long errorCode) {
Handler<Throwable> handler; boolean notify;
synchronized (conn) { synchronized (conn) {
handler = ended ? null : exceptionHandler; notify = !ended;
ended = true; ended = true;
} }
if (handler != null) { if (notify) {
handler.handle(new StreamResetException(errorCode)); notifyException(new StreamResetException(errorCode));
} }
response.handleReset(errorCode); response.handleReset(errorCode);
} }
Expand Down

0 comments on commit 695ad8c

Please sign in to comment.