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

Avoid null type, derive from provider type params or fallback to Object. #6820

Merged
merged 1 commit into from Dec 14, 2023

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Dec 8, 2023

This fixes a potential NPE thrown in some situations:

Cannot invoke "java.lang.Class.getModifiers()" because "clazz" is null
Error stack trace: org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.findNonDecoratedClass(NbProjectInfoBuilder.java:943)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.inspectObjectAndValues0(NbProjectInfoBuilder.java:746)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.inspectObjectAndValues(NbProjectInfoBuilder.java:597)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.startInspectObjectAndValues(NbProjectInfoBuilder.java:563)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.detectTaskProperties(NbProjectInfoBuilder.java:320)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.lambda$runAndRegisterPerf$7(NbProjectInfoBuilder.java:427)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.runAndRegisterPerf(NbProjectInfoBuilder.java:433)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.runAndRegisterPerf(NbProjectInfoBuilder.java:427)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.lambda$buildAll$3(NbProjectInfoBuilder.java:248)
org.netbeans.modules.gradle.tooling.NbProjectInfoBuilder.sinceGradle(NbProjectInfoBuilder.java:1850)

With micronaut-core, null is sometimes returned by the provider as a value, and the (Provider) type in t is overwritten by null and subsequently fails in findNonDecoratedClass. Even when getFixedValue()returns != null, the provider'sgetType()sometimes returnsnull` as a type - added a fallback to actual value's Class.

Lastly, if it is not possible to determien type from either a concrete value, or the provider's type parameter, the introspection falls back to Object.class.

@sdedic sdedic added Gradle [ci] enable "build tools" tests VSCode Extension [ci] enable VSCode Extension tests labels Dec 8, 2023
@sdedic sdedic added this to the NB21 milestone Dec 8, 2023
@sdedic sdedic self-assigned this Dec 8, 2023
@sdedic sdedic marked this pull request as ready for review December 8, 2023 18:50
@sdedic
Copy link
Member Author

sdedic commented Dec 11, 2023

If no objections are raised, will merge later today.

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really an expert here, but makes sense to me.

@sdedic sdedic merged commit c9ae5f8 into apache:master Dec 14, 2023
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gradle [ci] enable "build tools" tests VSCode Extension [ci] enable VSCode Extension tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants