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
Request content preview isn't produced if decorate a service with ThrottlingService
#3816
Comments
ThrottlingService
TomcatService
with ThrottlingService
TomcatService
with ThrottlingService
ThrottlingService
It seems like the armeria/core/src/main/java/com/linecorp/armeria/internal/logging/ContentPreviewingUtil.java Line 59 in 5b384fb
I think we can safely change req.whenComplete().handle() to req.whenComplete().exceptionally() so that the logBuilder.requestContentPreview(null) is set only when the request is completed exceptionally.Otherwise, FilteredHttpRequest will set logBuilder.requestContentPreview() .
Are you sending a PR? 😆 |
On second thought, it might be better to fix public abstract class FilteredStreamMessage<T, U> implements StreamMessage<U> {
// Set true when being collected or subscribed
private volatile boolean subscribed;
protected FilteredStreamMessage(StreamMessage<T> upstream, boolean withPooledObjects) {
...
upstream.whenComplete().exceptionally(cause -> {
if (!subscribed) {
// complete `completionFuture` with the cause
}
}
} , and could remove |
Thanks @ikhoon! Second idea looks good. Let me prepare PR. I have a question. I found that when a |
When I locally tested it, |
I think I was confused. Please ignore 😅 |
@ikhoon, could you check following test? @Test
void shouldCompleteWhenUpstreamCompletedExceptionally() {
final EventLoop eventLoop = eventLoopExtension.get();
final ByteBuf buf = newPooledBuffer();
final HttpData data = HttpData.wrap(buf).withEndOfStream();
final DefaultStreamMessage<HttpData> stream = new DefaultStreamMessage<>();
stream.abort(new RuntimeException());
final AtomicBoolean completed = new AtomicBoolean();
final FilteredStreamMessage<HttpData, HttpData> filtered =
new FilteredStreamMessage<HttpData, HttpData>(stream) {
@Override
protected HttpData filter(HttpData obj) {
return obj;
}
};
filtered.whenComplete().handle((ignored, cause) -> {
completed.set(true);
return null;
});
eventLoop.execute(() -> filtered.collect(eventLoop));
await().untilAtomic(completed, Matchers.is(true));
}
I expected that So I guess we can simply
|
Good analysis. If upstream is aborted, it is propagated to |
I found that
RequestLog#requestContentPreview
returns null when I decorate a service usingContentPreviewingService
andThrottlingService
.The request content preview is not produced when aggregate a service which is decorated with following structure:
Following test can reproduce:
logging H1C:
logging H2C:
It works well if not decorated by the last one.
What I found is that
armeria/core/src/main/java/com/linecorp/armeria/internal/logging/ContentPreviewingUtil.java
Line 62 in dbc7d4d
is called before
armeria/core/src/main/java/com/linecorp/armeria/internal/logging/ContentPreviewingUtil.java
Line 82 in dbc7d4d
And this is because a
CloseEvent
fromHttp1RequestDecoder
is already in queue before collect.The text was updated successfully, but these errors were encountered: