Skip to content

CXF-8096: Fix LoggingFeature blocking read on streaming responses#2957

Draft
gnodet wants to merge 6 commits intomainfrom
fix/CXF-8096-logging-streaming
Draft

CXF-8096: Fix LoggingFeature blocking read on streaming responses#2957
gnodet wants to merge 6 commits intomainfrom
fix/CXF-8096-logging-streaming

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 12, 2026

Summary

Fixes CXF-8096LoggingFeature blocks client reads on streaming responses.

Root cause: WireTapIn interceptor eagerly reads the entire input stream via IOUtils.copyAtLeast() before the application can process it. For streaming responses (e.g., StreamingOutput with chunked transfer), this blocks the client from reading data incrementally.

Fix:

  • Introduces TeeInputStream — wraps the input stream and copies data to the logging cache as it flows through (up to the configured limit), without blocking
  • WireTapIn now uses TeeInputStream instead of the eager copyAtLeast + SequenceInputStream approach
  • LoggingInInterceptor defers logging to a stream-close callback when the stream hasn't been consumed yet (streaming case), while preserving immediate logging for cases where the body is already consumed (e.g., SOAP/JAX-WS where unmarshal happens before PRE_INVOKE)

Key files:

  • TeeInputStream.java — new class, copies reads to CachedOutputStream transparently
  • WireTapIn.java — uses TeeInputStream instead of eager read
  • LoggingInInterceptor.java — deferred logging via close callback
  • Test updates to consume streams before asserting log events (reflecting the new non-blocking behavior)
  • New streamingInputShouldNotBlockRead test verifying the streaming scenario

Supersedes #574 (which was test-only with no fix).

Test plan

  • All existing logging module tests pass (124 tests)
  • New streaming test (streamingInputShouldNotBlockRead) verifies non-blocking behavior
  • CI pipeline

🤖 Generated with Claude Code

WireTapIn was eagerly reading the entire input stream (via
IOUtils.copyAtLeast) before the application could process it.
For streaming responses (e.g. StreamingOutput), this blocked the
client from reading data incrementally.

The fix replaces the eager copy + SequenceInputStream approach with
a TeeInputStream that copies data to the logging cache as it flows
through, up to the configured limit. LoggingInInterceptor now defers
logging to a close callback when the stream hasn't been consumed yet,
allowing streaming responses to flow through without blocking.

Supersedes #574.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added the bug label Mar 12, 2026
@gnodet gnodet marked this pull request as draft March 12, 2026 12:57
gnodet and others added 5 commits March 12, 2026 13:57
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The 5-second timeout introduced in #2962 is still not sufficient for
CI environments under load. Tracing tests like
testThatNewSpanIsCreatedOnClientTimeout continue to fail with
ConditionTimeoutException at the 5-second mark. Increase all Awaitility
timeouts to 10 seconds across all tracing test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant