eclipse / lsp4mp

Technology lsp4mp
Eclipse Public License 2.0
22 stars 27 forks source link

NPEs in TestJaxRsInfoProvider.canProvideJaxRsMethodInfoForClass #424

Closed fbricon closed 1 year ago

fbricon commented 1 year ago

When running Quarkus LS builds, that depend on this class, we're seeing hundreds of NPEs logged because this code doesn't check if fruitResourceType is null https://github.com/eclipse/lsp4mp/blob/9642f6a45d2c20473b324e4f11dd3f5df1789d79/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/jaxrs/TestJaxRsInfoProvider.java#L52

Sep 22, 2023 9:45:10 AM org.eclipse.lsp4mp.jdt.internal.core.java.JaxRsInfoDefinition canProvideJaxRsMethodInfoForClass
SEVERE: Unable to get JAX-RS info provider
java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.core.IType.getTypeRoot()" because "fruitResourceType" is null
    at org.eclipse.lsp4mp.jdt.core.jaxrs.TestJaxRsInfoProvider.canProvideJaxRsMethodInfoForClass(TestJaxRsInfoProvider.java:52)
    at org.eclipse.lsp4mp.jdt.internal.core.java.JaxRsInfoDefinition.canProvideJaxRsMethodInfoForClass(JaxRsInfoDefinition.java:45)
    at org.eclipse.lsp4mp.jdt.internal.jaxrs.java.JaxRsCodeLensParticipant.getProviderForType(JaxRsCodeLensParticipant.java:129)
    at org.eclipse.lsp4mp.jdt.internal.jaxrs.java.JaxRsCodeLensParticipant.isAdaptedForCodeLens(JaxRsCodeLensParticipant.java:70)
    at org.eclipse.lsp4mp.jdt.internal.core.java.codelens.JavaCodeLensDefinition.isAdaptedForCodeLens(JavaCodeLensDefinition.java:43)
    at org.eclipse.lsp4mp.jdt.core.PropertiesManagerForJava.lambda$0(PropertiesManagerForJava.java:188)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    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.eclipse.lsp4mp.jdt.core.PropertiesManagerForJava.collectCodeLens(PropertiesManagerForJava.java:189)
    at org.eclipse.lsp4mp.jdt.core.PropertiesManagerForJava.codeLens(PropertiesManagerForJava.java:176)
    at org.eclipse.lsp4mp.jdt.core.MicroProfileForJavaAssert.assertCodeLens(MicroProfileForJavaAssert.java:409)
    at com.redhat.microprofile.jdt.quarkus.jaxrs.JaxRsCodeLensTest.assertCodeLenses(JaxRsCodeLensTest.java:139)
sbouchet commented 1 year ago

@fbricon @angelozerr : one other way might be to stop throwing Exception in tests, because it swallow any potential NPE and makes the test not fail.