Skip to content

Close HTTP response streams when interceptors throw - #7361

Open
afarber wants to merge 1 commit into
aws:masterfrom
afarber:5005-http-connection-leak
Open

afarber wants to merge 1 commit into
aws:masterfrom
afarber:5005-http-connection-leak

Conversation

@afarber

@afarber afarber commented Sep 9, 2026

Copy link
Copy Markdown

Motivation and Context

Fixes #5005.

A synchronous HTTP response stream could leak when a response execution interceptor threw an exception before the response handler took ownership of the stream.

Modifications

  • Close synchronous response streams when afterTransmission or beforeUnmarshalling interceptors throw.
  • Close the current response stream when modifyHttpResponse or modifyHttpResponseContent throws.
  • Add regression coverage for all affected response interceptor hooks.
  • Add a changelog entry.

Testing

./mvnw -pl :sdk-core -am \
  -Dtest=SyncClientHandlerInterceptorExceptionTest \
  -Dsurefire.failIfNoSpecifiedTests=false \
  -Dspotbugs.skip=true test

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

License

  • I confirm that this pull request can be released under the Apache 2 license

@afarber
afarber requested a review from a team as a code owner September 9, 2026 14:54
@afarber
afarber force-pushed the 5005-http-connection-leak branch from e8b30e1 to 662da6b Compare September 9, 2026 16:43
@afarber
afarber force-pushed the 5005-http-connection-leak branch from 662da6b to 073d2eb Compare September 12, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP connection leaked if ExecutionInterceptor throws exception

1 participant