From b26ae58972e96118b4f9e4496438fc218e5ab2d0 Mon Sep 17 00:00:00 2001 From: Ian Bull Date: Fri, 27 Apr 2012 14:40:20 -0700 Subject: Bug 377976 : Don't continually try to download bad artifacts. 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--- .../p2/artifact/repository/MirrorRequest.java | 9 +++++++++ .../p2/artifact/repository/SignatureVerifier.java | 4 ++-- .../repository/simple/SimpleArtifactRepository.java | 19 ++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository') 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 20da9aee9..ab2683573 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 @@ -37,6 +37,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 */ @@ -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 e99b808bb..99c9080ac 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 allStatus = new ArrayList(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 4c0777d14..1f036394b 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()) @@ -603,6 +603,23 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme return status.getCode() == CODE_RETRY ? status : result; } + /** + * 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. -- cgit v1.2.3