Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-02-28 00:20:04 +0000
committerslewis2009-02-28 00:20:04 +0000
commit429cc21cd745734a8023df9cfe631099c889f678 (patch)
treea4f6a08c1376c5e06b8376a7f8562e9df8f8b6fa
parentf39f14c5fd8e9b60d3cf0ff05fd19f4692fa6c3e (diff)
downloadorg.eclipse.ecf-429cc21cd745734a8023df9cfe631099c889f678.tar.gz
org.eclipse.ecf-429cc21cd745734a8023df9cfe631099c889f678.tar.xz
org.eclipse.ecf-429cc21cd745734a8023df9cfe631099c889f678.zip
Contributions from attachment 127064 on bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=263613
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java40
1 files changed, 21 insertions, 19 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
index 106a6cd76..dc881c282 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
@@ -8,6 +8,7 @@
* Composent, Inc. - initial API and implementation
* Maarten Meijer - bug 237936, added gzip encoded transfer default
* Henrich Kraemer - bug 263869, testHttpsReceiveFile fails using HTTP proxy
+ * Henrich Kraemer - bug 263613, [transport] Update site contacting / downloading is not cancelable
******************************************************************************/
package org.eclipse.ecf.provider.filetransfer.httpclient;
@@ -180,6 +181,7 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
private String password;
private int responseCode = -1;
+ private volatile boolean doneFired = false;
private String remoteFileName;
@@ -435,10 +437,11 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
/* (non-Javadoc)
* @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#openStreams()
*/
- protected void openStreams() throws IncomingFileTransferException {
+ protected void openStreams() throws Exception {
Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "openStreams"); //$NON-NLS-1$
final String urlString = getRemoteFileURL().toString();
+ this.doneFired = false;
int code = -1;
@@ -463,13 +466,7 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
getMethod.setRequestHeader(GzipGetMethod.ACCEPT_ENCODING, GzipGetMethod.CONTENT_ENCODING_ACCEPTED);
fireConnectStartEvent();
- if (isCanceled()) {
- return;
- }
- if (isDone()) {
- if (getException() != null) {
- throw getException();
- }
+ if (checkAndHandleDone()) {
return;
}
@@ -483,16 +480,9 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
connectJob.join();
connectJob = null;
}
- if (isCanceled()) {
+ if (checkAndHandleDone()) {
return;
}
- if (isDone()) {
- Exception e = getException();
- if (e != null) {
- throw e;
- }
- return; // not expected
- }
code = responseCode;
Trace.trace(Activator.PLUGIN_ID, "retrieve resp=" + code); //$NON-NLS-1$
@@ -518,13 +508,24 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
throw new IOException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_ERROR_GENERAL_RESPONSE_CODE, new Integer(code)));
}
} catch (final Exception e) {
- IncomingFileTransferException ex = new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, urlString), e, code);
- Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, this.getClass(), "openStreams", ex); //$NON-NLS-1$
- throw ex;
+ Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, this.getClass(), "openStreams", e); //$NON-NLS-1$
+ throw e;
+
}
Trace.exiting(Activator.PLUGIN_ID, DebugOptions.METHODS_EXITING, this.getClass(), "openStreams"); //$NON-NLS-1$
}
+ private boolean checkAndHandleDone() {
+ if (isDone()) {
+ // for cancel the done event should have been fired always.
+ if (!doneFired) {
+ fireTransferReceiveDoneEvent();
+ }
+ return true;
+ }
+ return false;
+ }
+
/*
* (non-Javadoc)
*
@@ -873,6 +874,7 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
protected void fireTransferReceiveDoneEvent() {
Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "fireTransferReceiveDoneEvent len=" + fileLength + ";rcvd=" + bytesReceived); //$NON-NLS-1$ //$NON-NLS-2$
+ this.doneFired = true;
super.fireTransferReceiveDoneEvent();
}

Back to the top