You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by st...@apache.org on 2019/02/28 09:47:30 UTC

svn commit: r1854511 - in /geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json: EmptyJsonArray.java EmptyJsonObject.java JsonArray.java JsonObject.java JsonValue.java

Author: struberg
Date: Thu Feb 28 09:47:29 2019
New Revision: 1854511

URL: http://svn.apache.org/viewvc?rev=1854511&view=rev
Log:
GERONIMO-6712 remove JsonProvider resolving for JsonValue class init

The usage of the full JsonProvider might have created a deadlock during class init.

Added:
    geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonArray.java
    geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonObject.java
Modified:
    geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java
    geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java
    geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java

Added: geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonArray.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonArray.java?rev=1854511&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonArray.java (added)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonArray.java Thu Feb 28 09:47:29 2019
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package javax.json;
+
+import java.io.Serializable;
+import java.util.AbstractList;
+import java.util.List;
+
+class EmptyJsonArray extends AbstractList<JsonValue> implements JsonArray, Serializable {
+    @Override
+    public JsonValue get(int i) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public int size() {
+        return 0;
+    }
+
+    @Override
+    public JsonObject getJsonObject(int index) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public JsonArray getJsonArray(int index) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public JsonNumber getJsonNumber(int index) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public JsonString getJsonString(int index) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public <T extends JsonValue> List<T> getValuesAs(Class<T> clazz) {
+        return null;
+    }
+
+    @Override
+    public String getString(int index) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public String getString(int index, String defaultValue) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public int getInt(int index) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public int getInt(int index, int defaultValue) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public boolean getBoolean(int index) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public boolean getBoolean(int index, boolean defaultValue) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public boolean isNull(int index) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    @Override
+    public ValueType getValueType() {
+        return ValueType.ARRAY;
+    }
+}

Added: geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonObject.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonObject.java?rev=1854511&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonObject.java (added)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonObject.java Thu Feb 28 09:47:29 2019
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+package javax.json;
+
+import java.io.Serializable;
+import java.util.AbstractMap;
+import java.util.Collections;
+import java.util.Set;
+
+class EmptyJsonObject extends AbstractMap<String, JsonValue> implements JsonObject, Serializable {
+    @Override
+    public Set<Entry<String, JsonValue>> entrySet() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public JsonArray getJsonArray(String name) {
+        return null;
+    }
+
+    @Override
+    public JsonObject getJsonObject(String name) {
+        return null;
+    }
+
+    @Override
+    public JsonNumber getJsonNumber(String name) {
+        return null;
+    }
+
+    @Override
+    public JsonString getJsonString(String name) {
+        return null;
+    }
+
+    @Override
+    public String getString(String name) {
+        return null;
+    }
+
+    @Override
+    public String getString(String name, String defaultValue) {
+        return null;
+    }
+
+    @Override
+    public int getInt(String name) {
+        throw new NullPointerException("Calling getInt on EmptyJsonObject");
+    }
+
+    @Override
+    public int getInt(String name, int defaultValue) {
+        return defaultValue;
+    }
+
+    @Override
+    public boolean getBoolean(String name) {
+        throw new NullPointerException("Calling getInt on EmptyJsonObject");
+    }
+
+    @Override
+    public boolean getBoolean(String name, boolean defaultValue) {
+        return defaultValue;
+    }
+
+    @Override
+    public boolean isNull(String name) {
+        return true;
+    }
+
+    @Override
+    public ValueType getValueType() {
+        return ValueType.OBJECT;
+    }
+}

Modified: geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java?rev=1854511&r1=1854510&r2=1854511&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java (original)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java Thu Feb 28 09:47:29 2019
@@ -122,6 +122,7 @@ public interface JsonArray extends JsonS
      * @throws IndexOutOfBoundsException if the index is out of range
      * @throws ClassCastException if the value at the specified position is not
      *                            assignable to an int
+     * @throws NullPointerException if an object with the given name doesn't exist
      */
     int getInt(int index);
 
@@ -138,6 +139,7 @@ public interface JsonArray extends JsonS
      * @throws IndexOutOfBoundsException if the index is out of range
      * @throws ClassCastException if the value at the specified position is not
      *                            assignable to a boolean
+     * @throws NullPointerException if an object with the given name doesn't exist
      */
     boolean getBoolean(int index);
 

Modified: geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java?rev=1854511&r1=1854510&r2=1854511&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java (original)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java Thu Feb 28 09:47:29 2019
@@ -75,6 +75,7 @@ public interface JsonObject extends Json
     /**
      * @return the int with the given name or {@code null} if there is no attribute with that name
      * @throws ClassCastException if the JsonValue cannot be correctly cast
+     * @throws NullPointerException if an object with the given name doesn't exist
      */
     int getInt(String name);
 
@@ -87,6 +88,7 @@ public interface JsonObject extends Json
     /**
      * @return the boolean with the given name or {@code null} if there is no attribute with that name
      * @throws ClassCastException if the JsonValue cannot be correctly cast
+     * @throws NullPointerException if an object with the given name doesn't exist
      */
     boolean getBoolean(String name);
 

Modified: geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java?rev=1854511&r1=1854510&r2=1854511&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java (original)
+++ geronimo/specs/trunk/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java Thu Feb 28 09:47:29 2019
@@ -24,12 +24,12 @@ public interface JsonValue {
     /**
      * The empty JSON object.
      */
-    JsonObject EMPTY_JSON_OBJECT = Json.createObjectBuilder().build();
+    JsonObject EMPTY_JSON_OBJECT = new EmptyJsonObject();
 
     /**
      * The empty JSON array.
      */
-    JsonArray EMPTY_JSON_ARRAY = Json.createArrayBuilder().build();
+    JsonArray EMPTY_JSON_ARRAY = new EmptyJsonArray();
 
 
     /**