Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Goubet2017-08-02 14:10:11 +0000
committerlgoubet2021-03-29 12:06:05 +0000
commit3c776f0388a39ccd076e9832a737740dab0b515b (patch)
treedfd398de827892173ee0d0e3d86953b486aa8575
parent6c6cc6f58fde6c87448aeb167f2c82e74d6c2966 (diff)
downloadrt.equinox.p2-3c776f0388a39ccd076e9832a737740dab0b515b.tar.gz
rt.equinox.p2-3c776f0388a39ccd076e9832a737740dab0b515b.tar.xz
rt.equinox.p2-3c776f0388a39ccd076e9832a737740dab0b515b.zip
P2 should honor retry property on time outs for repository metadataI20210329-1800
Bug: 520461 Signed-off-by: Laurent Goubet <laurent.goubet@obeo.fr> Change-Id: Iaa96aea34026c6cd1c539f651ff3d6aef7ca168a
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.transport.ecf/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java12
5 files changed, 37 insertions, 9 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
index 99b3e9f41..5b5b1cfe6 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java
@@ -27,6 +27,7 @@ import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.osgi.util.NLS;
/**
@@ -189,7 +190,7 @@ public class CacheManager {
// bug 269588 - server may return 0 when file exists, so extra flag is needed
boolean useJar = true;
try {
- lastModifiedRemote = transport.getLastModified(jarLocation, submonitor.newChild(1));
+ lastModifiedRemote = getLastModified(jarLocation, submonitor.newChild(1));
if (lastModifiedRemote <= 0)
LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Server returned lastModified <= 0 for " + jarLocation)); //$NON-NLS-1$
} catch (AuthenticationFailedException e) {
@@ -226,7 +227,7 @@ public class CacheManager {
// (Status is reported based on finding the XML file as giving up on certain errors
// when checking for the jar may not be correct).
try {
- lastModifiedRemote = transport.getLastModified(xmlLocation, submonitor.newChild(1));
+ lastModifiedRemote = getLastModified(xmlLocation, submonitor.newChild(1));
// if lastModifiedRemote is 0 - something is wrong in the communication stack, as
// a FileNotFound exception should have been thrown.
// bug 269588 - server may return 0 when file exists - site is not correctly configured
@@ -267,6 +268,24 @@ public class CacheManager {
}
}
+ private long getLastModified(URI location, IProgressMonitor monitor) throws AuthenticationFailedException, FileNotFoundException, CoreException {
+ CoreException exception = null;
+ long lastModifiedRemote = -1L;
+ do {
+ try {
+ lastModifiedRemote = transport.getLastModified(location, monitor);
+ } catch (CoreException e) {
+ if (e.getStatus() == null) {
+ throw e;
+ }
+ exception = e;
+ }
+ } while (exception != null && exception.getStatus() != null && exception.getStatus().getCode() == IArtifactRepository.CODE_RETRY);
+ if (exception != null)
+ throw exception;
+ return lastModifiedRemote;
+ }
+
/**
* Deletes the local cache file(s) for the given repository
* @param repositoryLocation
@@ -402,6 +421,9 @@ public class CacheManager {
try {
submonitor.setWorkRemaining(1000);
result = transport.download(remoteFile, stream, submonitor.newChild(1000));
+ while (result.getCode() == IArtifactRepository.CODE_RETRY) {
+ result = transport.download(remoteFile, stream, submonitor.newChild(1000));
+ }
} catch (OperationCanceledException e) {
// need to pick up the status - a new operation canceled exception is thrown at the end
// as status will be CANCEL.
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
index 06a338c2a..81083d924 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
@@ -34,6 +34,7 @@ import org.eclipse.equinox.p2.core.spi.IAgentService;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.security.storage.EncodingUtils;
import org.eclipse.osgi.util.NLS;
import org.osgi.service.prefs.BackingStoreException;
@@ -727,6 +728,9 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
ByteArrayOutputStream index = new ByteArrayOutputStream();
IStatus indexFileStatus = null;
indexFileStatus = getTransport().download(indexFileURI, index, monitor);
+ while (indexFileStatus.getCode() == IArtifactRepository.CODE_RETRY) {
+ indexFileStatus = getTransport().download(indexFileURI, index, monitor);
+ }
if (indexFileStatus != null && indexFileStatus.isOK())
return LocationProperties.create(new ByteArrayInputStream(index.toByteArray()));
return LocationProperties.createEmptyIndexFile();
diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF
index bbceef3db..2bf8a892d 100644
--- a/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.transport.ecf
-Bundle-Version: 1.3.0.qualifier
+Bundle-Version: 1.3.100.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.ecf;bundle-version="3.1.0",
org.eclipse.ecf.filetransfer;bundle-version="4.0.0",
diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/pom.xml b/bundles/org.eclipse.equinox.p2.transport.ecf/pom.xml
index b6fbd6281..6447c88a0 100644
--- a/bundles/org.eclipse.equinox.p2.transport.ecf/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.transport.ecf/pom.xml
@@ -9,6 +9,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.p2.transport.ecf</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.3.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java
index ba13b7fc4..a705ddcc0 100644
--- a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java
+++ b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java
@@ -192,8 +192,8 @@ public class RepositoryTransport extends Transport {
// must translate this core exception as it is most likely not informative to a
// user
if (e.getStatus().getException() == null)
- throw new CoreException(RepositoryStatus.forException(e, toDownload));
- throw new CoreException(RepositoryStatus.forStatus(e.getStatus(), toDownload));
+ throw new CoreException(forException(e, toDownload));
+ throw new CoreException(forStatus(e.getStatus(), toDownload));
} catch (LoginCanceledException e) {
// i.e. same behavior when user cancels as when failing n attempts.
throw new AuthenticationFailedException();
@@ -253,8 +253,8 @@ public class RepositoryTransport extends Transport {
// must translate this core exception as it is most likely not informative to a
// user
if (e.getStatus().getException() == null)
- throw new CoreException(RepositoryStatus.forException(e, toDownload));
- throw new CoreException(RepositoryStatus.forStatus(e.getStatus(), toDownload));
+ throw new CoreException(forException(e, toDownload));
+ throw new CoreException(forStatus(e.getStatus(), toDownload));
} catch (AuthenticationFailedException e) {
promptUser = true;
} catch (LoginCanceledException e) {
@@ -278,6 +278,8 @@ public class RepositoryTransport extends Transport {
return true;
else if (t instanceof SocketException)
return true;
+ else if (t instanceof IncomingFileTransferException && ((IncomingFileTransferException) t).getErrorCode() == 503)
+ return true;
return false;
}
@@ -308,7 +310,7 @@ public class RepositoryTransport extends Transport {
retryCount = Integer.valueOf(alreadyRetryCount.intValue() + 1);
}
}
- if (retryCount != null) {
+ if (retryCount != null && retryCount.intValue() <= retry) {
socketExceptionRetry.put(toDownload, retryCount);
return new DownloadStatus(IStatus.ERROR, Activator.ID, IArtifactRepository.CODE_RETRY,
NLS.bind(Messages.connection_to_0_failed_on_1_retry_attempt_2, new String[] {

Back to the top