From 57ecc5a05ba4420f4983be2c27832fe139ab5d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Thu, 15 Feb 2024 17:13:58 +0100 Subject: [PATCH] MirrorRequest: catch UnsupportedOperationException #252 and resolve deprecated call https://github.com/eclipse-equinox/p2/issues/252 --- .../p2/artifact/repository/MirrorRequest.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 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 2f066f1b42..ff785229ff 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 @@ -121,7 +121,8 @@ protected void setSourceRepository(IArtifactRepository value) { @Override public void perform(IArtifactRepository sourceRepository, IProgressMonitor monitor) { - monitor.subTask(NLS.bind(Messages.downloading, getArtifactKey().getId())); + SubMonitor subMonitor = SubMonitor.convert(monitor, NLS.bind(Messages.downloading, getArtifactKey().getId()), + 3); setSourceRepository(sourceRepository); // Do we already have the artifact in the target? if (target.contains(getArtifactKey())) { @@ -160,13 +161,13 @@ else if (ProcessingStepHandler.canProcess(descriptor2)) } IArtifactDescriptor destinationDescriptor = getDestinationDescriptor(descriptor, descriptor == canonical); - IStatus status = transfer(destinationDescriptor, descriptor, monitor); + IStatus status = transfer(destinationDescriptor, descriptor, subMonitor.split(1)); // if ok, cancelled or transfer has already been done with the canonical form return with status set if (status.getSeverity() == IStatus.CANCEL) { setResult(status); return; } - if (monitor.isCanceled()) { + if (subMonitor.isCanceled()) { setResult(Status.CANCEL_STATUS); return; } @@ -176,15 +177,21 @@ else if (ProcessingStepHandler.canProcess(descriptor2)) } // failed, first remove possibly erroneously added descriptor - if (target.contains(destinationDescriptor)) - target.removeDescriptor(destinationDescriptor); + 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; + } + } if (descriptor == canonical || canonical == null) { setResult(status); return; } - IStatus canonicalStatus = transfer(getDestinationDescriptor(canonical, true), canonical, monitor); + IStatus canonicalStatus = transfer(getDestinationDescriptor(canonical, true), canonical, subMonitor.split(1)); // To prevent the optimized transfer status severity from dominating the canonical, only merge // if the canonical severity is equal to or higher than the optimized transfer severity. if (canonicalStatus.getSeverity() < status.getSeverity())