Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 577929 - NPE in org.eclipse.pde.internal.core.TargetWeaver.findRunningPlatformBundle(TargetWeaver.java:213)
Summary: NPE in org.eclipse.pde.internal.core.TargetWeaver.findRunningPlatformBundle(T...
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.22   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.23 M1   Edit
Assignee: Christoph Laeubrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-21 10:55 EST by Lars Vogel CLA
Modified: 2021-12-21 11:22 EST (History)
3 users (show)

See Also:


Attachments
Screenshot (27.53 KB, image/png)
2021-12-21 10:55 EST, Lars Vogel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2021-12-21 10:55:01 EST
Created attachment 287716 [details]
Screenshot

If you include a bundle into your runtime Eclipse which contains a platform filter not matching your platform you get an NPE in your runtime Eclipse.

I have not seen this NPE in earlier releases.

To test:

1.) Create plug-in with a platform filter not matching your platform and start ar runtime Eclipse into an empty workspace (see screenshot)
2.) Create a new plug-in in your runtime Eclipse


!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
	at java.base/java.util.Arrays.stream(Arrays.java:5645)
	at org.eclipse.pde.internal.core.TargetWeaver.findRunningPlatformBundle(TargetWeaver.java:213)
	at org.eclipse.pde.internal.core.TargetWeaver.isBundleOfRunningPlatform(TargetWeaver.java:195)
	at org.eclipse.pde.internal.core.TargetWeaver.getDevProperty(TargetWeaver.java:191)
	at org.eclipse.pde.internal.core.TargetWeaver.weaveManifest(TargetWeaver.java:114)
	at org.eclipse.pde.internal.core.MinimalState.addBundle(MinimalState.java:201)
	at org.eclipse.pde.internal.core.MinimalState.addBundle(MinimalState.java:195)
	at org.eclipse.pde.internal.core.PDEState.createNewTargetState(PDEState.java:166)
	at org.eclipse.pde.internal.core.PDEState.<init>(PDEState.java:61)
	at org.eclipse.pde.internal.core.PluginModelManager.initializeTable(PluginModelManager.java:602)
	at org.eclipse.pde.internal.core.PluginModelManager.targetReloaded(PluginModelManager.java:522)
	at org.eclipse.pde.internal.ui.wizards.plugin.NewPluginProjectWizard.lambda$0(NewPluginProjectWizard.java:117)
	at org.eclipse.pde.internal.ui.wizards.plugin.NewPluginProjectWizard$$Lambda$899/0x0000000000000000.run(Unknown Source)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Comment 1 Lars Vogel CLA 2021-12-21 10:58:27 EST
Hannes and Christoph, did we change something in this area? I don't think we had this NPE earlier and IIRC you were the only people changing target platform handling in this release.
Comment 2 Christoph Laeubrich CLA 2021-12-21 11:00:22 EST
Hannes has added this code and I think a simple null check is required here as the method clearly states that null is a valid return value.
Comment 3 Eclipse Genie CLA 2021-12-21 11:02:24 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189056
Comment 4 Eclipse Genie CLA 2021-12-21 11:04:37 EST
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189057
Comment 5 Hannes Wellmann CLA 2021-12-21 11:12:04 EST
(In reply to Lars Vogel from comment #1)
> Hannes and Christoph, did we change something in this area? I don't think we
> had this NPE earlier and IIRC you were the only people changing target
> platform handling in this release.

Yes that right, I changed TargetWeaver.

From your stacktrace I assume the problem is that in TargetWeaver.findRunningPlatformBundle()
the call Platform.getBundles(symbolicName, null) returns null in your case but Arrays.stream() does not permit null arguments.

A simple null check probably does the job, I have forgot that.

Looks like you were to fast for me and found the answer already while I was typing my comment.
Comment 6 Lars Vogel CLA 2021-12-21 11:22:48 EST
Thanks, Christoph and Hannes.