Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331212 - [transport] FileReader fails to stop CancelHandler Job
Summary: [transport] FileReader fails to stop CancelHandler Job
Status: CLOSED WONTFIX
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: P2 Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-26 10:03 EST by Eckart Langhuth CLA
Modified: 2020-08-12 08:20 EDT (History)
3 users (show)

See Also:


Attachments
FileReader test project (6.38 KB, application/octet-stream)
2011-06-28 10:19 EDT, Eckart Langhuth CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eckart Langhuth CLA 2010-11-26 10:03:48 EST
Build Identifier: org.eclipse.equinox.p2.repository 2.0.1.R36x_v20100823

org.eclipse.equinox.internal.p2.repository.FileReader implementation might fail to cancel related FileReader$CancelHandler Jobs.

When trying to update with improper proxy settings I end up with 950+ worker threads crashing the VM.
All worker stacks look like:
	Thread.sleep(long) line: not available [native method]	
	FileReader$CancelHandler.run(IProgressMonitor) line: 104	
	Worker.run() line: 54	

It seems the problem is that after catching an Exception in
	HttpClientRetrieveFileTransfer.performConnect(IProgressMonitor) line: 1145	
	HttpClientRetrieveFileTransfer.openStreams() line: 710	
	
the FileReader receives a IIncomingFileTransferReceiveDoneEvent via  
	FileReader.handleTransferEvent(IFileTransferEvent) line: 186	
	HttpClientRetrieveFileTransfer(AbstractRetrieveFileTransfer).fireTransferReceiveDoneEvent() line: 365	
	HttpClientRetrieveFileTransfer.fireTransferReceiveDoneEvent() line: 1169	
	HttpClientRetrieveFileTransfer.checkAndHandleDone() line: 788	
	HttpClientRetrieveFileTransfer.openStreams() line: 716

and does not stop the related cancelJob during handling this event.
 
(org.eclipse.equinox.p2.repository 2.0.1.R36x_v20100823)


Reproducible: Always

Steps to Reproduce:
Probably requires special network settings.
Access of external content requires usage of a proxy. 
Bypassing the proxy will lead to probematic Unknown host exceptions.
Comment 1 Pascal Rapicault CLA 2011-06-10 23:58:39 EDT
Please try again with 3.7 and reopen if the issue still exists. Thx
Comment 2 Eckart Langhuth CLA 2011-06-28 10:19:52 EDT
Created attachment 198734 [details]
FileReader test project

Attached simple JUnit Plug-in Test project.
Running with Eclipse 3.7 it generates contained myLocalOutput.txt.

None of the workers
Thread[Worker-22,5,main]
 java.lang.Thread.sleep(Native Method)
 org.eclipse.equinox.internal.p2.transport.ecf.FileReader$CancelHandler.run(FileReader.java:111)
 org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
will ever finish.
Comment 3 Eckart Langhuth CLA 2011-06-28 10:23:02 EDT
See attached test project.
org.eclipse.equinox.internal.p2.transport.ecf.FileReader will leak a worker thread in case an UnknownHostException occurs.
Comment 4 Pascal Rapicault CLA 2011-06-28 21:21:26 EDT
Henrik, could you please take a look?
Comment 5 Henrik Lindberg CLA 2011-06-29 18:45:18 EDT
(In reply to comment #4)
> Henrik, could you please take a look?

I am not setup to work on this. I did take a look at the code. And it seems that if these lines:

 // kill the cancelJob, if there is one
 if (cancelJob != null) {
   cancelJob.cancel();
   cancelJob = null;
}

were to also be inserted into this method: public synchronized void handleTransferEvent(IFileTransferEvent event)

} else if (event instanceof IIncomingFileTransferReceiveDoneEvent) {
if (closeStreamWhenFinished)
hardClose(theOutputStream);

just before the if(closeStreamWhenFinished) check

that would probably solve the problem as at that point (done), the cancel job has played out its role anyway. For a normal run the cancel job would have been cancelled by one of the other callbacks.
Comment 6 Eclipse Genie CLA 2019-10-23 01:51:56 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Michalis Adamidis CLA 2020-08-12 02:56:29 EDT
This bug can still be seen. We currently experience it in several places, one of which is really annoying:

When building an eclipse plugin via maven the hanging worker threads will cause the spawning maven process to run indefinitely. This means CI jobs on a machine without direct access to the internet and no configured proxy settings (which is intentionally left out) will never finish.

The behavior can also be seen in other eclipse projects accessing update sites like the oomph setup mechanisms. At least there the stale processes are killed as soon as the tool is of the opinion that it's finished.
Comment 8 Michalis Adamidis CLA 2020-08-12 08:20:40 EDT
As a hint for other people having problems with this:

The tycho maven plugin is trying to call a mirror list from the official eclipse repositories, even if you have configured specific sources for artifacts in the respective plugin project. If the host for that call cannot be resolved it will result in the stale threads described in this issue which will hang the maven process indefinitely.

To get rid of this configure your environment to not ask for mirror lists as described here: https://wiki.eclipse.org/Tycho/FAQ#How_do_I_disable_P2_mirrors.3F

Even though the above works around the issue, this bug should still be fixed.