Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent NPE when no artifact repository is given #524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
Loading