From 10a5c9a8d012d6569a7e9621d02811e5cd526bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 18 Feb 2024 08:21:09 +0100 Subject: [PATCH] Ignore the UnsupportedOperationException in case of descriptor removal If removal of the errornous descriptor failed this can have different reasons: 1) it was never added because the target is not capable of downloading 2) the repository does not support removal of descriptors 3) some bug in the implementation in any case we want to report the original error an not an error that says we can't remove the descriptor. --- .../p2/artifact/repository/Messages.java | 2 ++ .../p2/artifact/repository/MirrorRequest.java | 17 ++++++++++++++--- .../p2/artifact/repository/messages.properties | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) 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 993ad714bf..30d4d941a4 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 @@ -57,6 +57,8 @@ public class Messages extends NLS { public static String MirrorLog_Exception_Occurred; public static String MirrorRequest_multipleDownloadProblems; + + public static String MirrorRequest_removal_failed; 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 ff785229ff..d84dfc5939 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 @@ -180,9 +180,20 @@ else if (ProcessingStepHandler.canProcess(descriptor2)) if (target.contains(destinationDescriptor)) { try { target.removeDescriptor(destinationDescriptor, subMonitor.split(1)); - } catch (UnsupportedOperationException e) { - setResult(Status.warning("unable to remove Descriptor", e)); //$NON-NLS-1$ - return; + } catch (RuntimeException e) { + // In case the repository does not support this, fall through to get the real + // error, maybe the repository does not support downloads at all! + Status warning = Status.warning(NLS.bind(Messages.MirrorRequest_removal_failed, destinationDescriptor), + e); + if (status instanceof MultiStatus multi) { + multi.add(warning); + } else { + MultiStatus multiStatus = new MultiStatus(Activator.ID, 0, + NLS.bind(Messages.MirrorRequest_transferFailed, descriptor), null); + multiStatus.add(status); + multiStatus.add(warning); + status = multiStatus; + } } } 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 6a2901ac78..ca6dcbfc9e 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 @@ -48,6 +48,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_removal_failed=Target repository contains descriptor after failed download but it can't be removed: {0} MirrorRequest_transferFailed=Failed to transfer artifact {0}. exception_unsupportedAddToComposite = Cannot add descriptors to a composite repository.