eclipse-equinox / p2

Eclipse Public License 2.0
14 stars 40 forks source link

Nullpointer in AbstractRepositoryManager#handleRemoteIndexFile #476

Closed laeubi closed 6 months ago

laeubi commented 6 months ago

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)
laeubi commented 6 months ago

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.

github-actions[bot] commented 6 months ago

Test Results

    6 files   -     3      6 suites   - 3   20m 34s :stopwatch: - 10m 49s 2 183 tests ±    0  2 179 :white_check_mark: ±    0  4 :zzz: ±0  0 :x: ±0  4 424 runs   - 2 215  4 417 :white_check_mark:  - 2 211  7 :zzz:  - 4  0 :x: ±0 

Results for commit 3dac813e. ± Comparison against base commit 151d95ba.