Skip to content

Close response stream on unsupported content encoding#10325

Open
jmestwa-coder wants to merge 1 commit into
gwtproject:mainfrom
jmestwa-coder:urlrequesttransport-stream-leak
Open

Close response stream on unsupported content encoding#10325
jmestwa-coder wants to merge 1 commit into
gwtproject:mainfrom
jmestwa-coder:urlrequesttransport-stream-leak

Conversation

@jmestwa-coder

Copy link
Copy Markdown

Summary

This fixes a response stream leak in UrlRequestTransport when the server returns an unsupported Content-Encoding.

Problem

  • send() opens the response InputStream.
  • When Content-Encoding is unsupported, the method reports a transport failure and returns immediately.
  • The opened stream is not closed before returning.

Fix

  • Close the response stream before returning from the unsupported encoding branch.
  • No changes to existing success or failure behavior.
  • No changes to transport callbacks or response handling.

@tbroyer

tbroyer commented May 30, 2026

Copy link
Copy Markdown
Member

Won't connection.disconnect() in the finally block already take care of this?

@zbynek

zbynek commented May 31, 2026

Copy link
Copy Markdown
Collaborator

This makes the code more symmetrical (the stream is explicitly closed when encoding is correct, so closing it when it's incorrect makes sense). OTOH @tbroyer is right that the stream is closed automatically in disconnect (at least with OpenJDK).

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.

3 participants