Skip to content

Commit

Permalink
Ignore the UnsupportedOperationException in case of descriptor removal
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laeubi committed Feb 20, 2024
1 parent 57ecc5a commit 151d95b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 151d95b

Please sign in to comment.