Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 162585

Summary: [FTP] fetch children cannot be canceled
Product: [Tools] Target Management Reporter: Michael Scharf <eclipse>
Component: RSEAssignee: Javier Montalvo Orús <javier.montalvoorus>
Status: VERIFIED FIXED QA Contact: Martin Oberhuber <mober.at+eclipse>
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 1.0.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 162577    
Bug Blocks:    

Description Michael Scharf CLA 2006-10-27 12:15:10 EDT
The fetch children of a FTP connection runs a job that makes a blocking call. Canceling the fetch in the progress view does not cancel the job. 

The solution would be to call Thread.interrupt on Job Thread. Unfortunately, this is not possible (see bug 162577)

"Worker-304" prio=6 tid=0x07fca040 nid=0x10bc in Object.wait() [0x0526f000..0x0526fa68]
	at java.lang.Object.wait(Native Method)
	- waiting on <0x1e956ba0> (a [I)
	at java.lang.Object.wait(Unknown Source)
	at org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:339)
	- locked <0x1e956ba0> (a [I)
	at org.apache.commons.net.telnet.TelnetInputStream.read(TelnetInputStream.java:466)
	at java.io.BufferedInputStream.read1(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	- locked <0x1e95abc0> (a java.io.BufferedInputStream)
	at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source)
	at sun.nio.cs.StreamDecoder$CharsetSD.implRead(Unknown Source)
	at sun.nio.cs.StreamDecoder.read(Unknown Source)
	- locked <0x1e95ec48> (a java.io.InputStreamReader)
	at java.io.InputStreamReader.read(Unknown Source)
	at java.io.BufferedReader.fill(Unknown Source)
	at java.io.BufferedReader.readLine(Unknown Source)
	- locked <0x1e95ec48> (a java.io.InputStreamReader)
	at java.io.BufferedReader.readLine(Unknown Source)
	at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:264)
	at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:335)
	at org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:550)
	at org.apache.commons.net.SocketClient.connect(SocketClient.java:163)
	at org.apache.commons.net.SocketClient.connect(SocketClient.java:250)
	at org.eclipse.rse.services.files.ftp.FTPService.connect(FTPService.java:103)
	at org.eclipse.rse.subsystems.files.ftp.connectorservice.FTPConnectorService.internalConnect(FTPConnectorService.java:51)
	at org.eclipse.rse.subsystems.files.ftp.connectorservice.FTPConnectorService.internalConnect(FTPConnectorService.java:41)
	at org.eclipse.rse.core.subsystems.AbstractConnectorService.connect(AbstractConnectorService.java:798)
	at org.eclipse.rse.ui.operations.SystemFetchOperation.execute(SystemFetchOperation.java:178)
	- locked <0x16905df0> (a org.eclipse.rse.subsystems.files.ftp.connectorservice.FTPConnectorService)
	at org.eclipse.rse.ui.operations.SystemFetchOperation.run(SystemFetchOperation.java:101)
	at org.eclipse.rse.ui.view.AbstractSystemViewAdapter.fetchDeferredChildren(AbstractSystemViewAdapter.java:1766)
	at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:207)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Comment 1 Javier Montalvo Orús CLA 2006-11-07 13:00:55 EST
Fixed in I20061107-0700.
Fetching children runs in a separate Job and can be cancelled.
Comment 2 David Dykstal CLA 2006-11-09 16:42:48 EST
I created a directory with 3000 files and used FTP to list the contents of the directory. The query took maybe 5 seconds. I attempted to cancel using the progress monitor but was not able to do so. After several refresh operations the progress monitor began not showing up. I had a Remote System Details view open on the folder and was refreshing using the refresh button on that view. The console log indicates that the listing is happening. I see no relevant messages in the .log file.

-----------Enter bugs above this line-----------
RSE 1.0 Testing Verification of fixes for I20061109
installation : Eclipse M20060629-1905 platform-3.2.1
RSE install  : RSE SDK I20061109
java.runtime : Sun VM 1.5
os.name:     : Mac OS X 10.4.8
------------------------------------------------
systemtype   : FTP Only
targetos     : Mac OS X
targetvm     : N/A
--------------------------------------
Comment 3 Javier Montalvo Orús CLA 2006-11-20 11:25:20 EST
I'll move the fetching children call into a Thread instead of a Job, as there's already a Job covering it.
Cancelling the parent Job will force a termination of the fetching process.
Comment 4 Javier Montalvo Orús CLA 2006-11-20 11:57:46 EST
I've moved the fetching action into a Thread, now it should work fine when cancelling the fetching Job action.
This solution only covers the FTP list files action, not the population of the RSE tree, that might be quite slow and migh require some rework on the UI.

So, the cancel action will only work if performed between opening and closing the data channel. It can be seen in the console log as the interval between the 150 and 226 code messages, something like: 

LIST
150 Opening data channel for sending file.
226 Transfer OK
Comment 5 David McKnight CLA 2006-12-14 17:18:46 EST
I've tried this out and I see that if I press cancel before the operation completes, the output is returned as  "operation failed...".  The message would probably be better as something along the lines of "operation cancelled".  Nevertheless the operation does get cancelled.