Bug 577741 - NullPointerException running search
Summary: NullPointerException running search
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Search (show other bugs)
Version: 4.22   Edit
Hardware: PC Windows 10
: P3 critical (vote)
Target Milestone: 4.23 M1   Edit
Assignee: Jörg Kubitz CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
: 577897 578374 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-12-10 06:14 EST by Alain Picard CLA
Modified: 2022-03-18 14:16 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alain Picard CLA 2021-12-10 06:14:42 EST
Just updated to new 2021-12 and getting NPE trying to run search

Stacktrace:
java.lang.NullPointerException
	at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469)
	at java.base/java.util.Comparators$NullComparator.compare(Comparators.java:83)
	at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
	at java.base/java.util.TimSort.sort(TimSort.java:234)
	at java.base/java.util.Arrays.sort(Arrays.java:1515)
	at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:353)
	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at org.eclipse.search.internal.core.text.TextSearchVisitor.search(TextSearchVisitor.java:417)
	at org.eclipse.search.internal.core.text.TextSearchVisitor.search(TextSearchVisitor.java:450)
	at org.eclipse.search.core.text.TextSearchEngine$1.search(TextSearchEngine.java:60)
	at org.eclipse.search.internal.ui.text.FileSearchQuery.run(FileSearchQuery.java:236)
	at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:94)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Session Data:
eclipse.buildId=4.22.0.I20211124-1800
java.version=11.0.5
java.vendor=AdoptOpenJDK
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.modeling.product -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.modeling.product -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.modeling.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.modeling.product -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.modeling.product -data C:\eclipse\baws2003 -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.modeling.product


Search for: endPoint, case sensitive in workspace, patterns: *.css, *.e4xmi, *.ecore, *.exsd, *.genmodel, *.java, *.js, *.odesign, *.product, *.properties, *.view, *.xml, *.zul, MANIFEST.MF

Note that changing the pattern to only *.java runs w/o error.
Comment 1 Alain Picard CLA 2021-12-10 06:38:21 EST
I tried with various combination of pattern, and of those listed, the following are failing (others are not):
- * (obviously)
- MANIFEST.MF
- *.xml
Comment 2 Andrey Loskutov CLA 2021-12-10 06:48:46 EST
Regression from bug 575893 changes.
Jörg, please take a look.
Comment 4 Jörg Kubitz CLA 2021-12-10 07:03:07 EST
hmm, i was not able to reproduce it.
And at a first look i do not see the error in the sourcecode.
@Alain, could you please upload a simple Project where the error occurs so that i could debug?
Comment 5 Eclipse Genie CLA 2021-12-10 07:11:20 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/188739
Comment 6 Alain Picard CLA 2021-12-10 08:10:33 EST
(In reply to Jörg Kubitz from comment #4)
> hmm, i was not able to reproduce it.
> And at a first look i do not see the error in the sourcecode.
> @Alain, could you please upload a simple Project where the error occurs so
> that i could debug?

Jörg, I have a workspace with a few hundred projects, and I have no idea from the reported error where it comes from. How can I narrow it down more than the types I have reported, then will gladly try to get you a reproducible case.
Comment 7 Jörg Kubitz CLA 2021-12-10 08:34:10 EST
@Alain
can you start eclipse with a jdk 17 please to get a rich NPE message? Maybe that helps
Comment 8 Alain Picard CLA 2021-12-10 11:55:26 EST
(In reply to Jörg Kubitz from comment #7)
> @Alain
> can you start eclipse with a jdk 17 please to get a rich NPE message? Maybe
> that helps

Here is the new stacktrace with Java 17

java.lang.NullPointerException: Cannot invoke "java.lang.Comparable.compareTo(Object)" because the return value of "java.util.function.Function.apply(Object)" is null
	at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:473)
	at java.base/java.util.Comparators$NullComparator.compare(Comparators.java:85)
	at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
	at java.base/java.util.TimSort.sort(TimSort.java:234)
	at java.base/java.util.Arrays.sort(Arrays.java:1307)
	at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:353)
	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
	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.eclipse.search.internal.core.text.TextSearchVisitor.search(TextSearchVisitor.java:417)
	at org.eclipse.search.internal.core.text.TextSearchVisitor.search(TextSearchVisitor.java:450)
	at org.eclipse.search.core.text.TextSearchEngine$1.search(TextSearchEngine.java:60)
	at org.eclipse.search.internal.ui.text.FileSearchQuery.run(FileSearchQuery.java:236)
	at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:94)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Comment 9 Jörg Kubitz CLA 2021-12-13 04:21:48 EST
(In reply to Alain Picard from comment #8)
> Here is the new stacktrace with Java 17
> 
> java.lang.NullPointerException: Cannot invoke
> "java.lang.Comparable.compareTo(Object)" because the return value of
> "java.util.function.Function.apply(Object)" is null

thanks. that makes it a little more clear.
Comment 10 Alain Picard CLA 2021-12-13 13:45:31 EST
(In reply to Jörg Kubitz from comment #9)
> (In reply to Alain Picard from comment #8)
> > Here is the new stacktrace with Java 17
> > 
> > java.lang.NullPointerException: Cannot invoke
> > "java.lang.Comparable.compareTo(Object)" because the return value of
> > "java.util.function.Function.apply(Object)" is null
> 
> thanks. that makes it a little more clear.

Got another variation this time:
java.lang.NullPointerException: Cannot read field "value" because "anotherString" is null
	at java.base/java.lang.String.compareTo(String.java:2012)
	at java.base/java.lang.String.compareTo(String.java:140)
	at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:473)
	at java.base/java.util.Comparators$NullComparator.compare(Comparators.java:85)
	at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
	at java.base/java.util.TimSort.sort(TimSort.java:234)
	at java.base/java.util.Arrays.sort(Arrays.java:1307)
	at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:353)
	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
	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.eclipse.search.internal.core.text.TextSearchVisitor.search(TextSearchVisitor.java:417)
	at org.eclipse.search.internal.core.text.TextSearchVisitor.search(TextSearchVisitor.java:450)
	at org.eclipse.search.core.text.TextSearchEngine$1.search(TextSearchEngine.java:60)
	at org.eclipse.search.internal.ui.text.FileSearchQuery.run(FileSearchQuery.java:236)
	at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:94)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Comment 12 Jonah Graham CLA 2022-01-27 10:10:21 EST
*** Bug 578374 has been marked as a duplicate of this bug. ***
Comment 13 Jonah Graham CLA 2022-01-27 10:16:13 EST
Hi Jörg - did you ever find out the condition that exposes this bug? I was wondering if some use cases (e.g. remote dev?) make it more likely to be hit.
Comment 14 Jörg Kubitz CLA 2022-01-27 10:52:47 EST
(In reply to Jonah Graham from comment #13)
> Hi Jörg - did you ever find out the condition that exposes this bug? I was
> wondering if some use cases (e.g. remote dev?) make it more likely to be hit.

There must be an IFile with org.eclipse.core.resources.IResource.getLocation()==null.  I do not know when that actually happens. With normal files it does not.

The javadoc says:
"If this resource is a project that does not exist in the workspace,
or a file or folder below such a project, this method returns
<code>null</code>.  This method also returns <code>null</code> if called
on a resource that is not stored in the local file system."


more intersting:  For such resources {@link #getLocationURI()} should be used instead.

May be the results for such files are not deterministically ordered at the moment.
Comment 15 Jonah Graham CLA 2022-01-27 11:27:22 EST
(In reply to Jörg Kubitz from comment #14)

Thanks for that.

> May be the results for such files are not deterministically ordered at the
> moment.

I would guess so.
Comment 16 Sebastian Zarnekow CLA 2022-03-18 14:16:06 EDT
*** Bug 577897 has been marked as a duplicate of this bug. ***