summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oberlies2011-08-03 14:49:43 (EDT)
committerTobias Oberlies2011-08-03 15:14:50 (EDT)
commitaa82f551eda5fbead50fdc00d02368ca9e36809a (patch)
tree4b8d902de353235580991bfdf7d730ec6bbbdc21
parente45af3d34527db9b4dc4d683da5ad5d515aea7b7 (diff)
downloadrt.equinox.p2-aa82f551eda5fbead50fdc00d02368ca9e36809a.zip
rt.equinox.p2-aa82f551eda5fbead50fdc00d02368ca9e36809a.tar.gz
rt.equinox.p2-aa82f551eda5fbead50fdc00d02368ca9e36809a.tar.bz2
353767 Preserve root cause of "Artifact not found" when mirroring
- If multiple attempts are made to download an artifact, aggregate the results in a multi-status. This is necessary to preserve the root cause of a failure in a composite repository, which disables components if they fail with a non-retry status.
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties1
5 files changed, 15 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml b/bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml
index 2286f46..6737d5a 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml
@@ -10,6 +10,6 @@
</parent>
<groupId>org.eclipse</groupId>
<artifactId>org.eclipse.equinox.p2.artifact.repository</artifactId>
- <version>1.1.100-SNAPSHOT</version>
+ <version>1.1.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
index 68dbd1d..87cf474 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
@@ -378,7 +378,7 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
current.setBad(true);
// If more children are available, set retry
if (childIterator.hasNext())
- return new MultiStatus(Activator.ID, CODE_RETRY, new IStatus[] {status}, NLS.bind(Messages.retryRequest, current.repo.getLocation(), descriptor.getArtifactKey()), null);
+ return new MultiStatus(Activator.ID, CODE_RETRY, new IStatus[] {status}, NLS.bind(Messages.retryRequest, descriptor.getArtifactKey(), current.repo.getLocation()), null);
// Nothing that can be done, pass child's failure on
resetChildFailures();
return status;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
index da8c1f7..eae97fc 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
@@ -52,6 +52,7 @@ public class Messages extends NLS {
public static String MirrorLog_Exception_Occurred;
public static String MirrorRequest_multipleDownloadProblems;
+ public static String MirrorRequest_transferFailed;
public static String exception_unableToCreateParentDir;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
index 873c3ef..b0daef2 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
@@ -179,7 +179,8 @@ public class MirrorRequest extends ArtifactRequest {
* @return the status of the transfer operation
*/
protected IStatus transfer(IArtifactDescriptor destinationDescriptor, IArtifactDescriptor sourceDescriptor, IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
+ MultiStatus allResults = new MultiStatus(Activator.ID, 0, NLS.bind(Messages.MirrorRequest_transferFailed, sourceDescriptor), null);
+ IStatus lastResult = Status.OK_STATUS;
// go until we get one (OK), there are no more mirrors to consider or the operation is cancelled.
// Put a hard limit of MAX_RETRY_REQUEST so we don't end up in an infinite loop.
// Really, if you've tried MAX_RETRY_REQUEST times without success, it's time to give up
@@ -188,11 +189,16 @@ public class MirrorRequest extends ArtifactRequest {
int counter = 0;
do {
- status = transferSingle(destinationDescriptor, sourceDescriptor, monitor);
- } while (status.getSeverity() == IStatus.ERROR && status.getCode() == IArtifactRepository.CODE_RETRY && counter++ < MAX_RETRY_REQUEST);
- if (status.isOK())
+ lastResult = transferSingle(destinationDescriptor, sourceDescriptor, monitor);
+ allResults.add(lastResult);
+ } while (lastResult.getSeverity() == IStatus.ERROR && lastResult.getCode() == IArtifactRepository.CODE_RETRY && counter++ < MAX_RETRY_REQUEST);
+ if (lastResult.isOK()) {
collectStats(sourceDescriptor, monitor);
- return status;
+ return lastResult;
+ } else if (allResults.getChildren().length <= 1) {
+ return lastResult;
+ }
+ return allResults;
}
/**
@@ -247,11 +253,6 @@ public class MirrorRequest extends ArtifactRequest {
return new MultiStatus(Activator.ID, status.getCode(), new IStatus[] {status}, NLS.bind(Messages.error_closing_stream, getArtifactKey(), target.getLocation()), e);
return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.error_closing_stream, getArtifactKey(), target.getLocation()), e);
}
- if (status != null && status.getSeverity() == IStatus.ERROR) {
- IStatus root = extractRootCause(status);
- if (root != null && FileNotFoundException.class == root.getException().getClass())
- return new Status(IStatus.ERROR, Activator.ID, status.getCode(), NLS.bind(Messages.artifact_not_found, getArtifactKey()), root.getException());
- }
}
return status;
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
index 9622be2..68453f7 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
@@ -44,6 +44,7 @@ exception_noComparators = No Artifact Comparators are available.
MirrorLog_Console_Log=Logging to the console instead.
MirrorLog_Exception_Occurred=An exception occurred while writing to the log:
MirrorRequest_multipleDownloadProblems=Multiple problems occurred while downloading.
+MirrorRequest_transferFailed=Failed to transfer artifact {0}.
exception_unsupportedAddToComposite = Cannot add descriptors to a composite repository.
exception_unsupportedGetOutputStream=Cannot write artifacts to a composite repository.