You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2012/12/17 17:18:35 UTC

[jira] [Resolved] (HTTPCLIENT-1281) GzipDecompressingEntity does not release InputStream when an IOException occurs while reading the Gzip header

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1281?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCLIENT-1281.
-------------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.2.3

Patch committed to both SVN trunk and 4.2.x branch with some minor tweaks. Please review.

Oleg 
                
> GzipDecompressingEntity does not release InputStream when an IOException occurs while reading the Gzip header
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1281
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1281
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.2.2, 4.2.3, Snapshot
>            Reporter: Francois-Xavier Bonnet
>            Priority: Blocker
>             Fix For: 4.2.3
>
>         Attachments: DecompressingEntity_patch.txt
>
>
> When calling method org.apache.http.client.entity.DecompressingEntity.getContent() for a GzipDecompressingEntity, the method tries to build a GZIPInputStream, then the GzipInputStream tries to read the Gzip header and fails throwing an IOException.
> At the end you get an Exception but the backend InputStream is never closed resulting in a connection leak.
> Here is a test to reproduce:
> 	@Test
> 	public void testGzipDecompressingEntityDoesNotCrashInConstructorAndLeaveInputStreamOpen()
> 			throws Exception {
> 		final AtomicBoolean inputStreamIsClosed = new AtomicBoolean(false);
> 		HttpEntity in = new InputStreamEntity(new InputStream() {
> 			@Override
> 			public int read() throws IOException {
> 				throw new IOException("An exception occurred");
> 			}
> 			@Override
> 			public void close() throws IOException {
> 				inputStreamIsClosed.set(true);
> 			}
> 		}, 123);
> 		GzipDecompressingEntity gunzipe = new GzipDecompressingEntity(in);
> 		try {
> 			InputStream is = gunzipe.getContent();
> 		} catch (IOException e) {
> 			// As I cannot get the content, GzipDecompressingEntity is supposed
> 			// to have released everything
> 			Assert.assertTrue(inputStreamIsClosed.get());
> 		}
> 	}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org