Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(http interceptor context): clear http interceptor context on resp… #856

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -247,41 +247,47 @@ private State onLegitimateRequest(LiveHttpRequest request, ChannelHandlerContext

HttpInterceptorContext context = new HttpInterceptorContext(secure, remoteAddress(ctx), ctx.executor(), timers);
Eventual<LiveHttpResponse> responseEventual = httpPipeline.handle(v11Request, context);
responseEventual.subscribe(new BaseSubscriber<>() {
@Override
public void hookOnSubscribe(Subscription s) {
subscription = s;
s.request(1);
}

@Override
public void hookOnComplete() {
eventProcessor.submit(new ResponseObservableCompletedEvent(ctx, request.id()));
}

@Override
public void hookOnError(Throwable cause) {
eventProcessor.submit(new ResponseObservableErrorEvent(ctx, cause, request.id()));
}
responseEventual.map(response ->
response.newBuilder().body(body ->
body.doOnCancel(() -> {
timers.stopTiming(RESPONSE_PROCESSING);
timers.stopTiming(REQUEST_PROCESSING);
context.clear();
})
.doOnEnd(throwable -> {
timers.stopTiming(RESPONSE_PROCESSING);
timers.stopTiming(REQUEST_PROCESSING);
context.clear();
})
).build()
)
.subscribe(new BaseSubscriber<>() {
@Override
public void hookOnSubscribe(Subscription s) {
subscription = s;
s.request(1);
}

@Override
public void hookOnNext(LiveHttpResponse response) {
eventProcessor.submit(new ResponseReceivedEvent(response, ctx));
}
@Override
public void hookOnComplete() {
eventProcessor.submit(new ResponseObservableCompletedEvent(ctx, request.id()));
}

@Override
protected void hookOnCancel() {
eventProcessor.submit(new ResponseObservableCancelledEvent(ctx, new ResponseCancelledException(), request.id()));
}
@Override
public void hookOnError(Throwable cause) {
eventProcessor.submit(new ResponseObservableErrorEvent(ctx, cause, request.id()));
}

@Override
protected void hookFinally(SignalType type) {
timers.stopTiming(RESPONSE_PROCESSING);
timers.stopTiming(REQUEST_PROCESSING);
@Override
public void hookOnNext(LiveHttpResponse response) {
eventProcessor.submit(new ResponseReceivedEvent(response, ctx));
}

context.clear();
}
});
@Override
protected void hookOnCancel() {
eventProcessor.submit(new ResponseObservableCancelledEvent(ctx, new ResponseCancelledException(), request.id()));
}
});

return WAITING_FOR_RESPONSE;
} catch (Throwable cause) {
Expand Down
Loading