Giter Club home page Giter Club logo

lombokbuilderbug's Introduction

#Bug

The BuilderDemo is a simple demo for a bug hitting me when using @Builder annotation.

It appears (a NPE in ArrayList.addAll) when I use the toBuilder() method of an instance containing a null SINGULARIZED collection( or map).

Note : if I remove the @Singular annotation, the NPE is not thrown (see should_not_NPE_on_NOT_singularized_item_when_using_toBuilder_from_an_instance_created_with_a_null_collection)

Test stack trace :

java.lang.NullPointerException
    at java.util.ArrayList.addAll(ArrayList.java:577)
    at BuilderDemo$BuilderDemoBuilder.singularNames(BuilderDemo.java:51)
    at BuilderDemo.toBuilder(BuilderDemo.java:100)
    at BuilderDemoTest.should_not_NPE_on_singularized_item_when_using_toBuilder_from_an_instance_created_with_a_null_collection(BuilderDemoTest.java:21)

Generated source code (thx delombok plugin)

    @SuppressWarnings("all")
    @javax.annotation.Generated("lombok")
    public BuilderDemoBuilder singularNames(final java.util.Collection<? extends String> singularNames) {
        if (this.singularNames == null) this.singularNames = new java.util.ArrayList<String>();
        this.singularNames.addAll(singularNames);
        return this;
    }

the NPE is thrown at line this.singularNames.addAll(singularNames); : the singularNames parameter is null, and ArrayList.addAll does not support null param.

See #src/test/java/BuilderDemoTest.java

lombokbuilderbug's People

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.