summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Bull2012-04-27 17:40:20 (EDT)
committerIan Bull2012-04-27 17:40:20 (EDT)
commitb26ae58972e96118b4f9e4496438fc218e5ab2d0 (patch)
tree618c5d1ec9757c2efdd7c81905944f5886911180
parentbf5c8bdedac8655c0534ed63df3a99b9fa1e7679 (diff)
downloadrt.equinox.p2-b26ae58972e96118b4f9e4496438fc218e5ab2d0.zip
rt.equinox.p2-b26ae58972e96118b4f9e4496438fc218e5ab2d0.tar.gz
rt.equinox.p2-b26ae58972e96118b4f9e4496438fc218e5ab2d0.tar.bz2
Bug 377976 : Don't continually try to download bad artifacts.v20120427-2140
If there is a processing error (non-transport error), we can now set the status code ARTIFACT_PROCESSING_ERROR. This will skip the retry attempts. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377976
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java19
3 files changed, 29 insertions, 3 deletions
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 20da9ae..ab26835 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
@@ -38,6 +38,12 @@ import org.eclipse.osgi.util.NLS;
public class MirrorRequest extends ArtifactRequest {
/**
+ * A Status code that represents an error while processing the artifact. This error is not
+ * related to transport, but rather a problem with the processing step.
+ */
+ public static final int ARTIFACT_PROCESSING_ERROR = 2;
+
+ /**
* Maximum number of times a request for a single artifact should be tried
*/
private static final int MAX_RETRY_REQUEST = 200;
@@ -199,6 +205,9 @@ public class MirrorRequest extends ArtifactRequest {
int counter = 0;
do {
+ if (counter > 0) {
+ System.out.println("Retry: " + counter + " " + sourceDescriptor.getArtifactKey().getId());
+ }
lastResult = transferSingle(destinationDescriptor, sourceDescriptor, monitor);
allResults.add(lastResult);
} while (lastResult.getSeverity() == IStatus.ERROR && lastResult.getCode() == IArtifactRepository.CODE_RETRY && counter++ < MAX_RETRY_REQUEST);
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java
index e99b808..99c9080 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java
@@ -76,7 +76,7 @@ public class SignatureVerifier extends ProcessingStep {
try {
signedContent = verifierFactory.getSignedContent(inputFile);
} catch (GeneralSecurityException e) {
- return new Status(IStatus.ERROR, Activator.ID, Messages.SignatureVerification_failedRead + inputFile, e);
+ return new Status(IStatus.ERROR, Activator.ID, MirrorRequest.ARTIFACT_PROCESSING_ERROR, Messages.SignatureVerification_failedRead + inputFile, e);
}
ArrayList<IStatus> allStatus = new ArrayList<IStatus>(0);
SignedContentEntry[] entries = signedContent.getSignedEntries();
@@ -84,7 +84,7 @@ public class SignatureVerifier extends ProcessingStep {
try {
entries[i].verify();
} catch (InvalidContentException e) {
- allStatus.add(new Status(IStatus.ERROR, Activator.ID, Messages.SignatureVerification_invalidContent + entries[i].getName(), e));
+ allStatus.add(new Status(IStatus.ERROR, Activator.ID, MirrorRequest.ARTIFACT_PROCESSING_ERROR, Messages.SignatureVerification_invalidContent + entries[i].getName(), e));
} catch (OutOfMemoryError e) {
allStatus.add(new Status(IStatus.ERROR, Activator.ID, Messages.SignatureVerifier_OutOfMemory, e));
break;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 4c0777d..1f03639 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -592,7 +592,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
// if the original download went reasonably but the reportStatus found some issues
// (e..g, in the processing steps/validators) then mark the mirror as bad and return
// a retry code (assuming we have more mirrors)
- if ((status.isOK() || status.matches(IStatus.INFO | IStatus.WARNING)) && result.getSeverity() == IStatus.ERROR) {
+ if ((status.isOK() || status.matches(IStatus.INFO | IStatus.WARNING)) && result.getSeverity() == IStatus.ERROR && !artifactError(result)) {
if (mirrors != null) {
mirrors.reportResult(mirrorLocation.toString(), result);
if (mirrors.hasValidMirror())
@@ -604,6 +604,23 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
/**
+ * Return true if there is an 'artifact error'. You cannot retry when an artifact error is found.
+ * @return True if the status (or children status) have an artifact error status code. False otherwise
+ */
+ private boolean artifactError(IStatus status) {
+ if (status.getCode() == MirrorRequest.ARTIFACT_PROCESSING_ERROR)
+ return true;
+ if (status.getChildren() != null) {
+ IStatus[] children = status.getChildren();
+ for (IStatus child : children) {
+ if (artifactError(child))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Copy a file to an output stream.
* Optionally close the streams when done.
* Notify the monitor about progress we make