Bug 574173 expose hard coded RepositoryPreferences as system properties
Allow to use following system properties to configure
RepositoryPreferences:
p2.RepositoryPreferences.retryOnSocketTimeout (default is false)
p2.RepositoryPreferences.connectionRetryCount (default is 1)
p2.RepositoryPreferences.connectionMsRetryDelay (default is 200)
Change-Id: I9340493bb6e88a706fcd94662a92e82ecc4fb76b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.p2/+/181876
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/RepositoryPreferences.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/RepositoryPreferences.java
index a126e80..23ce204 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/RepositoryPreferences.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/RepositoryPreferences.java
@@ -15,25 +15,44 @@
*/
public class RepositoryPreferences {
+ /** See bug 574173: allow to retry download if specified */
+ private static boolean retryOnSocketTimeout = Boolean.getBoolean("p2.RepositoryPreferences.retryOnSocketTimeout"); //$NON-NLS-1$
+
+ /** See bug 574173 */
+ private static int connectionRetryCount = Integer.getInteger("p2.RepositoryPreferences.connectionRetryCount", 1); //$NON-NLS-1$
+
+ /** See bug 574173 */
+ private static int connectionMsRetryDelay = Integer.getInteger("p2.RepositoryPreferences.connectionMsRetryDelay", //$NON-NLS-1$
+ 200);
+
/**
- * Number of attempts to connect (with same credentials) before giving up.
- * Note that newer ECF using apache HTTPclient has retry by default.
- * TODO - make this configurable via a property.
- * TODO - consider removing this option
+ * Number of attempts to connect (with same credentials) before giving up. Note
+ * that newer ECF using apache HTTPclient has retry by default. TODO - consider
+ * removing this option
+ *
* @return the value 1
*/
public static int getConnectionRetryCount() {
- return 1;
+ return connectionRetryCount;
}
/**
* Reconnect delay after failure to connect (with same credentials)- in milliseconds.
* Current implementation returns 200ms.
- * TODO - make this configurable via a property
* @return the value 200
*/
public static long getConnectionMsRetryDelay() {
- return 200;
+ return connectionMsRetryDelay;
+ }
+
+ /**
+ * Whether an attempt should be made to retry download if the connection was
+ * terminated by SocketTimeoutException
+ *
+ * @return {@code false} by default
+ */
+ public static boolean getRetryOnSocketTimeout() {
+ return retryOnSocketTimeout;
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java
index 6e6d6b9..97c7e2f 100644
--- a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java
+++ b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java
@@ -108,6 +108,8 @@
private ProgressStatistics statistics;
private final int connectionRetryCount;
private final long connectionRetryDelay;
+ /** See bug 574173: allow to retry download if specified */
+ private final boolean retryOnSocketTimeout;
private final IConnectContext connectContext;
private URI requestUri;
protected IFileTransferConnectStartEvent connectEvent;
@@ -130,6 +132,7 @@
setUser(false);
connectionRetryCount = RepositoryPreferences.getConnectionRetryCount();
connectionRetryDelay = RepositoryPreferences.getConnectionMsRetryDelay();
+ retryOnSocketTimeout = RepositoryPreferences.getRetryOnSocketTimeout();
connectContext = aConnectContext;
this.agent = aAgent;
}
@@ -512,11 +515,14 @@
if (t instanceof CoreException)
throw RepositoryStatusHelper.unwindCoreException((CoreException) t);
- // not meaningful to try 'timeout again' - if a server is that busy, we
- // need to wait for quite some time before retrying- it is not likely it is
- // just a temporary network thing.
- if (t instanceof SocketTimeoutException)
- throw RepositoryStatusHelper.wrap(t);
+ if (!retryOnSocketTimeout) {
+ // not meaningful to try 'timeout again' - if a server is that busy, we
+ // need to wait for quite some time before retrying- it is not likely it is
+ // just a temporary network thing.
+ if (t instanceof SocketTimeoutException) {
+ throw RepositoryStatusHelper.wrap(t);
+ }
+ }
if (t instanceof IOException && attemptCounter < connectionRetryCount) {
// TODO: Retry only certain exceptions or filter out