Skip to content

Commit

Permalink
Nullpointer in AbstractRepositoryManager#handleRemoteIndexFile
Browse files Browse the repository at this point in the history
I found that in some rare cases the handleRemoteIndexFile could run into
a NPE if the Transport service can't be fetched.

This now checks first for null before using the transport and if it is
null fall back to simple URL stream, if that also fails, create an empty
index file.
  • Loading branch information
laeubi committed Feb 27, 2024
1 parent 151d95b commit 3dac813
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,21 @@ private LocationProperties loadIndexFile(URI location, IProgressMonitor monitor)
private LocationProperties handleRemoteIndexFile(URI indexFileURI, IProgressMonitor monitor) {
ByteArrayOutputStream index = new ByteArrayOutputStream();
IStatus indexFileStatus = null;
indexFileStatus = getTransport().download(indexFileURI, index, monitor);
while (indexFileStatus.getCode() == IArtifactRepository.CODE_RETRY) {
indexFileStatus = getTransport().download(indexFileURI, index, monitor);
Transport transport = getTransport();
if (transport != null) {
indexFileStatus = transport.download(indexFileURI, index, monitor);
while (indexFileStatus.getCode() == IArtifactRepository.CODE_RETRY) {
indexFileStatus = transport.download(indexFileURI, index, monitor);
}
if (indexFileStatus != null && indexFileStatus.isOK())
return LocationProperties.create(new ByteArrayInputStream(index.toByteArray()));
} else {
try (InputStream openStream = indexFileURI.toURL().openStream()) {
return LocationProperties.create(openStream);
} catch (IOException e) {
// nothing more to do here...
}
}
if (indexFileStatus != null && indexFileStatus.isOK())
return LocationProperties.create(new ByteArrayInputStream(index.toByteArray()));
return LocationProperties.createEmptyIndexFile();
}

Expand Down

0 comments on commit 3dac813

Please sign in to comment.