Skip to content

Commit

Permalink
MirrorRequest: catch UnsupportedOperationException #252
Browse files Browse the repository at this point in the history
and resolve deprecated call

#252
  • Loading branch information
EcljpseB0T committed Feb 15, 2024
1 parent e84b5a0 commit bb78b65
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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())
Expand Down

0 comments on commit bb78b65

Please sign in to comment.