Skip to content

DataLoader/BatchLoader causing unexpected NPEs #197

Open
@iuliiasobolevska

Description

@iuliiasobolevska

Describe the bug

Hi Folks,

The 3060a30 commit added JSpecify's @NonNull annotation on the load method key argument but missed adding it on some methods that call the annotated ones, e.g.

    public CompletableFuture<V> load(K key) {
        return load(key, null);
    }

https://github.com/graphql-java/java-dataloader/blame/master/src/main/java/org/dataloader/DataLoader.java#L172-L174

As a result, IntelliJ IDE doesn't provide any hinting on passing a nullable argument to the dataLoader.load(key) method.

Additional context: Some applications got caught by surprise since they picked up OSS Spring Boot 3.5 via automated dependency updates, which upgraded spring-graphql and, as a result, java-dataloader. Thanks to adding JSpecify nullity annotations, these old bugs are getting surfaced, but, unfortunately, this happens at runtime, and the tooling (e.g. IntelliJ IDE) doesn't help much. In one case, the key was derived from a several chained calls pulling data from the DgsDataFetchingEnvironment.

Overall, org.dataloader.DataLoader only has one method that takes key annotated as @NonNull. While it's self-explanatory that null should be passed in all others, it would still be great to explicitly annotate all of them to make it easier to identify and catch issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions