Skip to content

Commit

Permalink
Prevent NPE when no artifact repository is given
Browse files Browse the repository at this point in the history
Currently RawMirrorRequest can fail if no repository is given in the
descriptor and it want to log a message.

P2 should be gracefully in this case and simply report the location as
being unknown.
  • Loading branch information
laeubi committed Jun 16, 2024
1 parent 5c5045c commit 723c7ff
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.artifact.repository;singleton:=true
Bundle-Version: 1.5.400.qualifier
Bundle-Version: 1.5.500.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.artifact.repository.Activator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.eclipse.equinox.internal.p2.artifact.repository;

import java.io.OutputStream;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.core.runtime.*;
Expand Down Expand Up @@ -95,7 +96,7 @@ protected IStatus getArtifact(IArtifactDescriptor artifactDescriptor, OutputStre
if (steps.isEmpty()) {
LogHelper.log(new Status(IStatus.WARNING, Activator.ID,
NLS.bind(Messages.noDigestAlgorithmToVerifyDownload, artifactDescriptor.getArtifactKey(),
artifactDescriptor.getRepository().getLocation())));
getLocation(artifactDescriptor))));
}
ProcessingStep[] stepArray = steps.toArray(new ProcessingStep[steps.size()]);
// TODO should probably be using createAndLink here
Expand All @@ -105,4 +106,16 @@ protected IStatus getArtifact(IArtifactDescriptor artifactDescriptor, OutputStre
subMon.setWorkRemaining(1);
return getSourceRepository().getRawArtifact(artifactDescriptor, destination, subMon.split(1));
}

private String getLocation(IArtifactDescriptor artifactDescriptor) {
IArtifactRepository repository = artifactDescriptor.getRepository();
if (repository == null) {
return "<unkown repository>"; //$NON-NLS-1$
}
URI loc = repository.getLocation();
if (loc == null) {
return "<unkown location>"; //$NON-NLS-1$
}
return loc.toASCIIString();
}
}
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.core.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.core.feature"
label="%featureName"
version="1.7.200.qualifier"
version="1.7.300.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.extras.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.extras.feature"
label="%featureName"
version="1.4.2400.qualifier"
version="1.4.2500.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.server.p2/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.server.p2"
label="%featureName"
version="1.12.1300.qualifier"
version="1.12.1400.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down

0 comments on commit 723c7ff

Please sign in to comment.