Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2010-05-21 00:21:48 -0400
committerslewis2010-05-21 00:21:48 -0400
commit02008da0e9c0c2ebf660158f82c7fa0600732504 (patch)
tree7eaa7f95b329c7e750e175eb988d6f612ab598e5 /providers/bundles/org.eclipse.ecf.provider.filetransfer
parent88018c2c997d54d7ac017806b9ef3627201c0e74 (diff)
downloadorg.eclipse.ecf-02008da0e9c0c2ebf660158f82c7fa0600732504.tar.gz
org.eclipse.ecf-02008da0e9c0c2ebf660158f82c7fa0600732504.tar.xz
org.eclipse.ecf-02008da0e9c0c2ebf660158f82c7fa0600732504.zip
Fixes for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=313519
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.java16
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/util/PollingInputStream.java41
2 files changed, 50 insertions, 7 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 e90a34321..6924d3b41 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
@@ -66,7 +66,7 @@ public abstract class AbstractRetrieveFileTransfer implements IIncomingFileTrans
public static final int DEFAULT_BUF_LENGTH = 4096;
- protected static final int POLLING_RETRY_ATTEMPTS = new Integer(System.getProperty("org.eclipse.ecf.provider.filetransfer.retrieve.retryAttempts", "20")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$;;
+ protected static final int POLLING_RETRY_ATTEMPTS = new Integer(System.getProperty("org.eclipse.ecf.provider.filetransfer.retrieve.retryAttempts", "30")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$;;
protected static final int TIMEOUT_INPUTSTREAM_BUFFER_SIZE = 8192;
@@ -74,6 +74,18 @@ public abstract class AbstractRetrieveFileTransfer implements IIncomingFileTrans
protected static final int CLOSE_TIMEOUT = new Integer(System.getProperty("org.eclipse.ecf.provider.filetransfer.retrieve.closeTimeout", "1000")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$;
+ private static final String readTimeoutMessage = "Timeout while reading input stream.\n" + //$NON-NLS-1$
+ "The following system properties can be used to adjust the readTimeout, retryAttempts, and closeTimeout\n" + //$NON-NLS-1$
+ "\torg.eclipse.ecf.provider.filetransfer.retrieve.readTimeout=<default:1000>\n" + //$NON-NLS-1$
+ "\torg.eclipse.ecf.provider.filetransfer.retrieve.retryAttempts=<default:30>\n" + //$NON-NLS-1$
+ "\torg.eclipse.ecf.provider.filetransfer.retrieve.closeTimeout=<default:1000>\n"; //$NON-NLS-1$
+
+ private static final String closeTimeoutMessage = "Timeout while closing input stream.\n" + //$NON-NLS-1$
+ "The following system properties can be used to adjust the readTimeout, retryAttempts, and closeTimeout\n" + //$NON-NLS-1$
+ "\torg.eclipse.ecf.provider.filetransfer.retrieve.readTimeout=<default:1000>\n" + //$NON-NLS-1$
+ "\torg.eclipse.ecf.provider.filetransfer.retrieve.retryAttempts=<default:30>\n" + //$NON-NLS-1$
+ "\torg.eclipse.ecf.provider.filetransfer.retrieve.closeTimeout=<default:1000>\n"; //$NON-NLS-1$
+
protected Object jobLock = new Object();
protected Job job;
@@ -125,7 +137,7 @@ public abstract class AbstractRetrieveFileTransfer implements IIncomingFileTrans
}
protected InputStream wrapTransferReadInputStream(InputStream inputStream, IProgressMonitor monitor) {
- return new PollingInputStream(remoteFileContents, getRetryAttempts(), monitor);
+ return new PollingInputStream(remoteFileContents, getRetryAttempts(), monitor, readTimeoutMessage, closeTimeoutMessage);
}
private int getRetryAttempts() {
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/util/PollingInputStream.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/util/PollingInputStream.java
index a21ff6870..a66ba05fd 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/util/PollingInputStream.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/util/PollingInputStream.java
@@ -39,6 +39,9 @@ public class PollingInputStream extends FilterInputStream {
private IProgressMonitor monitor;
private boolean cancellable;
+ private String readTimeoutMessage = "Timeout while reading input stream"; //$NON-NLS-1$
+ private String closeTimeoutMessage = "Timeout while closing input stream"; //$NON-NLS-1$
+
/**
* Creates a new polling input stream.
*
@@ -59,6 +62,32 @@ public class PollingInputStream extends FilterInputStream {
}
/**
+ * Creates a new polling input stream.
+ *
+ * @param in
+ * the underlying input stream
+ * @param numAttempts
+ * the number of attempts before issuing an
+ * InterruptedIOException, if 0, retries indefinitely until
+ * canceled
+ * @param monitor
+ * the progress monitor to be polled for cancellation
+ * @param readTimeoutMessage message to go with InteruptedIOException if read timeout
+ * @param closeTimeoutMessage message to go with InteruptedIOException if close timeout
+ * @since 3.1
+ */
+ public PollingInputStream(InputStream in, int numAttempts, IProgressMonitor monitor, String readTimeoutMessage, String closeTimeoutMessage) {
+ super(in);
+ this.numAttempts = numAttempts;
+ this.monitor = monitor;
+ this.cancellable = true;
+ if (readTimeoutMessage != null)
+ this.readTimeoutMessage = readTimeoutMessage;
+ if (closeTimeoutMessage != null)
+ this.closeTimeoutMessage = closeTimeoutMessage;
+ }
+
+ /**
* Wraps the underlying stream's method. It may be important to wait for an
* input stream to be closed because it holds an implicit lock on a system
* resource (such as a file) while it is open. Closing a stream may take
@@ -89,7 +118,7 @@ public class PollingInputStream extends FilterInputStream {
if (checkCancellation())
throw new OperationCanceledException();
if (++attempts == numAttempts)
- throw new InterruptedIOException("Timeout while closing input stream"); //$NON-NLS-1$
+ throw new InterruptedIOException(closeTimeoutMessage);
} catch (IOException e) {
// ignore it - see
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=203423#c10
@@ -99,7 +128,9 @@ public class PollingInputStream extends FilterInputStream {
}
private void logError(String message, IOException e) {
- Activator.getDefault().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, message, e));
+ Activator a = Activator.getDefault();
+ if (a != null)
+ a.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, message, e));
}
/**
@@ -123,7 +154,7 @@ public class PollingInputStream extends FilterInputStream {
return in.read();
} catch (InterruptedIOException e) {
if (++attempts == numAttempts)
- throw new InterruptedIOException("Timeout while reading input stream"); //$NON-NLS-1$
+ throw new InterruptedIOException(readTimeoutMessage);
}
}
}
@@ -158,7 +189,7 @@ public class PollingInputStream extends FilterInputStream {
if (e.bytesTransferred != 0)
return e.bytesTransferred; // keep partial transfer
if (++attempts == numAttempts)
- throw new InterruptedIOException("Timeout while reading input stream"); //$NON-NLS-1$
+ throw new InterruptedIOException(readTimeoutMessage);
}
}
}
@@ -188,7 +219,7 @@ public class PollingInputStream extends FilterInputStream {
if (e.bytesTransferred != 0)
return e.bytesTransferred; // keep partial transfer
if (++attempts == numAttempts)
- throw new InterruptedIOException("Timeout while reading input stream"); //$NON-NLS-1$
+ throw new InterruptedIOException(readTimeoutMessage);
}
}
}

Back to the top