You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by rm...@apache.org on 2019/08/18 18:06:36 UTC

[johnzon] branch master updated: basic validations: JsonObject should be immutable, JsonObjectBuilder#remove does not validate NPE for its input

This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/johnzon.git


The following commit(s) were added to refs/heads/master by this push:
     new 61ff1f4  basic validations: JsonObject should be immutable, JsonObjectBuilder#remove does not validate NPE for its input
61ff1f4 is described below

commit 61ff1f4a156c321b82b9b739eb32a8901517f7ae
Author: Romain Manni-Bucau <rm...@apache.org>
AuthorDate: Sun Aug 18 20:06:31 2019 +0200

    basic validations: JsonObject should be immutable, JsonObjectBuilder#remove does not validate NPE for its input
---
 .../java/org/apache/johnzon/core/JsonObjectBuilderImpl.java    |  4 +++-
 .../src/main/java/org/apache/johnzon/core/JsonObjectImpl.java  | 10 ++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonObjectBuilderImpl.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonObjectBuilderImpl.java
index e34c007..de13a0a 100644
--- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonObjectBuilderImpl.java
+++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonObjectBuilderImpl.java
@@ -18,6 +18,8 @@
  */
 package org.apache.johnzon.core;
 
+import static java.util.Objects.requireNonNull;
+
 import javax.json.JsonArrayBuilder;
 import javax.json.JsonException;
 import javax.json.JsonObject;
@@ -166,7 +168,7 @@ class JsonObjectBuilderImpl implements JsonObjectBuilder, Serializable {
 
     @Override
     public JsonObjectBuilder remove(String name) {
-        attributeMap.remove(name);
+        attributeMap.remove(requireNonNull(name));
         return this;
     }
 
diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonObjectImpl.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonObjectImpl.java
index 7801b60..a84053f 100644
--- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonObjectImpl.java
+++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonObjectImpl.java
@@ -173,6 +173,16 @@ final class JsonObjectImpl extends AbstractMap<String, JsonValue> implements Jso
         return unmodifieableBackingMap.entrySet();
     }
 
+    @Override
+    public void clear() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public JsonValue remove(final Object key) {
+        throw new UnsupportedOperationException();
+    }
+
     private Object writeReplace() throws ObjectStreamException {
         return new SerializableValue(toString());
     }