Skip to content

Commit

Permalink
Detect unexpected response leaks for multi-address client instances
Browse files Browse the repository at this point in the history
Motivation:

We already apply `HttpMessageDiscardWatchdogClientFilter` to
single-address clients to detect response leaks that could be caused by
unhandled exceptions in the filter chain. Multi-address client adds more
logic around a client group and therefore also could leak responses if
case on unexpected exceptions.

Modifications:

- Apply `HttpMessageDiscardWatchdogClientFilter` to multi-address client
instances;
- Enhance `HttpMessageDiscardWatchdogClientFilter` to include unhandled
exception in the logs to help narrow down the leak cause;

Result:

Users will see warn message if their multi-address client leaks
responses.
  • Loading branch information
idelpivnitskiy committed Nov 9, 2024
1 parent 77a3c51 commit b080620
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public StreamingHttpClient buildStreaming() {
urlClient = redirectConfig == null ? urlClient :
new RedirectingHttpRequesterFilter(redirectConfig).create(urlClient);

// Detect leaks that can be caused by unexpected exceptions
urlClient = HttpMessageDiscardWatchdogClientFilter.CLIENT_CLEANER.create(urlClient);

LOGGER.debug("Multi-address client created with base strategy {}", executionContext.executionStrategy());
return new FilterableClientToClient(urlClient, executionContext);
} catch (final Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected Single<StreamingHttpResponse> request(final StreamingHttpRequester del
LOGGER.warn("Discovered un-drained HTTP response message body which has " +
"been dropped by user code - this is a strong indication of a bug " +
"in a user-defined filter. Response payload (message) body must " +
"be fully consumed before discarding.");
"be fully consumed before discarding.", cause);
}
return Single.<StreamingHttpResponse>failed(cause).shareContextOnSubscribe();
});
Expand Down

0 comments on commit b080620

Please sign in to comment.