Removing from an empty JsonObjectBuilder may produce a NPE

Open Beginner friendly
#167 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java
Domain
backend

Research direction

Start in JsonObjectBuilderImpl.java at the remove method and reproduce the issue with the Json.createObjectBuilder() example from the report. Trace how valueMap is initialized for an empty builder, then verify that removing from an empty builder completes without a NullPointerException.

Written by the indexing model from the issue text.

Description

It seems that builder does not initialize the valueMap field in all cases.

    public class Test {
        public static void main(String[] args) {
            JsonObjectBuilder builder = Json.createObjectBuilder();
            builder.remove("name");
        }
    }

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.util.Map.remove(Object)" because "this.valueMap" is null
at org.eclipse.parsson.JsonObjectBuilderImpl.remove(JsonObjectBuilderImpl.java:171)

Dominant language
Java
Stars
17
Forks
25
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from eclipse-ee4j/parsson

All issues in eclipse-ee4j/parsson

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.