wrprice opened a new issue, #9728:
URL: https://github.com/apache/netbeans/issues/9728
### Apache NetBeans version
Apache NetBeans 31
### What happened
```stacktrace
java.lang.NullPointerException: Cannot invoke
"org.apache.lucene.index.Terms.iterator()" because the return value of
"org.apache.lucene.index.LeafReader.terms(String)" is null
at
org.netbeans.modules.parsing.lucene.LuceneIndex.queryTermsImpl(LuceneIndex.java:234)
at
org.netbeans.modules.parsing.lucene.LuceneIndex.queryTermFrequencies(LuceneIndex.java:204)
at
org.netbeans.modules.java.source.usages.PersistentClassIndex.lambda$getReferencesFrequences$5(PersistentClassIndex.java:388)
at
org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153)
at
org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:341)
at
org.netbeans.modules.parsing.lucene.support.IndexManager.priorityAccess(IndexManager.java:164)
at
org.netbeans.modules.java.source.usages.PersistentClassIndex.getReferencesFrequences(PersistentClassIndex.java:385)
at
org.netbeans.api.java.source.support.ReferencesCount.init(ReferencesCount.java:163)
at
org.netbeans.api.java.source.support.ReferencesCount.getTypeReferenceCount(ReferencesCount.java:80)
at
org.netbeans.modules.editor.java.Utilities.getImportanceLevel(Utilities.java:188)
at
org.netbeans.modules.editor.java.Utilities.getImportanceLevel(Utilities.java:184)
at
org.netbeans.modules.java.hints.errors.ImportClass.run(ImportClass.java:275)
[catch] at
org.netbeans.modules.java.hints.infrastructure.CreatorBasedLazyFixList.compute(CreatorBasedLazyFixList.java:133)
at
org.netbeans.modules.java.hints.infrastructure.LazyHintComputation.run(LazyHintComputation.java:87)
at
org.netbeans.modules.java.hints.infrastructure.LazyHintComputation.run(LazyHintComputation.java:33)
at
org.netbeans.modules.java.source.JavaSourceAccessor$CancelableTaskWrapper.run(JavaSourceAccessor.java:273)
at
org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:561)
at
org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:786)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
at
org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
at
org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
at
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:545)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:328)
at
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1370)
at
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1981)
```
### Language / Project Type / NetBeans Component
Gradle-based Java project
### How to reproduce
I suspect that the index is corrupted somehow. I can reproduce by opening
any Java file, ones that have no warnings/errors, and if I try to mess with
imports or, say, comment out an import in a previously valid Java file, then
the exception shows up in the Notifications pane. Occurs with any Java file,
not necessarily the one(s) I was working on when I first noticed the
notification.
### Did this work correctly in an earlier version?
Apache NetBeans 30
### Operating System
Fedora 44 on WSL2 6.18.54.1-microsoft-standard-WSL2
### JDK
OpenJDK Runtime Environment Temurin-25.0.4.1+1
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
I suspect it occurs whenever there's a symbol in the file that can't be
resolved and NB is trying to use the index to build potential import hints, but
this is just a suspicion based on visual observation. After this occurs, the
list of suggested hints only includes options to create the missing classes --
even if the required import is from jdk.base it's not listed as an option.
I'm unable to determine what caused the index to enter the suspected
corrupted state. This has happened a few weeks ago and I resolved it by blowing
away the index in my userdir, but it has come back. Probably during some times
where I was editing files in various states of validity -- i.e. missing
imports, methods missing required returns, probably mismatched braces / scoping
levels.
### Are you willing to submit a pull request?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists