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

NPE in Branding Panel for maven project #4084

Closed
ebarboni opened this issue May 6, 2022 · 9 comments
Closed

NPE in Branding Panel for maven project #4084

ebarboni opened this issue May 6, 2022 · 9 comments
Labels
kind:bug Bug report or fix Platform [ci] enable platform tests (platform/*)
Milestone

Comments

@ebarboni
Copy link
Contributor

ebarboni commented May 6, 2022

Apache NetBeans version

Apache NetBeans latest daily build

What happened

I was trying to use branding in Maven NetBeans platform on NetBeans 14 rc3

On branding artetfact right click on branding
Should open a branding panel but a NPE happens

java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:208)
	at java.base/java.util.TreeMap.merge(TreeMap.java:708)
	at java.base/java.util.stream.Collectors.lambda$toMap$68(Collectors.java:1673)
	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.base/java.util.stream.IntPipeline$1$1.accept(IntPipeline.java:180)
	at java.base/java.util.Spliterators$IntArraySpliterator.forEachRemaining(Spliterators.java:1076)
	at java.base/java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:711)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at org.netbeans.modules.apisupport.project.ui.branding.BasicBrandingPanel.<init>(BasicBrandingPanel.java:62)
	at org.netbeans.modules.apisupport.project.ui.branding.BrandingEditorPanel.<init>(BrandingEditorPanel.java:51)
	at org.netbeans.modules.apisupport.project.api.BrandingUtils.openBrandingEditor(BrandingUtils.java:56)
	at org.netbeans.modules.maven.apisupport.OpenBrandingEditorAction$1$1.run(OpenBrandingEditorAction.java:104)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
[catch] at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

How to reproduce

To generate a example:
File -> new project
Java with Maven -> NetBeans Applications
Select RELEASE130 for version

wait until project created the select the branding artefact. Right click on it and click on branding.

Did this work correctly in an earlier version?

No

Operating System

Windows 11

JDK

jdk 17

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

It was a long time I didn't use the branding. I'm not sure how old the issue is.
I'm not sure I can propose a PR for this having issue to understand the intention of the stream and map collectors.

Are you willing to submit a pull request?

No

Code of Conduct

Yes

@ebarboni ebarboni added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels May 6, 2022
@ebarboni ebarboni added this to the NB14 milestone May 6, 2022
@GuyDaniel
Copy link

I just tried to replicate this bug on Linux with 14rc3 and oracle jdk 17, and got the branding panel ok, after a notification that some netbeans dependencies were downloading.
Works ok for me.

@ebarboni ebarboni changed the title NPE NPE in Branding Panel for maven project May 9, 2022
@ebarboni
Copy link
Contributor Author

thanks for trying on linux maybe an issue with windows.

@vieiro
Copy link
Contributor

vieiro commented May 10, 2022

Verified: this happens on Windows, on a brand new Maven/NetBeans installation.

I get this exception...

WARNING [null]: Last record repeated 3 more times.
INFO [org.netbeans.ui.indexing]: Indexing started, time from last indexing 5.131 ms.
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.netbeans.modules.maven.apisupport.OpenBrandingEditorAction$1
java.lang.NullPointerException
	at org.netbeans.modules.maven.apisupport.OpenBrandingEditorAction$1.run(OpenBrandingEditorAction.java:91)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

... but once all Maven artifacts are downloaded (and after one minute or so?), and with this exception in between:

SCAN_EXCEEDS_RATE ID: 61, Type:PATH
Time scheduled: Tue May 10 15:42:17 CEST 2022
Time executed: Tue May 10 15:42:17 CEST 2022
Time finished: Tue May 10 15:42:17 CEST 2022
Scanned roots: []
, total time: 0
Current root(s): []
Current indexer(s): 
Time spent in indexers:
Time spent in indexers, in individual roots:
Time in index store: 0
Time crawling: 0
Stacktrace:
	java.base/java.lang.Thread.getStackTrace(Thread.java:1602)
	org.netbeans.modules.parsing.impl.indexing.LogContext.create(LogContext.java:111)
	org.netbeans.modules.parsing.impl.indexing.LogContext.create(LogContext.java:102)
	org.netbeans.modules.parsing.impl.indexing.PathRegistry.scheduleFirer(PathRegistry.java:936)
	org.netbeans.modules.parsing.impl.indexing.PathRegistry.resetCacheAndFire(PathRegistry.java:929)
	org.netbeans.modules.parsing.impl.indexing.PathRegistry.access$500(PathRegistry.java:68)
	org.netbeans.modules.parsing.impl.indexing.PathRegistry$Listener.stateChanged(PathRegistry.java:1265)
	org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:108)
	org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:94)
	org.netbeans.api.java.queries.SourceForBinaryQuery$Result2$1.stateChanged(SourceForBinaryQuery.java:182)
	org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:331)
	org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:108)
	org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:94)
	org.netbeans.modules.maven.queries.RepositoryForBinaryQueryImpl$SrcResult.checkChanges(RepositoryForBinaryQueryImpl.java:411)
	org.netbeans.modules.maven.queries.RepositoryForBinaryQueryImpl$SrcResult.access$300(RepositoryForBinaryQueryImpl.java:288)
	org.netbeans.modules.maven.queries.RepositoryForBinaryQueryImpl$SrcResult$1.run(RepositoryForBinaryQueryImpl.java:328)
	org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
	org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
	org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
SCAN_EXCEEDS_RATE ID: 62, Type:PATH
Time scheduled: Tue May 10 15:42:18 CEST 2022
Time executed: Tue May 10 15:42:19 CEST 2022
Time finished: Tue May 10 15:42:19 CEST 2022
Scanned roots: []
, total time: 0
Current root(s): []
Current indexer(s): 
Time spent in indexers:
Time spent in indexers, in individual roots:
Time in index store: 0
Time crawling: 0
Stacktrace:
	java.base/java.lang.Thread.getStackTrace(Thread.java:1602)
	org.netbeans.modules.parsing.impl.indexing.LogContext.create(LogContext.java:111)
	org.netbeans.modules.parsing.impl.indexing.LogContext.create(LogContext.java:102)
	org.netbeans.modules.parsing.impl.indexing.PathRegistry.scheduleFirer(PathRegistry.java:936)
	org.netbeans.modules.parsing.impl.indexing.PathRegistry.resetCacheAndFire(PathRegistry.java:929)
	org.netbeans.modules.parsing.impl.indexing.PathRegistry.access$500(PathRegistry.java:68)
	org.netbeans.modules.parsing.impl.indexing.PathRegistry$Listener.stateChanged(PathRegistry.java:1265)
	org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:108)
	org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:94)
	org.netbeans.api.java.queries.SourceForBinaryQuery$Result2$1.stateChanged(SourceForBinaryQuery.java:182)
	org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:331)
	org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:108)
	org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:94)
	org.netbeans.modules.maven.queries.RepositoryForBinaryQueryImpl$SrcResult.checkChanges(RepositoryForBinaryQueryImpl.java:411)
	org.netbeans.modules.maven.queries.RepositoryForBinaryQueryImpl$SrcResult.access$300(RepositoryForBinaryQueryImpl.java:288)
	org.netbeans.modules.maven.queries.RepositoryForBinaryQueryImpl$SrcResult$1.run(RepositoryForBinaryQueryImpl.java:328)
	org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
	org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
	org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
WARNING [org.netbeans.modules.parsing.impl.indexing.LogContext]: === End excessive indexing
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Resolving dependencies took: 27 ms
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Complete indexing of 0 binary roots took: 0 ms
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Complete indexing of 0 source roots took: 0 ms (New or modified files: 0, Deleted files: 0) [Adding listeners took: 0 ms]
INFO [org.netbeans.ui.indexing]: Indexing finished, indexing took 28 ms.

The branding panel does indeed open. After that opening the branding panel does open everytime normally, without delay.

imagen

@GuyDaniel
Copy link

thanks for trying on linux maybe an issue with windows.

Oh, I just realized I did a build of everything first, before testing the panel mainly out of habit.

@ebarboni ebarboni modified the milestones: NB14, NB15 May 11, 2022
@ebarboni
Copy link
Contributor Author

changing to NB15 as it's not reproductible

@pedro-w
Copy link
Contributor

pedro-w commented May 11, 2022

I had a quick look and it seems the exception traces back to

this.iconSources = IntStream.of(16, 32, 48, 256, 512, 1024).boxed()
.collect(toMap(size -> size, model::getIconSource,
(a, b) -> a, TreeMap::new));

which was added in #3551
I am not familiar with the code but it looks like BrandingModel::getIconSource could legitimately return null for some of the listed sizes, which will cause TreeMap's merge function to throw the NPE. (ref here)
So I think you need to implement this a bit differently to filter out any null icons that are returned by the branding model.

@ebarboni
Copy link
Contributor Author

maybe because I run NetBeans on jdk 17 ?

@pedro-w
Copy link
Contributor

pedro-w commented May 11, 2022

I think what I said before was right but maybe not the root cause. From reading #3544 (comment) it looks like the path <project>\branding\src\main\nbm-branding\core\core.jar\org\netbeans\core\startup should have some images in it, and it does not (only a Bundle.properties)

I also am using Windows 11 & JDK 17. I tried on Debian 11/JDK 11 and did not see the issue.

@mbien mbien added Platform [ci] enable platform tests (platform/*) and removed needs:triage Requires attention from one of the committers labels May 14, 2022
@ebarboni ebarboni closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2022
@ebarboni
Copy link
Contributor Author

closing as I cannot reproduce maybe incoherent artefact on my local repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix Platform [ci] enable platform tests (platform/*)
Projects
None yet
Development

No branches or pull requests

5 participants