Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368830 - fix NPE when releasing request
Summary: fix NPE when releasing request
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.7   Edit
Assignee: Steffen Pingel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 335254
  Show dependency tree
 
Reported: 2012-01-17 09:58 EST by Steffen Pingel CLA
Modified: 2012-02-23 09:02 EST (History)
1 user (show)

See Also:


Attachments
mylyn/context/zip (2.89 KB, application/octet-stream)
2012-01-17 16:54 EST, Steffen Pingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Pingel CLA 2012-01-17 09:58:12 EST
HttpUtil.getResponseBodyAsStream() uses a producer/consumer pattern to read streams with support for cancellation. The implementation spawns a thread that fills a buffer until the stream is closed or exhausted. With HttpCore this can cause problems when the end of the stream is reached and it is automatically closed by the entity. If the request is released concurrently by the thread reading from the buffer this will cause an NPE. 

https://hudson.eclipse.org/hudson/user/spingel/my-views/view/Mylyn/job/mylyn-builds-nightly/215/testReport/org.eclipse.mylyn.hudson.tests.client/HudsonClientTest/testValidateValidUrl/

java.lang.NullPointerException
	at org.apache.http.conn.BasicManagedEntity.streamClosed(BasicManagedEntity.java:153)
	at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:237)
	at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:186)
	at org.apache.http.util.EntityUtils.consume(EntityUtils.java:67)
	at org.eclipse.mylyn.commons.repositories.http.core.HttpUtil.release(HttpUtil.java:330)
	at org.eclipse.mylyn.internal.hudson.core.client.HudsonOperation.updateCrumb(HudsonOperation.java:128)
	at org.eclipse.mylyn.internal.hudson.core.client.HudsonOperation.authenticate(HudsonOperation.java:95)
	at org.eclipse.mylyn.commons.repositories.http.core.CommonHttpOperation.executeOnce(CommonHttpOperation.java:80)
	at org.eclipse.mylyn.commons.repositories.http.core.CommonHttpOperation.execute(CommonHttpOperation.java:64)
	at org.eclipse.mylyn.internal.hudson.core.client.RestfulHudsonClient$8.execute(RestfulHudsonClient.java:405)
	at org.eclipse.mylyn.internal.hudson.core.client.RestfulHudsonClient$8.execute(RestfulHudsonClient.java:1)
	at org.eclipse.mylyn.internal.hudson.core.client.HudsonOperation.run(HudsonOperation.java:134)
	at org.eclipse.mylyn.internal.hudson.core.client.RestfulHudsonClient.validate(RestfulHudsonClient.java:427)
	at org.eclipse.mylyn.hudson.tests.client.HudsonClientTest.testValidateValidUrl(HudsonClientTest.java:57)
Comment 1 Steffen Pingel CLA 2012-01-17 16:54:49 EST
I have committed a work-around in 6eba6ca65b76ed6589cc2f81c103d17e36fc055f to ignore the exception. This will need to get fixed properly though.
Comment 2 Steffen Pingel CLA 2012-01-17 16:54:51 EST
Created attachment 209648 [details]
mylyn/context/zip
Comment 3 Steffen Pingel CLA 2012-02-23 09:02:43 EST
The NPE has been addressed through disabling support for cancellation for ongoing transfers in commit 1dd26ba24948eb518706d195cb76dd1514224f1d. Unfortunately there is no straight forward solution to provide cancellation in a thread-safe manner. I have opened bug 372332 to track that.