Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-10-26 15:18:33 -0400
committerslewis2009-10-26 15:18:33 -0400
commite66a6d6a28789bdc43daa4e3d894875573faf277 (patch)
tree5b529d626bc85320fc30c4969d7af386641b4daa /providers/bundles/org.eclipse.ecf.provider.filetransfer
parent281cd8e1f5d8322310ddf5bcdf1651c27ae646de (diff)
downloadorg.eclipse.ecf-e66a6d6a28789bdc43daa4e3d894875573faf277.tar.gz
org.eclipse.ecf-e66a6d6a28789bdc43daa4e3d894875573faf277.tar.xz
org.eclipse.ecf-e66a6d6a28789bdc43daa4e3d894875573faf277.zip
Added system properties for setting default connection and read timeouts. See bug 292995
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.filetransfer')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java55
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java24
2 files changed, 71 insertions, 8 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java
index 03f76b9f0..1fe92a553 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/AbstractRetrieveFileTransfer.java
@@ -120,7 +120,24 @@ public abstract class AbstractRetrieveFileTransfer implements IIncomingFileTrans
}
protected InputStream wrapTransferReadInputStream(InputStream inputStream, IProgressMonitor monitor) {
- return new PollingInputStream(remoteFileContents, POLLING_RETRY_ATTEMPTS, monitor);
+ return new PollingInputStream(remoteFileContents, getRetryAttempts(), monitor);
+ }
+
+ private int getRetryAttempts() {
+ int result = POLLING_RETRY_ATTEMPTS;
+ Map localOptions = getOptions();
+ if (localOptions != null) {
+ // See if the property is present, if so set
+ Object o = localOptions.get("org.eclipse.ecf.provider.filetransfer.retrieve.retryAttempts"); //$NON-NLS-1$
+ if (o != null) {
+ if (o instanceof Integer) {
+ result = ((Integer) o).intValue();
+ } else if (o instanceof String) {
+ result = new Integer(((String) o)).intValue();
+ }
+ }
+ }
+ return result;
}
private IFileTransferRunnable fileTransferRunnable = new IFileTransferRunnable() {
@@ -177,8 +194,42 @@ public abstract class AbstractRetrieveFileTransfer implements IIncomingFileTrans
return remoteFileURL;
}
+ protected int getSocketReadTimeout() {
+ int result = READ_TIMEOUT;
+ Map localOptions = getOptions();
+ if (localOptions != null) {
+ // See if the property is present, if so set
+ Object o = localOptions.get("org.eclipse.ecf.provider.filetransfer.retrieve.readTimeout"); //$NON-NLS-1$
+ if (o != null) {
+ if (o instanceof Integer) {
+ result = ((Integer) o).intValue();
+ } else if (o instanceof String) {
+ result = new Integer(((String) o)).intValue();
+ }
+ }
+ }
+ return result;
+ }
+
+ protected int getSocketCloseTimeout() {
+ int result = CLOSE_TIMEOUT;
+ Map localOptions = getOptions();
+ if (localOptions != null) {
+ // See if the property is present, if so set
+ Object o = localOptions.get("org.eclipse.ecf.provider.filetransfer.retrieve.closeTimeout"); //$NON-NLS-1$
+ if (o != null) {
+ if (o instanceof Integer) {
+ result = ((Integer) o).intValue();
+ } else if (o instanceof String) {
+ result = new Integer(((String) o)).intValue();
+ }
+ }
+ }
+ return result;
+ }
+
protected void setInputStream(InputStream ins) {
- remoteFileContents = new TimeoutInputStream(ins, TIMEOUT_INPUTSTREAM_BUFFER_SIZE, READ_TIMEOUT, CLOSE_TIMEOUT);
+ remoteFileContents = new TimeoutInputStream(ins, TIMEOUT_INPUTSTREAM_BUFFER_SIZE, getSocketReadTimeout(), getSocketCloseTimeout());
}
protected void setOutputStream(OutputStream outs) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java
index 64a5d7b11..9da168e87 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/UrlConnectionRetrieveFileTransfer.java
@@ -18,6 +18,7 @@ import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.net.URLConnection;
+import java.util.Map;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.ecf.core.security.Callback;
@@ -53,10 +54,6 @@ public class UrlConnectionRetrieveFileTransfer extends AbstractRetrieveFileTrans
private static final String JRE_READ_TIMEOUT_PROPERTY = "sun.net.client.defaultReadTimeout"; //$NON-NLS-1$
- // 10/26/2009: Added being able to set with system property with name org.eclipse.ecf.provider.filetransfer.readTimeout
- // for https://bugs.eclipse.org/bugs/show_bug.cgi?id=292995
- private static final String DEFAULT_READ_TIMEOUT = System.getProperty("org.eclipse.ecf.provider.filetransfer.retrieve.readTimeout", "1000"); //$NON-NLS-1$ //$NON-NLS-2$
-
protected URLConnection urlConnection;
protected int httpVersion = 1;
@@ -376,14 +373,29 @@ public class UrlConnectionRetrieveFileTransfer extends AbstractRetrieveFileTrans
return super.getAdapter(adapter);
}
+ protected String getConnectTimeout() {
+ String result = DEFAULT_CONNECT_TIMEOUT;
+ Map localOptions = getOptions();
+ if (localOptions != null) {
+ // See if the property is present, if so set
+ Object o = localOptions.get("org.eclipse.ecf.provider.filetransfer.retrieve.connectTimeout"); //$NON-NLS-1$
+ if (o instanceof Integer) {
+ result = ((Integer) o).toString();
+ } else if (o instanceof String) {
+ result = (String) o;
+ }
+ }
+ return result;
+ }
+
private void setupTimeouts() {
String existingTimeout = System.getProperty(JRE_CONNECT_TIMEOUT_PROPERTY);
if (existingTimeout == null) {
- System.setProperty(JRE_CONNECT_TIMEOUT_PROPERTY, DEFAULT_CONNECT_TIMEOUT);
+ System.setProperty(JRE_CONNECT_TIMEOUT_PROPERTY, getConnectTimeout());
}
existingTimeout = System.getProperty(JRE_READ_TIMEOUT_PROPERTY);
if (existingTimeout == null) {
- System.setProperty(JRE_READ_TIMEOUT_PROPERTY, DEFAULT_READ_TIMEOUT);
+ System.setProperty(JRE_READ_TIMEOUT_PROPERTY, "" + getSocketReadTimeout()); //$NON-NLS-1$
}
}

Back to the top