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

Nullpointer in AbstractRepositoryManager#handleRemoteIndexFile #476

Closed

Conversation

laeubi
Copy link
Member

@laeubi laeubi commented Feb 27, 2024

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.

@merks I don't know how this could happen but seen this in a log while performing an update operation, but the method itself also seems merely used (only found two references), so instead of running into a NPE this seems better and hopefully then reveals the real root cause later on.

The stacktrace is:

java.lang.NullPointerException: Cannot invoke "org.eclipse.equinox.internal.p2.repository.Transport.download(java.net.URI, java.io.OutputStream, org.eclipse.core.runtime.IProgressMonitor)" because the return value of "org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.getTransport()" is null
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.handleRemoteIndexFile(AbstractRepositoryManager.java:742)
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadIndexFile(AbstractRepositoryManager.java:736)
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:678)
        at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:110)
        at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:105)
        at org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob.doLoad(LoadMetadataRepositoryJob.java:126)
        at org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob.runModal(LoadMetadataRepositoryJob.java:110)

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.
@laeubi laeubi requested a review from merks February 27, 2024 11:57
@laeubi
Copy link
Member Author

laeubi commented Feb 27, 2024

It seems the issue is/was the ECF bundles where missing in my run config .... so I'm not sure if my fix still applies here but P2 could use a fallback service for Transports that simply uses URL.openStream even though this might not be very powerful its better than failing completely.

Copy link

Test Results

    6 files   -     3      6 suites   - 3   20m 34s ⏱️ - 10m 49s
2 183 tests ±    0  2 179 ✅ ±    0  4 💤 ±0  0 ❌ ±0 
4 424 runs   - 2 215  4 417 ✅  - 2 211  7 💤  - 4  0 ❌ ±0 

Results for commit 3dac813. ± Comparison against base commit 151d95b.

if (indexFileStatus != null && indexFileStatus.isOK())
return LocationProperties.create(new ByteArrayInputStream(index.toByteArray()));
} else {
try (InputStream openStream = indexFileURI.toURL().openStream()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My big concern here is that this masks a severe configuration problem. A problem likely to crop up elsewhere and a problem that, if not fixed will, will disable all kinds of functionality such as proxy support. Surely if one gets the index, something downstream will fail instead.

It would seem better to fail with some kind of message about the transport not being configured available and the like cause(s) for that.

@laeubi laeubi closed this Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants