Skip to content

Conversation

@mbien
Copy link
Member

@mbien mbien commented Oct 15, 2025

Would be good to refactor the utility to return non-null values in future, usages seem to treat empty list and null the same.

java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "org.netbeans.modules.java.hints.errors.CreateElementUtilities.resolveType(java.util.Set, org.netbeans.api.java.source.CompilationInfo, com.sun.source.util.TreePath, com.sun.source.tree.Tree, int, javax.lang.model.type.TypeMirror[], int[])" is null
	at org.netbeans.modules.java.hints.errors.CreateElementUtilities.computeLambdaReturn(CreateElementUtilities.java:566)
	at org.netbeans.modules.java.hints.errors.CreateElementUtilities.resolveType(CreateElementUtilities.java:216)
	at org.netbeans.modules.java.hints.errors.CreateElement.analyzeImpl(CreateElement.java:333)
	at org.netbeans.modules.java.hints.errors.CreateElement.analyze(CreateElement.java:131)
	at org.netbeans.modules.java.hints.errors.CreateElement.run(CreateElement.java:116)
	at org.netbeans.modules.java.hints.infrastructure.CreatorBasedLazyFixList.compute(CreatorBasedLazyFixList.java:128)
	at org.netbeans.modules.java.hints.infrastructure.LazyHintComputation.run(LazyHintComputation.java:87)
	at org.netbeans.modules.java.hints.infrastructure.LazyHintComputation.run(LazyHintComputation.java:33)
[catch] 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:1403)
	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:2018)

reproducer taken from a different/unrelated issue (#4668):

Details
package testapp;

import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    static String letterGrade(Student s) {
        int percent = 0; //s.getPercent();
        if (percent > 90)
            return "A";
        if (percent > 80)
            return "B";
        if (percent > 70)
            return "C";
        return "D";
    }

    public static void main(String[] args) {
        
        Stream.of(new Student(null, null))
                .collect(Collectors.groupingBy(s -> letterGrade(s), Collectors.mapping(s -> )))
    }

}

class Student {

    private String name;
    private int percent;

    public Student(String name, int percent) {
        this.name = name;
        this.percent = percent;
    }

}

@mbien mbien added this to the NB28 milestone Oct 15, 2025
@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Oct 15, 2025
@mbien mbien requested a review from lahodaj October 15, 2025 22:53
 - hotfix for regression
 - updated loop to log Exceptions and continue computing the remaining
   ErrorRules in the queue

Would be good to refactor the utility to return non-null values in
future, usages treat empty list and null the same.
@mbien mbien force-pushed the fix-npe-in-hint-utility_delivery branch from d1c565e to 7d6d9ac Compare October 16, 2025 01:48
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.

Looks good to me, thanks! (And sorry for the trouble.)

@ebarboni ebarboni merged commit fb18907 into apache:delivery Oct 17, 2025
69 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants