quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.54k stars 2.61k forks source link

Potential NPE thrown from QuarkusClassLoader.getResources #40438

Closed jamesnetherton closed 4 months ago

jamesnetherton commented 4 months ago

Describe the bug

There's an issue observed on the Camel Quarkus nightly build with Quarkus 999-SNAPSHOT.

The following change:

https://github.com/quarkusio/quarkus/commit/9daa467417b84c812ee04da5d909c79d5a729580

Causes the camel-quarkus-kotlin-dsl tests to fail:

Caused by: java.lang.NullPointerException
    at java.base/java.util.Objects.requireNonNull(Objects.java:233)
    at java.base/java.util.ImmutableCollections$List12.<init>(ImmutableCollections.java:563)
    at java.base/java.util.List.of(List.java:937)
    at io.quarkus.bootstrap.classloading.ClassPathElement.getResources(ClassPathElement.java:147)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.getResources(QuarkusClassLoader.java:270)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.getResources(QuarkusClassLoader.java:210)
    at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt.rawClassPathFromKeyResourcePath(jvmClasspathUtil.kt:139)
    at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt.classPathFromTypicalResourceUrls(jvmClasspathUtil.kt:152)
    at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt$classpathFromClassloader$1.invoke(jvmClasspathUtil.kt:96)
    at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt$classpathFromClassloader$1.invoke(jvmClasspathUtil.kt:77)

Seems that MemoryClassPathElement uses the default impl of ClassPathElement.getResources. If getResource(name) returns null, then it causes an NPE because it's passed into List.of().

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

  1. Clone the camel-quarkus project
  2. git checkout quarkus-main
  3. mvn clean install -Dquickly -T1C
  4. cd integration-tests/kotlin-dsl
  5. mvn clean test

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

999-SNAPSHOT

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

quarkus-bot[bot] commented 4 months ago

/cc @geoand (kotlin)

geoand commented 4 months ago

cc @stuartwdouglas

dmlloyd commented 4 months ago

I can take this one.

geoand commented 4 months ago

👌