You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2017/03/07 19:21:24 UTC

[01/51] [abbrv] geode git commit: GEODE-2142: Adding JSON library from the https://github.com/tdunning/open-json project

Repository: geode
Updated Branches:
  refs/heads/feature/GEM-1195 5b78f5d24 -> f46874799


http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/java/org/json/ParsingTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/ParsingTest.java b/geode-json/src/test/java/org/json/ParsingTest.java
new file mode 100755
index 0000000..4a0837a
--- /dev/null
+++ b/geode-json/src/test/java/org/json/ParsingTest.java
@@ -0,0 +1,294 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import org.junit.Test;
+
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class ParsingTest {
+
+    @Test
+    public void testParsingNoObjects() {
+        try {
+            new JSONTokener("").nextValue();
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testParsingLiterals() throws JSONException {
+        assertParsed(Boolean.TRUE, "true");
+        assertParsed(Boolean.FALSE, "false");
+        assertParsed(JSONObject.NULL, "null");
+        assertParsed(JSONObject.NULL, "NULL");
+        assertParsed(Boolean.FALSE, "False");
+        assertParsed(Boolean.TRUE, "truE");
+    }
+
+    @Test
+    public void testParsingQuotedStrings() throws JSONException {
+        assertParsed("abc", "\"abc\"");
+        assertParsed("123", "\"123\"");
+        assertParsed("foo\nbar", "\"foo\\nbar\"");
+        assertParsed("foo bar", "\"foo\\u0020bar\"");
+        assertParsed("\"{}[]/\\:,=;#", "\"\\\"{}[]/\\\\:,=;#\"");
+    }
+
+    @Test
+    public void testParsingSingleQuotedStrings() throws JSONException {
+        assertParsed("abc", "'abc'");
+        assertParsed("123", "'123'");
+        assertParsed("foo\nbar", "'foo\\nbar'");
+        assertParsed("foo bar", "'foo\\u0020bar'");
+        assertParsed("\"{}[]/\\:,=;#", "'\\\"{}[]/\\\\:,=;#'");
+    }
+
+    @Test
+    public void testParsingUnquotedStrings() throws JSONException {
+        assertParsed("abc", "abc");
+        assertParsed("123abc", "123abc");
+        assertParsed("123e0x", "123e0x");
+        assertParsed("123e", "123e");
+        assertParsed("123ee21", "123ee21");
+        assertParsed("0xFFFFFFFFFFFFFFFFF", "0xFFFFFFFFFFFFFFFFF");
+    }
+
+    /**
+     * Unfortunately the original implementation attempts to figure out what
+     * Java number type best suits an input value.
+     */
+    @Test
+    public void testParsingNumbersThatAreBestRepresentedAsLongs() throws JSONException {
+        assertParsed(9223372036854775807L, "9223372036854775807");
+        assertParsed(9223372036854775806L, "9223372036854775806");
+        assertParsed(-9223372036854775808L, "-9223372036854775808");
+        assertParsed(-9223372036854775807L, "-9223372036854775807");
+    }
+
+    @Test
+    public void testParsingNumbersThatAreBestRepresentedAsIntegers() throws JSONException {
+        assertParsed(0, "0");
+        assertParsed(5, "5");
+        assertParsed(-2147483648, "-2147483648");
+        assertParsed(2147483647, "2147483647");
+    }
+
+    @Test
+    public void testParsingNegativeZero() throws JSONException {
+        assertParsed(0, "-0");
+    }
+
+    @Test
+    public void testParsingIntegersWithAdditionalPrecisionYieldDoubles() throws JSONException {
+        assertParsed(1d, "1.00");
+        assertParsed(1d, "1.0");
+        assertParsed(0d, "0.0");
+        assertParsed(-0d, "-0.0");
+    }
+
+    @Test
+    public void testParsingNumbersThatAreBestRepresentedAsDoubles() throws JSONException {
+        assertParsed(9.223372036854776E18, "9223372036854775808");
+        assertParsed(-9.223372036854776E18, "-9223372036854775809");
+        assertParsed(1.7976931348623157E308, "1.7976931348623157e308");
+        assertParsed(2.2250738585072014E-308, "2.2250738585072014E-308");
+        assertParsed(4.9E-324, "4.9E-324");
+        assertParsed(4.9E-324, "4.9e-324");
+    }
+
+    @Test
+    public void testParsingOctalNumbers() throws JSONException {
+        assertParsed(5, "05");
+        assertParsed(8, "010");
+        assertParsed(1046, "02026");
+    }
+
+    @Test
+    public void testParsingHexNumbers() throws JSONException {
+        assertParsed(5, "0x5");
+        assertParsed(16, "0x10");
+        assertParsed(8230, "0x2026");
+        assertParsed(180150010, "0xABCDEFA");
+        assertParsed(2077093803, "0x7BCDEFAB");
+    }
+
+    @Test
+    public void testParsingLargeHexValues() throws JSONException {
+        assertParsed(Integer.MAX_VALUE, "0x7FFFFFFF");
+        String message = "Hex values are parsed as Strings if their signed " +
+                "value is greater than Integer.MAX_VALUE.";
+        assertParsed(message, 0x80000000L, "0x80000000");
+    }
+
+    @Test
+    public void test64BitHexValues() throws JSONException {
+        // note that this is different from the same test in the original Android
+        // this is due to the fact that Long.parseLong doesn't correctly handle
+        // the value -1 expressed as unsigned hex if you use the normal JDK. Presumably
+        // the Android equivalent program does this better.
+        assertParsed("Large hex longs shouldn't yield ints or strings",
+                0xFFFFFFFFFFFFFFFL, "0xFFFFFFFFFFFFFFF");
+    }
+
+    @Test
+    public void testParsingWithCommentsAndWhitespace() throws JSONException {
+        assertParsed("baz", "  // foo bar \n baz");
+        assertParsed("baz", "  // foo bar \r baz");
+        assertParsed("baz", "  // foo bar \r\n baz");
+        assertParsed("baz", "  # foo bar \n baz");
+        assertParsed("baz", "  # foo bar \r baz");
+        assertParsed("baz", "  # foo bar \r\n baz");
+        assertParsed(5, "  /* foo bar \n baz */ 5");
+        assertParsed(5, "  /* foo bar \n baz */ 5 // quux");
+        assertParsed(5, "  5   ");
+        assertParsed(5, "  5  \r\n\t ");
+        assertParsed(5, "\r\n\t   5 ");
+    }
+
+    @Test
+    public void testParsingArrays() throws JSONException {
+        assertParsed(array(), "[]");
+        assertParsed(array(5, 6, true), "[5,6,true]");
+        assertParsed(array(5, 6, array()), "[5,6,[]]");
+        assertParsed(array(5, 6, 7), "[5;6;7]");
+        assertParsed(array(5, 6, 7), "[5  , 6 \t; \r\n 7\n]");
+        assertParsed(array(5, 6, 7, null), "[5,6,7,]");
+        assertParsed(array(null, null), "[,]");
+        assertParsed(array(5, null, null, null, 5), "[5,,,,5]");
+        assertParsed(array(null, 5), "[,5]");
+        assertParsed(array(null, null, null), "[,,]");
+        assertParsed(array(null, null, null, 5), "[,,,5]");
+    }
+
+    @Test
+    public void testParsingObjects() throws JSONException {
+        assertParsed(object("foo", 5), "{\"foo\": 5}");
+        assertParsed(object("foo", 5), "{foo: 5}");
+        assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\": 5, \"bar\": \"baz\"}");
+        assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\": 5; \"bar\": \"baz\"}");
+        assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\"= 5; \"bar\"= \"baz\"}");
+        assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\"=> 5; \"bar\"=> \"baz\"}");
+        assertParsed(object("foo", object(), "bar", array()), "{\"foo\"=> {}; \"bar\"=> []}");
+        assertParsed(object("foo", object("foo", array(5, 6))), "{\"foo\": {\"foo\": [5, 6]}}");
+        assertParsed(object("foo", object("foo", array(5, 6))), "{\"foo\":\n\t{\t \"foo\":[5,\r6]}}");
+    }
+
+    @Test
+    public void testSyntaxProblemUnterminatedObject() {
+        assertParseFail("{");
+        assertParseFail("{\"foo\"");
+        assertParseFail("{\"foo\":");
+        assertParseFail("{\"foo\":bar");
+        assertParseFail("{\"foo\":bar,");
+        assertParseFail("{\"foo\":bar,\"baz\"");
+        assertParseFail("{\"foo\":bar,\"baz\":");
+        assertParseFail("{\"foo\":bar,\"baz\":true");
+        assertParseFail("{\"foo\":bar,\"baz\":true,");
+    }
+
+    @Test
+    public void testSyntaxProblemEmptyString() {
+        assertParseFail("");
+    }
+
+    @Test
+    public void testSyntaxProblemUnterminatedArray() {
+        assertParseFail("[");
+        assertParseFail("[,");
+        assertParseFail("[,,");
+        assertParseFail("[true");
+        assertParseFail("[true,");
+        assertParseFail("[true,,");
+    }
+
+    @Test
+    public void testSyntaxProblemMalformedObject() {
+        assertParseFail("{:}");
+        assertParseFail("{\"key\":}");
+        assertParseFail("{:true}");
+        assertParseFail("{\"key\":true:}");
+        assertParseFail("{null:true}");
+        assertParseFail("{true:true}");
+        assertParseFail("{0xFF:true}");
+    }
+
+    private void assertParseFail(String malformedJson) {
+        try {
+            new JSONTokener(malformedJson).nextValue();
+            fail("Successfully parsed: \"" + malformedJson + "\"");
+        } catch (JSONException ignored) {
+        } catch (StackOverflowError e) {
+            fail("Stack overflowed on input: \"" + malformedJson + "\"");
+        }
+    }
+
+    private JSONArray array(Object... elements) {
+        return new JSONArray(Arrays.asList(elements));
+    }
+
+    private JSONObject object(Object... keyValuePairs) throws JSONException {
+        JSONObject result = new JSONObject();
+        for (int i = 0; i < keyValuePairs.length; i += 2) {
+            result.put((String) keyValuePairs[i], keyValuePairs[i + 1]);
+        }
+        return result;
+    }
+
+    private void assertParsed(String message, Object expected, String json) throws JSONException {
+        Object actual = new JSONTokener(json).nextValue();
+        actual = canonicalize(actual);
+        expected = canonicalize(expected);
+        assertEquals("For input \"" + json + "\" " + message, expected, actual);
+    }
+
+    private void assertParsed(Object expected, String json) throws JSONException {
+        assertParsed("", expected, json);
+    }
+
+    /**
+     * Since they don't implement equals or hashCode properly, this recursively
+     * replaces JSONObjects with an equivalent HashMap, and JSONArrays with the
+     * equivalent ArrayList.
+     */
+    private Object canonicalize(Object input) throws JSONException {
+        if (input instanceof JSONArray) {
+            JSONArray array = (JSONArray) input;
+            List<Object> result = new ArrayList<Object>();
+            for (int i = 0; i < array.length(); i++) {
+                result.add(canonicalize(array.opt(i)));
+            }
+            return result;
+        } else if (input instanceof JSONObject) {
+            JSONObject object = (JSONObject) input;
+            Map<String, Object> result = new HashMap<String, Object>();
+            for (Iterator<?> i = object.keys(); i.hasNext(); ) {
+                String key = (String) i.next();
+                result.put(key, canonicalize(object.get(key)));
+            }
+            return result;
+        } else if (input == null || input.equals(JSONObject.NULL)) {
+            return JSONObject.NULL;
+        } else {
+            return input;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/java/org/json/SelfUseTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/SelfUseTest.java b/geode-json/src/test/java/org/json/SelfUseTest.java
new file mode 100755
index 0000000..0b9fb2c
--- /dev/null
+++ b/geode-json/src/test/java/org/json/SelfUseTest.java
@@ -0,0 +1,276 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * These tests checks self use calls. For the most part we doesn't attempt to
+ * cover self-use, except in those cases where our clean room implementation
+ * does it.
+ * <p>
+ * <p>This black box test was written without inspecting the non-free org.json
+ * sourcecode.
+ */
+public class SelfUseTest {
+
+    private int objectPutCalls = 0;
+    private int objectGetCalls = 0;
+    private int objectOptCalls = 0;
+    private int objectOptTypeCalls = 0;
+    private int arrayPutCalls = 0;
+    private int arrayGetCalls = 0;
+    private int arrayOptCalls = 0;
+    private int arrayOptTypeCalls = 0;
+    private int tokenerNextCalls = 0;
+    private int tokenerNextValueCalls = 0;
+
+    private final JSONObject object = new JSONObject() {
+        @Override
+        public JSONObject put(String name, Object value) throws JSONException {
+            objectPutCalls++;
+            return super.put(name, value);
+        }
+
+        @Override
+        public Object get(String name) throws JSONException {
+            objectGetCalls++;
+            return super.get(name);
+        }
+
+        @Override
+        public Object opt(String name) {
+            objectOptCalls++;
+            return super.opt(name);
+        }
+
+        @Override
+        public boolean optBoolean(String key, boolean defaultValue) {
+            objectOptTypeCalls++;
+            return super.optBoolean(key, defaultValue);
+        }
+
+        @Override
+        public double optDouble(String key, double defaultValue) {
+            objectOptTypeCalls++;
+            return super.optDouble(key, defaultValue);
+        }
+
+        @Override
+        public int optInt(String key, int defaultValue) {
+            objectOptTypeCalls++;
+            return super.optInt(key, defaultValue);
+        }
+
+        @Override
+        public long optLong(String key, long defaultValue) {
+            objectOptTypeCalls++;
+            return super.optLong(key, defaultValue);
+        }
+
+        @Override
+        public String optString(String key, String defaultValue) {
+            objectOptTypeCalls++;
+            return super.optString(key, defaultValue);
+        }
+    };
+
+    private final JSONArray array = new JSONArray() {
+        @Override
+        public JSONArray put(int index, Object value) throws JSONException {
+            arrayPutCalls++;
+            return super.put(index, value);
+        }
+
+        @Override
+        public Object get(int index) throws JSONException {
+            arrayGetCalls++;
+            return super.get(index);
+        }
+
+        @Override
+        public Object opt(int index) {
+            arrayOptCalls++;
+            return super.opt(index);
+        }
+
+        @Override
+        public boolean optBoolean(int index, boolean fallback) {
+            arrayOptTypeCalls++;
+            return super.optBoolean(index, fallback);
+        }
+
+        @Override
+        public double optDouble(int index, double fallback) {
+            arrayOptTypeCalls++;
+            return super.optDouble(index, fallback);
+        }
+
+        @Override
+        public long optLong(int index, long fallback) {
+            arrayOptTypeCalls++;
+            return super.optLong(index, fallback);
+        }
+
+        @Override
+        public String optString(int index, String fallback) {
+            arrayOptTypeCalls++;
+            return super.optString(index, fallback);
+        }
+
+        @Override
+        public int optInt(int index, int fallback) {
+            arrayOptTypeCalls++;
+            return super.optInt(index, fallback);
+        }
+    };
+
+    private final JSONTokener tokener = new JSONTokener("{\"foo\": [true]}") {
+        @Override
+        public char next() {
+            tokenerNextCalls++;
+            return super.next();
+        }
+
+        @Override
+        public Object nextValue() throws JSONException {
+            tokenerNextValueCalls++;
+            return super.nextValue();
+        }
+    };
+
+
+    @Test
+    public void testObjectPut() throws JSONException {
+        object.putOpt("foo", "bar");
+        assertEquals(1, objectPutCalls);
+    }
+
+    @Test
+    public void testObjectAccumulate() throws JSONException {
+        object.accumulate("foo", "bar");
+        assertEquals(1, objectPutCalls);
+    }
+
+    @Test
+    public void testObjectGetBoolean() throws JSONException {
+        object.put("foo", "true");
+        object.getBoolean("foo");
+        assertEquals(1, objectGetCalls);
+    }
+
+    @Test
+    public void testObjectOptType() throws JSONException {
+        object.optBoolean("foo");
+        assertEquals(1, objectOptCalls);
+        assertEquals(1, objectOptTypeCalls);
+        object.optDouble("foo");
+        assertEquals(2, objectOptCalls);
+        assertEquals(2, objectOptTypeCalls);
+        object.optInt("foo");
+        assertEquals(3, objectOptCalls);
+        assertEquals(3, objectOptTypeCalls);
+        object.optLong("foo");
+        assertEquals(4, objectOptCalls);
+        assertEquals(4, objectOptTypeCalls);
+        object.optString("foo");
+        assertEquals(5, objectOptCalls);
+        assertEquals(5, objectOptTypeCalls);
+    }
+
+    @Test
+    public void testToJSONArray() throws JSONException {
+        object.put("foo", 5);
+        object.put("bar", 10);
+        array.put("foo");
+        array.put("baz");
+        array.put("bar");
+        object.toJSONArray(array);
+        assertEquals(3, arrayOptCalls);
+        assertEquals(0, arrayOptTypeCalls);
+        assertEquals(3, objectOptCalls);
+        assertEquals(0, objectOptTypeCalls);
+    }
+
+    @Test
+    public void testPutAtIndex() throws JSONException {
+        array.put(10, false);
+        assertEquals(1, arrayPutCalls);
+    }
+
+    @Test
+    public void testIsNull() {
+        array.isNull(5);
+        assertEquals(1, arrayOptCalls);
+    }
+
+    @Test
+    public void testArrayGetType() throws JSONException {
+        array.put(true);
+        array.getBoolean(0);
+        assertEquals(1, arrayGetCalls);
+    }
+
+    @Test
+    public void testArrayOptType() throws JSONException {
+        array.optBoolean(3);
+        assertEquals(1, arrayOptCalls);
+        assertEquals(1, arrayOptTypeCalls);
+        array.optDouble(3);
+        assertEquals(2, arrayOptCalls);
+        assertEquals(2, arrayOptTypeCalls);
+        array.optInt(3);
+        assertEquals(3, arrayOptCalls);
+        assertEquals(3, arrayOptTypeCalls);
+        array.optLong(3);
+        assertEquals(4, arrayOptCalls);
+        assertEquals(4, arrayOptTypeCalls);
+        array.optString(3);
+        assertEquals(5, arrayOptCalls);
+        assertEquals(5, arrayOptTypeCalls);
+    }
+
+    @Test
+    public void testToJSONObject() throws JSONException {
+        array.put("foo");
+        array.put("baz");
+        array.put("bar");
+        JSONArray values = new JSONArray();
+        values.put(5.5d);
+        values.put(11d);
+        values.put(30);
+        values.toJSONObject(array);
+        assertEquals(3, arrayOptCalls);
+        assertEquals(0, arrayOptTypeCalls);
+    }
+
+    @Test
+    public void testNextExpecting() throws JSONException {
+        tokener.next('{');
+        assertEquals(1, tokenerNextCalls);
+        tokener.next('\"');
+        assertEquals(2, tokenerNextCalls);
+    }
+
+    @Test
+    public void testNextValue() throws JSONException {
+        tokener.nextValue();
+        assertEquals(4, tokenerNextValueCalls);
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/resources/sample-01.json
----------------------------------------------------------------------
diff --git a/geode-json/src/test/resources/sample-01.json b/geode-json/src/test/resources/sample-01.json
new file mode 100755
index 0000000..9cfef12
--- /dev/null
+++ b/geode-json/src/test/resources/sample-01.json
@@ -0,0 +1,227 @@
+[
+  {
+    "_id": "58309f3bd307b72ae49a9b23",
+    "index": 0,
+    "guid": "5764ebd8-b333-469e-8d83-4eb5658f1566",
+    "isActive": true,
+    "balance": "$1,099.93",
+    "picture": "http://placehold.it/32x32",
+    "age": 37,
+    "eyeColor": "blue",
+    "name": "Barrera Wilkerson",
+    "gender": "male",
+    "company": "VURBO",
+    "email": "barrerawilkerson@vurbo.com",
+    "phone": "+1 (817) 429-2473",
+    "address": "522 Vanderveer Street, Detroit, Wyoming, 4320",
+    "about": "Et officia aute ullamco magna adipisicing non ut cupidatat cupidatat aliquip. Tempor occaecat ex ad dolore aliquip mollit ea esse ipsum. Est incididunt sunt commodo duis est. Reprehenderit in ut reprehenderit ad culpa ea fugiat et est adipisicing aliquip. Id mollit voluptate qui pariatur officia.\r\n",
+    "registered": "2016-06-29T08:54:14 +07:00",
+    "latitude": -87.548434,
+    "longitude": 64.251242,
+    "tags": [
+      "aliqua",
+      "ex",
+      "sit",
+      "magna",
+      "dolor",
+      "laborum",
+      "non"
+    ],
+    "friends": [
+      {
+        "id": 0,
+        "name": "Byers Pratt"
+      },
+      {
+        "id": 1,
+        "name": "Kennedy Contreras"
+      },
+      {
+        "id": 2,
+        "name": "Frazier Monroe"
+      }
+    ],
+    "greeting": "Hello, Barrera Wilkerson! You have 3 unread messages.",
+    "favoriteFruit": "banana"
+  },
+  {
+    "_id": "58309f3b1f506440093a41d1",
+    "index": 1,
+    "guid": "de1a6cc9-f8b3-426e-b68a-cc30e1fff3c1",
+    "isActive": false,
+    "balance": "$3,397.60",
+    "picture": "http://placehold.it/32x32",
+    "age": 32,
+    "eyeColor": "blue",
+    "name": "Trisha Morris",
+    "gender": "female",
+    "company": "AMTAP",
+    "email": "trishamorris@amtap.com",
+    "phone": "+1 (805) 423-3375",
+    "address": "495 Tampa Court, Libertytown, New Hampshire, 5177",
+    "about": "Elit culpa Lorem dolor sit laborum ut ullamco ullamco nostrud reprehenderit adipisicing eiusmod. Aliqua quis dolor esse sint. Dolore in excepteur laborum anim ut consectetur. Nisi officia est eu ex ex id. Ipsum duis ullamco ad ut labore dolor. In amet tempor deserunt ullamco velit eu fugiat.\r\n",
+    "registered": "2015-02-08T06:14:19 +08:00",
+    "latitude": -81.956277,
+    "longitude": 143.685584,
+    "tags": [
+      "cillum",
+      "ullamco",
+      "magna",
+      "cillum",
+      "voluptate",
+      "magna",
+      "exercitation"
+    ],
+    "friends": [
+      {
+        "id": 0,
+        "name": "Fuentes Stout"
+      },
+      {
+        "id": 1,
+        "name": "Violet Vargas"
+      },
+      {
+        "id": 2,
+        "name": "Schmidt Wilder"
+      }
+    ],
+    "greeting": "Hello, Trisha Morris! You have 4 unread messages.",
+    "favoriteFruit": "strawberry"
+  },
+  {
+    "_id": "58309f3beaef2f31339b3755",
+    "index": 2,
+    "guid": "0bf387b7-abc2-4828-becc-1269928f7c3d",
+    "isActive": false,
+    "balance": "$1,520.64",
+    "picture": "http://placehold.it/32x32",
+    "age": 37,
+    "eyeColor": "blue",
+    "name": "Deanna Santiago",
+    "gender": "female",
+    "company": "MEGALL",
+    "email": "deannasantiago@megall.com",
+    "phone": "+1 (916) 511-2291",
+    "address": "919 Fayette Street, Homestead, Utah, 8669",
+    "about": "Sit amet ex quis velit irure Lorem non quis aliquip dolor pariatur nulla Lorem officia. Deserunt officia sit velit labore sint nostrud elit aliquip labore ullamco consectetur id amet. Ullamco duis commodo sit incididunt. Fugiat consectetur ad incididunt officia. Sint cillum minim laborum laboris id cillum est exercitation in eiusmod qui.\r\n",
+    "registered": "2015-11-18T08:39:28 +08:00",
+    "latitude": 79.105701,
+    "longitude": -146.901754,
+    "tags": [
+      "non",
+      "ullamco",
+      "cillum",
+      "ipsum",
+      "amet",
+      "aliqua",
+      "aliquip"
+    ],
+    "friends": [
+      {
+        "id": 0,
+        "name": "Hanson Anderson"
+      },
+      {
+        "id": 1,
+        "name": "Pollard Soto"
+      },
+      {
+        "id": 2,
+        "name": "Barlow Campbell"
+      }
+    ],
+    "greeting": "Hello, Deanna Santiago! You have 7 unread messages.",
+    "favoriteFruit": "apple"
+  },
+  {
+    "_id": "58309f3b49a68ad01346f27f",
+    "index": 3,
+    "guid": "d29c0dcc-48fb-4ca4-a63b-b47c0e6d6398",
+    "isActive": false,
+    "balance": "$2,069.96",
+    "picture": "http://placehold.it/32x32",
+    "age": 29,
+    "eyeColor": "green",
+    "name": "Brooks Gates",
+    "gender": "male",
+    "company": "TERRAGEN",
+    "email": "brooksgates@terragen.com",
+    "phone": "+1 (875) 483-2224",
+    "address": "562 Noll Street, Kipp, Louisiana, 7659",
+    "about": "Reprehenderit laboris mollit nulla commodo quis laborum commodo. Laborum aliquip laboris officia minim ipsum laborum ipsum reprehenderit quis laboris est sint culpa. Culpa magna aute mollit exercitation.\r\n",
+    "registered": "2016-05-04T10:34:38 +07:00",
+    "latitude": 72.77079,
+    "longitude": -134.291768,
+    "tags": [
+      "est",
+      "sunt",
+      "laboris",
+      "ea",
+      "proident",
+      "aute",
+      "excepteur"
+    ],
+    "friends": [
+      {
+        "id": 0,
+        "name": "Roxanne Morgan"
+      },
+      {
+        "id": 1,
+        "name": "Tamara Kelly"
+      },
+      {
+        "id": 2,
+        "name": "Cleveland Bush"
+      }
+    ],
+    "greeting": "Hello, Brooks Gates! You have 1 unread messages.",
+    "favoriteFruit": "banana"
+  },
+  {
+    "_id": "58309f3be746700e9af9a645",
+    "index": 4,
+    "guid": "54382bd6-c476-469d-9e1c-e546f959db51",
+    "isActive": true,
+    "balance": "$2,012.57",
+    "picture": "http://placehold.it/32x32",
+    "age": 40,
+    "eyeColor": "brown",
+    "name": "Jackie Thomas",
+    "gender": "female",
+    "company": "HINWAY",
+    "email": "jackiethomas@hinway.com",
+    "phone": "+1 (843) 470-2096",
+    "address": "910 Emerson Place, Gwynn, Federated States Of Micronesia, 4688",
+    "about": "Id cupidatat laboris elit est eiusmod esse nostrud. Ex commodo nisi voluptate est nisi laborum officia sint incididunt pariatur qui deserunt ullamco. Fugiat proident magna ipsum sit sint id adipisicing sit nostrud labore sit officia. Eiusmod exercitation non enim excepteur amet irure ullamco consectetur cupidatat proident Lorem reprehenderit aliquip. Veniam esse dolor Lorem incididunt proident officia enim in incididunt culpa. Mollit voluptate commodo aliquip anim ipsum nostrud ut labore enim labore qui do minim incididunt. Quis irure proident voluptate nisi qui sunt aute duis irure.\r\n",
+    "registered": "2014-08-03T09:21:43 +07:00",
+    "latitude": 84.871256,
+    "longitude": 2.043339,
+    "tags": [
+      "tempor",
+      "ut",
+      "deserunt",
+      "esse",
+      "nostrud",
+      "dolore",
+      "ex"
+    ],
+    "friends": [
+      {
+        "id": 0,
+        "name": "Lois Walters"
+      },
+      {
+        "id": 1,
+        "name": "Brewer Buchanan"
+      },
+      {
+        "id": 2,
+        "name": "Mccormick Fleming"
+      }
+    ],
+    "greeting": "Hello, Jackie Thomas! You have 2 unread messages.",
+    "favoriteFruit": "banana"
+  }
+]
\ No newline at end of file


[13/51] [abbrv] geode git commit: GEODE-2142: spotless

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/test/java/org/json/JSONArrayTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONArrayTest.java b/geode-json/src/test/java/org/json/JSONArrayTest.java
index 8f6632b..88ba989 100755
--- a/geode-json/src/test/java/org/json/JSONArrayTest.java
+++ b/geode-json/src/test/java/org/json/JSONArrayTest.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -28,581 +26,582 @@ import static org.junit.Assert.*;
  * This black box test was written without inspecting the non-free org.json sourcecode.
  */
 public class JSONArrayTest {
-    @Test
-    public void testEmptyArray() throws JSONException {
-        JSONArray array = new JSONArray();
-        assertEquals(0, array.length());
-        assertEquals("", array.join(" AND "));
-        try {
-            array.get(0);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            array.getBoolean(0);
-            fail();
-        } catch (JSONException ignored) {
-        }
-
-        assertEquals("[]", array.toString());
-        assertEquals("[]", array.toString(4));
-
-        // out of bounds is co-opted with defaulting
-        assertTrue(array.isNull(0));
-        assertNull(array.opt(0));
-        assertFalse(array.optBoolean(0));
-        assertTrue(array.optBoolean(0, true));
-
-        // bogus (but documented) behaviour: returns null rather than an empty object!
-        assertNull(array.toJSONObject(new JSONArray()));
-    }
-
-    @Test
-    public void testEqualsAndHashCode() throws JSONException {
-        JSONArray a = new JSONArray();
-        JSONArray b = new JSONArray();
-        assertTrue(a.equals(b));
-        assertEquals("equals() not consistent with hashCode()", a.hashCode(), b.hashCode());
-
-        a.put(true);
-        a.put(false);
-        b.put(true);
-        b.put(false);
-        assertTrue(a.equals(b));
-        assertEquals(a.hashCode(), b.hashCode());
-
-        b.put(true);
-        assertFalse(a.equals(b));
-        assertTrue(a.hashCode() != b.hashCode());
-    }
-
-    @Test
-    public void testBooleans() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put(true);
-        array.put(false);
-        array.put(2, false);
-        array.put(3, false);
-        array.put(2, true);
-        assertEquals("[true,false,true,false]", array.toString());
-        assertEquals(4, array.length());
-        assertEquals(Boolean.TRUE, array.get(0));
-        assertEquals(Boolean.FALSE, array.get(1));
-        assertEquals(Boolean.TRUE, array.get(2));
-        assertEquals(Boolean.FALSE, array.get(3));
-        assertFalse(array.isNull(0));
-        assertFalse(array.isNull(1));
-        assertFalse(array.isNull(2));
-        assertFalse(array.isNull(3));
-        assertEquals(true, array.optBoolean(0));
-        assertEquals(false, array.optBoolean(1, true));
-        assertEquals(true, array.optBoolean(2, false));
-        assertEquals(false, array.optBoolean(3));
-        assertEquals("true", array.getString(0));
-        assertEquals("false", array.getString(1));
-        assertEquals("true", array.optString(2));
-        assertEquals("false", array.optString(3, "x"));
-        assertEquals("[\n     true,\n     false,\n     true,\n     false\n]", array.toString(5));
-
-        JSONArray other = new JSONArray();
-        other.put(true);
-        other.put(false);
-        other.put(true);
-        other.put(false);
-        assertTrue(array.equals(other));
-        other.put(true);
-        assertFalse(array.equals(other));
-
-        other = new JSONArray();
-        other.put("true");
-        other.put("false");
-        other.put("truE");
-        other.put("FALSE");
-        assertFalse(array.equals(other));
-        assertFalse(other.equals(array));
-        assertEquals(true, other.getBoolean(0));
-        assertEquals(false, other.optBoolean(1, true));
-        assertEquals(true, other.optBoolean(2));
-        assertEquals(false, other.getBoolean(3));
-    }
-
-    // http://code.google.com/p/android/issues/detail?id=16411
-    @Test
-    public void testCoerceStringToBoolean() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put("maybe");
-        try {
-            array.getBoolean(0);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals(false, array.optBoolean(0));
-        assertEquals(true, array.optBoolean(0, true));
-    }
-
-    @Test
-    public void testNulls() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put(3, null);
-        array.put(0, JSONObject.NULL);
-        assertEquals(4, array.length());
-        assertEquals("[null,null,null,null]", array.toString());
-
-        // there's 2 ways to represent null; each behaves differently!
-        assertEquals(JSONObject.NULL, array.get(0));
-        try {
-            array.get(1);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            array.get(2);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            array.get(3);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals(JSONObject.NULL, array.opt(0));
-        assertEquals(null, array.opt(1));
-        assertEquals(null, array.opt(2));
-        assertEquals(null, array.opt(3));
-        assertTrue(array.isNull(0));
-        assertTrue(array.isNull(1));
-        assertTrue(array.isNull(2));
-        assertTrue(array.isNull(3));
-        assertEquals("null", array.optString(0));
-        assertEquals("", array.optString(1));
-        assertEquals("", array.optString(2));
-        assertEquals("", array.optString(3));
-    }
-
-    /**
-     * Our behaviour is questioned by this bug:
-     * http://code.google.com/p/android/issues/detail?id=7257
-     */
-    @Test
-    public void testParseNullYieldsJSONObjectNull() throws JSONException {
-        JSONArray array = new JSONArray("[\"null\",null]");
-        array.put(null);
-        assertEquals("null", array.get(0));
-        assertEquals(JSONObject.NULL, array.get(1));
-        try {
-            array.get(2);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals("null", array.getString(0));
-        assertEquals("null", array.getString(1));
-        try {
-            array.getString(2);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testNumbers() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put(Double.MIN_VALUE);
-        array.put(9223372036854775806L);
-        array.put(Double.MAX_VALUE);
-        array.put(-0d);
-        assertEquals(4, array.length());
-
-        // toString() and getString(int) return different values for -0d
-        assertEquals("[4.9E-324,9223372036854775806,1.7976931348623157E308,-0]", array.toString());
-
-        assertEquals(Double.MIN_VALUE, array.get(0));
-        assertEquals(9223372036854775806L, array.get(1));
-        assertEquals(Double.MAX_VALUE, array.get(2));
-        assertEquals(-0d, array.get(3));
-        assertEquals(Double.MIN_VALUE, array.getDouble(0), 0);
-        assertEquals(9.223372036854776E18, array.getDouble(1), 0);
-        assertEquals(Double.MAX_VALUE, array.getDouble(2), 0);
-        assertEquals(-0d, array.getDouble(3), 0);
-        assertEquals(0, array.getLong(0));
-        assertEquals(9223372036854775806L, array.getLong(1));
-        assertEquals(Long.MAX_VALUE, array.getLong(2));
-        assertEquals(0, array.getLong(3));
-        assertEquals(0, array.getInt(0));
-        assertEquals(-2, array.getInt(1));
-        assertEquals(Integer.MAX_VALUE, array.getInt(2));
-        assertEquals(0, array.getInt(3));
-        assertEquals(Double.MIN_VALUE, array.opt(0));
-        assertEquals(Double.MIN_VALUE, array.optDouble(0), 0);
-        assertEquals(0, array.optLong(0, 1L));
-        assertEquals(0, array.optInt(0, 1));
-        assertEquals("4.9E-324", array.getString(0));
-        assertEquals("9223372036854775806", array.getString(1));
-        assertEquals("1.7976931348623157E308", array.getString(2));
-        assertEquals("-0.0", array.getString(3));
-
-        JSONArray other = new JSONArray();
-        other.put(Double.MIN_VALUE);
-        other.put(9223372036854775806L);
-        other.put(Double.MAX_VALUE);
-        other.put(-0d);
-        assertTrue(array.equals(other));
-        other.put(0, 0L);
-        assertFalse(array.equals(other));
-    }
-
-    @Test
-    public void testStrings() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put("true");
-        array.put("5.5");
-        array.put("9223372036854775806");
-        array.put("null");
-        array.put("5\"8' tall");
-        assertEquals(5, array.length());
-        assertEquals("[\"true\",\"5.5\",\"9223372036854775806\",\"null\",\"5\\\"8' tall\"]",
-                array.toString());
-
-        // although the documentation doesn't mention it, join() escapes text and wraps
-        // strings in quotes
-        assertEquals("\"true\" \"5.5\" \"9223372036854775806\" \"null\" \"5\\\"8' tall\"",
-                array.join(" "));
-
-        assertEquals("true", array.get(0));
-        assertEquals("null", array.getString(3));
-        assertEquals("5\"8' tall", array.getString(4));
-        assertEquals("true", array.opt(0));
-        assertEquals("5.5", array.optString(1));
-        assertEquals("9223372036854775806", array.optString(2, null));
-        assertEquals("null", array.optString(3, "-1"));
-        assertFalse(array.isNull(0));
-        assertFalse(array.isNull(3));
-
-        assertEquals(true, array.getBoolean(0));
-        assertEquals(true, array.optBoolean(0));
-        assertEquals(true, array.optBoolean(0, false));
-        assertEquals(0, array.optInt(0));
-        assertEquals(-2, array.optInt(0, -2));
-
-        assertEquals(5.5d, array.getDouble(1), 0);
-        assertEquals(5L, array.getLong(1));
-        assertEquals(5, array.getInt(1));
-        assertEquals(5, array.optInt(1, 3));
-
-        // The last digit of the string is a 6 but getLong returns a 7. It's probably parsing as a
-        // double and then converting that to a long. This is consistent with JavaScript.
-        assertEquals(9223372036854775807L, array.getLong(2));
-        assertEquals(9.223372036854776E18, array.getDouble(2), 0);
-        assertEquals(Integer.MAX_VALUE, array.getInt(2));
-
-        assertFalse(array.isNull(3));
-        try {
-            array.getDouble(3);
-            fail();
-        } catch (JSONException e) {
-            // expected
-        }
-        assertEquals(Double.NaN, array.optDouble(3), 0);
-        assertEquals(-1.0d, array.optDouble(3, -1.0d), 0);
-    }
-
-    @Test
-    public void testJoin() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put(null);
-        assertEquals("null", array.join(" & "));
-        array.put("\"");
-        assertEquals("null & \"\\\"\"", array.join(" & "));
-        array.put(5);
-        assertEquals("null & \"\\\"\" & 5", array.join(" & "));
-        array.put(true);
-        assertEquals("null & \"\\\"\" & 5 & true", array.join(" & "));
-        array.put(new JSONArray(Arrays.asList(true, false)));
-        assertEquals("null & \"\\\"\" & 5 & true & [true,false]", array.join(" & "));
-        array.put(new JSONObject(Collections.singletonMap("x", 6)));
-        assertEquals("null & \"\\\"\" & 5 & true & [true,false] & {\"x\":6}", array.join(" & "));
-    }
-
-    @Test
-    public void testJoinWithNull() throws JSONException {
-        JSONArray array = new JSONArray(Arrays.asList(5, 6));
-        assertEquals("5null6", array.join(null));
-    }
-
-    @Test
-    public void testJoinWithSpecialCharacters() throws JSONException {
-        JSONArray array = new JSONArray(Arrays.asList(5, 6));
-        assertEquals("5\"6", array.join("\""));
-    }
-
-    @Test
-    public void testToJSONObject() throws JSONException {
-        JSONArray keys = new JSONArray();
-        keys.put("a");
-        keys.put("b");
-
-        JSONArray values = new JSONArray();
-        values.put(5.5d);
-        values.put(false);
-
-        JSONObject object = values.toJSONObject(keys);
-        assertEquals(5.5d, object.get("a"));
-        assertEquals(false, object.get("b"));
-
-        keys.put(0, "a");
-        values.put(0, 11.0d);
-        assertEquals(5.5d, object.get("a"));
-    }
-
-    @Test
-    public void testToJSONObjectWithNulls() throws JSONException {
-        JSONArray keys = new JSONArray();
-        keys.put("a");
-        keys.put("b");
-
-        JSONArray values = new JSONArray();
-        values.put(5.5d);
-        values.put(null);
-
-        // null values are stripped!
-        JSONObject object = values.toJSONObject(keys);
-        assertEquals(1, object.length());
-        assertFalse(object.has("b"));
-        assertEquals("{\"a\":5.5}", object.toString());
-    }
-
-    @Test
-    public void testToJSONObjectMoreNamesThanValues() throws JSONException {
-        JSONArray keys = new JSONArray();
-        keys.put("a");
-        keys.put("b");
-        JSONArray values = new JSONArray();
-        values.put(5.5d);
-        JSONObject object = values.toJSONObject(keys);
-        assertEquals(1, object.length());
-        assertEquals(5.5d, object.get("a"));
-    }
-
-    @Test
-    public void testToJSONObjectMoreValuesThanNames() throws JSONException {
-        JSONArray keys = new JSONArray();
-        keys.put("a");
-        JSONArray values = new JSONArray();
-        values.put(5.5d);
-        values.put(11.0d);
-        JSONObject object = values.toJSONObject(keys);
-        assertEquals(1, object.length());
-        assertEquals(5.5d, object.get("a"));
-    }
-
-    @Test
-    public void testToJSONObjectNullKey() throws JSONException {
-        JSONArray keys = new JSONArray();
-        keys.put(JSONObject.NULL);
-        JSONArray values = new JSONArray();
-        values.put(5.5d);
-        JSONObject object = values.toJSONObject(keys);
-        assertEquals(1, object.length());
-        assertEquals(5.5d, object.get("null"));
-    }
-
-    @Test
-    public void testPutUnsupportedNumbers() throws JSONException {
-        JSONArray array = new JSONArray();
-
-        try {
-            array.put(Double.NaN);
-            fail();
-        } catch (JSONException e) {
-            // expected
-        }
-        try {
-            array.put(0, Double.NEGATIVE_INFINITY);
-            fail();
-        } catch (JSONException e) {
-            // expected
-        }
-        try {
-            array.put(0, Double.POSITIVE_INFINITY);
-            fail();
-        } catch (JSONException e) {
-            // expected
-        }
-    }
-
-    @Test
-    public void testPutUnsupportedNumbersAsObject() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put(Double.valueOf(Double.NaN));
-        array.put(Double.valueOf(Double.NEGATIVE_INFINITY));
-        array.put(Double.valueOf(Double.POSITIVE_INFINITY));
-        assertEquals(null, array.toString());
-    }
-
-    /**
-     * Although JSONArray is usually defensive about which numbers it accepts,
-     * it doesn't check inputs in its constructor.
-     */
-    @Test
-    public void testCreateWithUnsupportedNumbers() throws JSONException {
-        JSONArray array = new JSONArray(Arrays.asList(5.5, Double.NaN));
-        assertEquals(2, array.length());
-        assertEquals(5.5, array.getDouble(0), 0);
-        assertEquals(Double.NaN, array.getDouble(1), 0);
-    }
-
-    @Test
-    public void testToStringWithUnsupportedNumbers() throws JSONException {
-        // when the array contains an unsupported number, toString returns null!
-        JSONArray array = new JSONArray(Arrays.asList(5.5, Double.NaN));
-        assertNull(array.toString());
-    }
-
-    @Test
-    public void testListConstructorCopiesContents() throws JSONException {
-        // have to use asList instead of Collections.singleton() to allow mutation
-        //noinspection ArraysAsListWithZeroOrOneArgument
-        List<Object> contents = Arrays.<Object>asList(5);
-        JSONArray array = new JSONArray(contents);
-        contents.set(0, 10);
-        assertEquals(5, array.get(0));
-    }
-
-    @Test
-    public void testTokenerConstructor() throws JSONException {
-        JSONArray object = new JSONArray(new JSONTokener("[false]"));
-        assertEquals(1, object.length());
-        assertEquals(false, object.get(0));
-    }
-
-    @Test
-    public void testTokenerConstructorWrongType() throws JSONException {
-        try {
-            new JSONArray(new JSONTokener("{\"foo\": false}"));
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testTokenerConstructorNull() throws JSONException {
-        try {
-            new JSONArray((JSONTokener) null);
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-    }
-
-    @Test
-    public void testTokenerConstructorParseFail() {
-        try {
-            new JSONArray(new JSONTokener("["));
-            fail();
-        } catch (JSONException ignored) {
-        } catch (StackOverflowError e) {
-            fail("Stack overflowed on input: \"[\"");
-        }
-    }
-
-    @Test
-    public void testStringConstructor() throws JSONException {
-        JSONArray object = new JSONArray("[false]");
-        assertEquals(1, object.length());
-        assertEquals(false, object.get(0));
-    }
-
-    @Test
-    public void testStringConstructorWrongType() throws JSONException {
-        try {
-            new JSONArray("{\"foo\": false}");
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testStringConstructorNull() throws JSONException {
-        try {
-            new JSONArray((String) null);
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-    }
-
-    @Test
-    public void testStringConstructorParseFail() {
-        try {
-            new JSONArray("[");
-            fail();
-        } catch (JSONException ignored) {
-        } catch (StackOverflowError e) {
-            fail("Stack overflowed on input: \"[\"");
-        }
-    }
-
-    @Test
-    public void testCreate() throws JSONException {
-        JSONArray array = new JSONArray(Arrays.asList(5.5, true));
-        assertEquals(2, array.length());
-        assertEquals(5.5, array.getDouble(0), 0.0);
-        assertEquals(true, array.get(1));
-        assertEquals("[5.5,true]", array.toString());
-    }
-
-    @Test
-    public void testAccessOutOfBounds() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put("foo");
-        assertEquals(null, array.opt(3));
-        assertEquals(null, array.opt(-3));
-        assertEquals("", array.optString(3));
-        assertEquals("", array.optString(-3));
-        try {
-            array.get(3);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            array.get(-3);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            array.getString(3);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            array.getString(-3);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void test_remove() throws Exception {
-        JSONArray a = new JSONArray();
-        assertEquals(null, a.remove(-1));
-        assertEquals(null, a.remove(0));
-
-        a.put("hello");
-        assertEquals(null, a.remove(-1));
-        assertEquals(null, a.remove(1));
-        assertEquals("hello", a.remove(0));
-        assertEquals(null, a.remove(0));
-    }
-
-    enum MyEnum { A, B, C }
-
-    // https://code.google.com/p/android/issues/detail?id=62539
-    // but changed in open-json to return toString for all enums
-    @Test
-    public void testEnums() throws Exception {
-        // This works because it's in java.* and any class in there falls back to toString.
-        JSONArray a1 = new JSONArray(java.lang.annotation.RetentionPolicy.values());
-        assertEquals("[\"SOURCE\",\"CLASS\",\"RUNTIME\"]", a1.toString());
-
-        // This doesn't because it's not.
-        JSONArray a2 = new JSONArray(MyEnum.values());
-        assertEquals("[\"A\",\"B\",\"C\"]", a2.toString());
-    }
+  @Test
+  public void testEmptyArray() throws JSONException {
+    JSONArray array = new JSONArray();
+    assertEquals(0, array.length());
+    assertEquals("", array.join(" AND "));
+    try {
+      array.get(0);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      array.getBoolean(0);
+      fail();
+    } catch (JSONException ignored) {
+    }
+
+    assertEquals("[]", array.toString());
+    assertEquals("[]", array.toString(4));
+
+    // out of bounds is co-opted with defaulting
+    assertTrue(array.isNull(0));
+    assertNull(array.opt(0));
+    assertFalse(array.optBoolean(0));
+    assertTrue(array.optBoolean(0, true));
+
+    // bogus (but documented) behaviour: returns null rather than an empty object!
+    assertNull(array.toJSONObject(new JSONArray()));
+  }
+
+  @Test
+  public void testEqualsAndHashCode() throws JSONException {
+    JSONArray a = new JSONArray();
+    JSONArray b = new JSONArray();
+    assertTrue(a.equals(b));
+    assertEquals("equals() not consistent with hashCode()", a.hashCode(), b.hashCode());
+
+    a.put(true);
+    a.put(false);
+    b.put(true);
+    b.put(false);
+    assertTrue(a.equals(b));
+    assertEquals(a.hashCode(), b.hashCode());
+
+    b.put(true);
+    assertFalse(a.equals(b));
+    assertTrue(a.hashCode() != b.hashCode());
+  }
+
+  @Test
+  public void testBooleans() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put(true);
+    array.put(false);
+    array.put(2, false);
+    array.put(3, false);
+    array.put(2, true);
+    assertEquals("[true,false,true,false]", array.toString());
+    assertEquals(4, array.length());
+    assertEquals(Boolean.TRUE, array.get(0));
+    assertEquals(Boolean.FALSE, array.get(1));
+    assertEquals(Boolean.TRUE, array.get(2));
+    assertEquals(Boolean.FALSE, array.get(3));
+    assertFalse(array.isNull(0));
+    assertFalse(array.isNull(1));
+    assertFalse(array.isNull(2));
+    assertFalse(array.isNull(3));
+    assertEquals(true, array.optBoolean(0));
+    assertEquals(false, array.optBoolean(1, true));
+    assertEquals(true, array.optBoolean(2, false));
+    assertEquals(false, array.optBoolean(3));
+    assertEquals("true", array.getString(0));
+    assertEquals("false", array.getString(1));
+    assertEquals("true", array.optString(2));
+    assertEquals("false", array.optString(3, "x"));
+    assertEquals("[\n     true,\n     false,\n     true,\n     false\n]", array.toString(5));
+
+    JSONArray other = new JSONArray();
+    other.put(true);
+    other.put(false);
+    other.put(true);
+    other.put(false);
+    assertTrue(array.equals(other));
+    other.put(true);
+    assertFalse(array.equals(other));
+
+    other = new JSONArray();
+    other.put("true");
+    other.put("false");
+    other.put("truE");
+    other.put("FALSE");
+    assertFalse(array.equals(other));
+    assertFalse(other.equals(array));
+    assertEquals(true, other.getBoolean(0));
+    assertEquals(false, other.optBoolean(1, true));
+    assertEquals(true, other.optBoolean(2));
+    assertEquals(false, other.getBoolean(3));
+  }
+
+  // http://code.google.com/p/android/issues/detail?id=16411
+  @Test
+  public void testCoerceStringToBoolean() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put("maybe");
+    try {
+      array.getBoolean(0);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals(false, array.optBoolean(0));
+    assertEquals(true, array.optBoolean(0, true));
+  }
+
+  @Test
+  public void testNulls() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put(3, null);
+    array.put(0, JSONObject.NULL);
+    assertEquals(4, array.length());
+    assertEquals("[null,null,null,null]", array.toString());
+
+    // there's 2 ways to represent null; each behaves differently!
+    assertEquals(JSONObject.NULL, array.get(0));
+    try {
+      array.get(1);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      array.get(2);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      array.get(3);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals(JSONObject.NULL, array.opt(0));
+    assertEquals(null, array.opt(1));
+    assertEquals(null, array.opt(2));
+    assertEquals(null, array.opt(3));
+    assertTrue(array.isNull(0));
+    assertTrue(array.isNull(1));
+    assertTrue(array.isNull(2));
+    assertTrue(array.isNull(3));
+    assertEquals("null", array.optString(0));
+    assertEquals("", array.optString(1));
+    assertEquals("", array.optString(2));
+    assertEquals("", array.optString(3));
+  }
+
+  /**
+   * Our behaviour is questioned by this bug: http://code.google.com/p/android/issues/detail?id=7257
+   */
+  @Test
+  public void testParseNullYieldsJSONObjectNull() throws JSONException {
+    JSONArray array = new JSONArray("[\"null\",null]");
+    array.put(null);
+    assertEquals("null", array.get(0));
+    assertEquals(JSONObject.NULL, array.get(1));
+    try {
+      array.get(2);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals("null", array.getString(0));
+    assertEquals("null", array.getString(1));
+    try {
+      array.getString(2);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testNumbers() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put(Double.MIN_VALUE);
+    array.put(9223372036854775806L);
+    array.put(Double.MAX_VALUE);
+    array.put(-0d);
+    assertEquals(4, array.length());
+
+    // toString() and getString(int) return different values for -0d
+    assertEquals("[4.9E-324,9223372036854775806,1.7976931348623157E308,-0]", array.toString());
+
+    assertEquals(Double.MIN_VALUE, array.get(0));
+    assertEquals(9223372036854775806L, array.get(1));
+    assertEquals(Double.MAX_VALUE, array.get(2));
+    assertEquals(-0d, array.get(3));
+    assertEquals(Double.MIN_VALUE, array.getDouble(0), 0);
+    assertEquals(9.223372036854776E18, array.getDouble(1), 0);
+    assertEquals(Double.MAX_VALUE, array.getDouble(2), 0);
+    assertEquals(-0d, array.getDouble(3), 0);
+    assertEquals(0, array.getLong(0));
+    assertEquals(9223372036854775806L, array.getLong(1));
+    assertEquals(Long.MAX_VALUE, array.getLong(2));
+    assertEquals(0, array.getLong(3));
+    assertEquals(0, array.getInt(0));
+    assertEquals(-2, array.getInt(1));
+    assertEquals(Integer.MAX_VALUE, array.getInt(2));
+    assertEquals(0, array.getInt(3));
+    assertEquals(Double.MIN_VALUE, array.opt(0));
+    assertEquals(Double.MIN_VALUE, array.optDouble(0), 0);
+    assertEquals(0, array.optLong(0, 1L));
+    assertEquals(0, array.optInt(0, 1));
+    assertEquals("4.9E-324", array.getString(0));
+    assertEquals("9223372036854775806", array.getString(1));
+    assertEquals("1.7976931348623157E308", array.getString(2));
+    assertEquals("-0.0", array.getString(3));
+
+    JSONArray other = new JSONArray();
+    other.put(Double.MIN_VALUE);
+    other.put(9223372036854775806L);
+    other.put(Double.MAX_VALUE);
+    other.put(-0d);
+    assertTrue(array.equals(other));
+    other.put(0, 0L);
+    assertFalse(array.equals(other));
+  }
+
+  @Test
+  public void testStrings() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put("true");
+    array.put("5.5");
+    array.put("9223372036854775806");
+    array.put("null");
+    array.put("5\"8' tall");
+    assertEquals(5, array.length());
+    assertEquals("[\"true\",\"5.5\",\"9223372036854775806\",\"null\",\"5\\\"8' tall\"]",
+        array.toString());
+
+    // although the documentation doesn't mention it, join() escapes text and wraps
+    // strings in quotes
+    assertEquals("\"true\" \"5.5\" \"9223372036854775806\" \"null\" \"5\\\"8' tall\"",
+        array.join(" "));
+
+    assertEquals("true", array.get(0));
+    assertEquals("null", array.getString(3));
+    assertEquals("5\"8' tall", array.getString(4));
+    assertEquals("true", array.opt(0));
+    assertEquals("5.5", array.optString(1));
+    assertEquals("9223372036854775806", array.optString(2, null));
+    assertEquals("null", array.optString(3, "-1"));
+    assertFalse(array.isNull(0));
+    assertFalse(array.isNull(3));
+
+    assertEquals(true, array.getBoolean(0));
+    assertEquals(true, array.optBoolean(0));
+    assertEquals(true, array.optBoolean(0, false));
+    assertEquals(0, array.optInt(0));
+    assertEquals(-2, array.optInt(0, -2));
+
+    assertEquals(5.5d, array.getDouble(1), 0);
+    assertEquals(5L, array.getLong(1));
+    assertEquals(5, array.getInt(1));
+    assertEquals(5, array.optInt(1, 3));
+
+    // The last digit of the string is a 6 but getLong returns a 7. It's probably parsing as a
+    // double and then converting that to a long. This is consistent with JavaScript.
+    assertEquals(9223372036854775807L, array.getLong(2));
+    assertEquals(9.223372036854776E18, array.getDouble(2), 0);
+    assertEquals(Integer.MAX_VALUE, array.getInt(2));
+
+    assertFalse(array.isNull(3));
+    try {
+      array.getDouble(3);
+      fail();
+    } catch (JSONException e) {
+      // expected
+    }
+    assertEquals(Double.NaN, array.optDouble(3), 0);
+    assertEquals(-1.0d, array.optDouble(3, -1.0d), 0);
+  }
+
+  @Test
+  public void testJoin() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put(null);
+    assertEquals("null", array.join(" & "));
+    array.put("\"");
+    assertEquals("null & \"\\\"\"", array.join(" & "));
+    array.put(5);
+    assertEquals("null & \"\\\"\" & 5", array.join(" & "));
+    array.put(true);
+    assertEquals("null & \"\\\"\" & 5 & true", array.join(" & "));
+    array.put(new JSONArray(Arrays.asList(true, false)));
+    assertEquals("null & \"\\\"\" & 5 & true & [true,false]", array.join(" & "));
+    array.put(new JSONObject(Collections.singletonMap("x", 6)));
+    assertEquals("null & \"\\\"\" & 5 & true & [true,false] & {\"x\":6}", array.join(" & "));
+  }
+
+  @Test
+  public void testJoinWithNull() throws JSONException {
+    JSONArray array = new JSONArray(Arrays.asList(5, 6));
+    assertEquals("5null6", array.join(null));
+  }
+
+  @Test
+  public void testJoinWithSpecialCharacters() throws JSONException {
+    JSONArray array = new JSONArray(Arrays.asList(5, 6));
+    assertEquals("5\"6", array.join("\""));
+  }
+
+  @Test
+  public void testToJSONObject() throws JSONException {
+    JSONArray keys = new JSONArray();
+    keys.put("a");
+    keys.put("b");
+
+    JSONArray values = new JSONArray();
+    values.put(5.5d);
+    values.put(false);
+
+    JSONObject object = values.toJSONObject(keys);
+    assertEquals(5.5d, object.get("a"));
+    assertEquals(false, object.get("b"));
+
+    keys.put(0, "a");
+    values.put(0, 11.0d);
+    assertEquals(5.5d, object.get("a"));
+  }
+
+  @Test
+  public void testToJSONObjectWithNulls() throws JSONException {
+    JSONArray keys = new JSONArray();
+    keys.put("a");
+    keys.put("b");
+
+    JSONArray values = new JSONArray();
+    values.put(5.5d);
+    values.put(null);
+
+    // null values are stripped!
+    JSONObject object = values.toJSONObject(keys);
+    assertEquals(1, object.length());
+    assertFalse(object.has("b"));
+    assertEquals("{\"a\":5.5}", object.toString());
+  }
+
+  @Test
+  public void testToJSONObjectMoreNamesThanValues() throws JSONException {
+    JSONArray keys = new JSONArray();
+    keys.put("a");
+    keys.put("b");
+    JSONArray values = new JSONArray();
+    values.put(5.5d);
+    JSONObject object = values.toJSONObject(keys);
+    assertEquals(1, object.length());
+    assertEquals(5.5d, object.get("a"));
+  }
+
+  @Test
+  public void testToJSONObjectMoreValuesThanNames() throws JSONException {
+    JSONArray keys = new JSONArray();
+    keys.put("a");
+    JSONArray values = new JSONArray();
+    values.put(5.5d);
+    values.put(11.0d);
+    JSONObject object = values.toJSONObject(keys);
+    assertEquals(1, object.length());
+    assertEquals(5.5d, object.get("a"));
+  }
+
+  @Test
+  public void testToJSONObjectNullKey() throws JSONException {
+    JSONArray keys = new JSONArray();
+    keys.put(JSONObject.NULL);
+    JSONArray values = new JSONArray();
+    values.put(5.5d);
+    JSONObject object = values.toJSONObject(keys);
+    assertEquals(1, object.length());
+    assertEquals(5.5d, object.get("null"));
+  }
+
+  @Test
+  public void testPutUnsupportedNumbers() throws JSONException {
+    JSONArray array = new JSONArray();
+
+    try {
+      array.put(Double.NaN);
+      fail();
+    } catch (JSONException e) {
+      // expected
+    }
+    try {
+      array.put(0, Double.NEGATIVE_INFINITY);
+      fail();
+    } catch (JSONException e) {
+      // expected
+    }
+    try {
+      array.put(0, Double.POSITIVE_INFINITY);
+      fail();
+    } catch (JSONException e) {
+      // expected
+    }
+  }
+
+  @Test
+  public void testPutUnsupportedNumbersAsObject() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put(Double.valueOf(Double.NaN));
+    array.put(Double.valueOf(Double.NEGATIVE_INFINITY));
+    array.put(Double.valueOf(Double.POSITIVE_INFINITY));
+    assertEquals(null, array.toString());
+  }
+
+  /**
+   * Although JSONArray is usually defensive about which numbers it accepts, it doesn't check inputs
+   * in its constructor.
+   */
+  @Test
+  public void testCreateWithUnsupportedNumbers() throws JSONException {
+    JSONArray array = new JSONArray(Arrays.asList(5.5, Double.NaN));
+    assertEquals(2, array.length());
+    assertEquals(5.5, array.getDouble(0), 0);
+    assertEquals(Double.NaN, array.getDouble(1), 0);
+  }
+
+  @Test
+  public void testToStringWithUnsupportedNumbers() throws JSONException {
+    // when the array contains an unsupported number, toString returns null!
+    JSONArray array = new JSONArray(Arrays.asList(5.5, Double.NaN));
+    assertNull(array.toString());
+  }
+
+  @Test
+  public void testListConstructorCopiesContents() throws JSONException {
+    // have to use asList instead of Collections.singleton() to allow mutation
+    // noinspection ArraysAsListWithZeroOrOneArgument
+    List<Object> contents = Arrays.<Object>asList(5);
+    JSONArray array = new JSONArray(contents);
+    contents.set(0, 10);
+    assertEquals(5, array.get(0));
+  }
+
+  @Test
+  public void testTokenerConstructor() throws JSONException {
+    JSONArray object = new JSONArray(new JSONTokener("[false]"));
+    assertEquals(1, object.length());
+    assertEquals(false, object.get(0));
+  }
+
+  @Test
+  public void testTokenerConstructorWrongType() throws JSONException {
+    try {
+      new JSONArray(new JSONTokener("{\"foo\": false}"));
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testTokenerConstructorNull() throws JSONException {
+    try {
+      new JSONArray((JSONTokener) null);
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+  }
+
+  @Test
+  public void testTokenerConstructorParseFail() {
+    try {
+      new JSONArray(new JSONTokener("["));
+      fail();
+    } catch (JSONException ignored) {
+    } catch (StackOverflowError e) {
+      fail("Stack overflowed on input: \"[\"");
+    }
+  }
+
+  @Test
+  public void testStringConstructor() throws JSONException {
+    JSONArray object = new JSONArray("[false]");
+    assertEquals(1, object.length());
+    assertEquals(false, object.get(0));
+  }
+
+  @Test
+  public void testStringConstructorWrongType() throws JSONException {
+    try {
+      new JSONArray("{\"foo\": false}");
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testStringConstructorNull() throws JSONException {
+    try {
+      new JSONArray((String) null);
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+  }
+
+  @Test
+  public void testStringConstructorParseFail() {
+    try {
+      new JSONArray("[");
+      fail();
+    } catch (JSONException ignored) {
+    } catch (StackOverflowError e) {
+      fail("Stack overflowed on input: \"[\"");
+    }
+  }
+
+  @Test
+  public void testCreate() throws JSONException {
+    JSONArray array = new JSONArray(Arrays.asList(5.5, true));
+    assertEquals(2, array.length());
+    assertEquals(5.5, array.getDouble(0), 0.0);
+    assertEquals(true, array.get(1));
+    assertEquals("[5.5,true]", array.toString());
+  }
+
+  @Test
+  public void testAccessOutOfBounds() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put("foo");
+    assertEquals(null, array.opt(3));
+    assertEquals(null, array.opt(-3));
+    assertEquals("", array.optString(3));
+    assertEquals("", array.optString(-3));
+    try {
+      array.get(3);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      array.get(-3);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      array.getString(3);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      array.getString(-3);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void test_remove() throws Exception {
+    JSONArray a = new JSONArray();
+    assertEquals(null, a.remove(-1));
+    assertEquals(null, a.remove(0));
+
+    a.put("hello");
+    assertEquals(null, a.remove(-1));
+    assertEquals(null, a.remove(1));
+    assertEquals("hello", a.remove(0));
+    assertEquals(null, a.remove(0));
+  }
+
+  enum MyEnum {
+    A, B, C
+  }
+
+  // https://code.google.com/p/android/issues/detail?id=62539
+  // but changed in open-json to return toString for all enums
+  @Test
+  public void testEnums() throws Exception {
+    // This works because it's in java.* and any class in there falls back to toString.
+    JSONArray a1 = new JSONArray(java.lang.annotation.RetentionPolicy.values());
+    assertEquals("[\"SOURCE\",\"CLASS\",\"RUNTIME\"]", a1.toString());
+
+    // This doesn't because it's not.
+    JSONArray a2 = new JSONArray(MyEnum.values());
+    assertEquals("[\"A\",\"B\",\"C\"]", a2.toString());
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/test/java/org/json/JSONFunctionTestObject.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONFunctionTestObject.java b/geode-json/src/test/java/org/json/JSONFunctionTestObject.java
index fe18ab6..9d24487 100755
--- a/geode-json/src/test/java/org/json/JSONFunctionTestObject.java
+++ b/geode-json/src/test/java/org/json/JSONFunctionTestObject.java
@@ -4,14 +4,14 @@ package org.json;
  * Class to test the function hack
  */
 public class JSONFunctionTestObject {
-    private String value;
+  private String value;
 
-    public JSONFunctionTestObject(String value) {
-        this.value = value;
-    }
+  public JSONFunctionTestObject(String value) {
+    this.value = value;
+  }
 
-    @Override
-    public String toString() {
-        return value;
-    }
-}
\ No newline at end of file
+  @Override
+  public String toString() {
+    return value;
+  }
+}


[24/51] [abbrv] geode git commit: GEODE-1995: Removed ReliableMessageQueue, ReliableMessageQueueFactory, ReliableMessageQueueFactoryImpl and it's usage in the code from GemfireCacheImpl and DistributedRegion.

Posted by ds...@apache.org.
GEODE-1995: Removed ReliableMessageQueue, ReliableMessageQueueFactory, ReliableMessageQueueFactoryImpl and
it's usage in the code from GemfireCacheImpl and DistributedRegion.

GEODE-1995: Addressing Review Comments.
  Removed ReliableDistributionData
  CacheOperationMessage does not required now to implement ReliableDistributionData, as it is removed
  Removed all reference of getOperations and getOperationCount
  AbstractRegion#handleReliableDistribution does not use ReliableDistributionData removed the same.
  Removed SendQueueOperation
  Removed sendQueue from DistributedRegion
  Cleanup LocalizedStrings
  Removed SEND_QUEUE_MESSAGE from DataSerializableFixedID and DSFIDFactory


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/5ec0d470
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/5ec0d470
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/5ec0d470

Branch: refs/heads/feature/GEM-1195
Commit: 5ec0d470f25ec4cb68dd7c5c31791eecb90b2548
Parents: b5fd6b5
Author: adongre <ad...@apache.org>
Authored: Tue Dec 13 12:50:31 2016 +0530
Committer: adongre <ad...@apache.org>
Committed: Tue Feb 28 12:35:38 2017 +0530

----------------------------------------------------------------------
 .../org/apache/geode/internal/DSFIDFactory.java |   2 -
 .../geode/internal/DataSerializableFixedID.java |   1 -
 .../geode/internal/cache/AbstractRegion.java    |   4 +-
 .../geode/internal/cache/DestroyOperation.java  |   6 -
 .../cache/DistributedCacheOperation.java        |  27 +-
 .../cache/DistributedPutAllOperation.java       |  27 --
 .../geode/internal/cache/DistributedRegion.java |  70 +-----
 .../cache/DistributedRemoveAllOperation.java    |  15 --
 .../geode/internal/cache/GemFireCacheImpl.java  |  27 --
 .../internal/cache/InvalidateOperation.java     |   8 -
 .../cache/ReliableDistributionData.java         |  41 ----
 .../internal/cache/ReliableMessageQueue.java    |  69 ------
 .../cache/ReliableMessageQueueFactory.java      |  41 ----
 .../cache/ReliableMessageQueueFactoryImpl.java  | 246 -------------------
 .../internal/cache/SendQueueOperation.java      | 190 --------------
 .../geode/internal/cache/TXCommitMessage.java   |  41 +---
 .../cache/UpdateEntryVersionOperation.java      |   6 -
 .../geode/internal/cache/UpdateOperation.java   |  13 -
 .../cache/wan/serial/BatchDestroyOperation.java |   7 -
 .../geode/internal/i18n/LocalizedStrings.java   |   6 -
 20 files changed, 9 insertions(+), 838 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java b/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java
index 5c18639..c02dc47 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/DSFIDFactory.java
@@ -251,7 +251,6 @@ import org.apache.geode.internal.cache.RemoteRegionOperation.RemoteRegionOperati
 import org.apache.geode.internal.cache.RemoteRemoveAllMessage;
 import org.apache.geode.internal.cache.RoleEventImpl;
 import org.apache.geode.internal.cache.SearchLoadAndWriteProcessor;
-import org.apache.geode.internal.cache.SendQueueOperation.SendQueueMessage;
 import org.apache.geode.internal.cache.ServerPingMessage;
 import org.apache.geode.internal.cache.StateFlushOperation.StateMarkerMessage;
 import org.apache.geode.internal.cache.StateFlushOperation.StateStabilizationMessage;
@@ -667,7 +666,6 @@ public final class DSFIDFactory implements DataSerializableFixedID {
     registerDSFID(CLEAR_REGION_MESSAGE, ClearRegionMessage.class);
     registerDSFID(TOMBSTONE_MESSAGE, TombstoneMessage.class);
     registerDSFID(INVALIDATE_REGION_MESSAGE, InvalidateRegionMessage.class);
-    registerDSFID(SEND_QUEUE_MESSAGE, SendQueueMessage.class);
     registerDSFID(STATE_MARKER_MESSAGE, StateMarkerMessage.class);
     registerDSFID(STATE_STABILIZATION_MESSAGE, StateStabilizationMessage.class);
     registerDSFID(STATE_STABILIZED_MESSAGE, StateStabilizedMessage.class);

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
index 4e45646..457af2f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
@@ -160,7 +160,6 @@ public interface DataSerializableFixedID extends SerializationVersions {
   public static final byte PUT_ALL_MESSAGE = -84;
   public static final byte CLEAR_REGION_MESSAGE = -83;
   public static final byte INVALIDATE_REGION_MESSAGE = -82;
-  public static final byte SEND_QUEUE_MESSAGE = -81;
   public static final byte STATE_MARKER_MESSAGE = -80;
   public static final byte STATE_STABILIZATION_MESSAGE = -79;
   public static final byte STATE_STABILIZED_MESSAGE = -78;

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java
index fe77578..7dffee2 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java
@@ -1719,15 +1719,13 @@ public abstract class AbstractRegion implements Region, RegionAttributes, Attrib
    * Makes sure that the data was distributed to every required role. If it was not it either queues
    * the data for later delivery or it throws an exception.
    *
-   * @param data the data that needs to be reliably distributed
    * @param successfulRecipients the successful recipients
    * @throws RoleException if a required role was not sent the message and the LossAction is either
    *         NO_ACCESS or LIMITED_ACCESS.
    * @since GemFire 5.0
    *
    */
-  protected void handleReliableDistribution(ReliableDistributionData data,
-      Set successfulRecipients) {
+  protected void handleReliableDistribution(Set successfulRecipients) {
     // do nothing by default
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/DestroyOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DestroyOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DestroyOperation.java
index a3d9376..5132ec0 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DestroyOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DestroyOperation.java
@@ -199,12 +199,6 @@ public class DestroyOperation extends DistributedCacheOperation {
     }
 
     @Override
-    public List getOperations() {
-      return Collections.singletonList(new QueuedOperation(getOperation(), this.key, null, null,
-          DistributedCacheOperation.DESERIALIZATION_POLICY_NONE, this.callbackArg));
-    }
-
-    @Override
     public ConflationKey getConflationKey() {
       if (!super.regionAllowsConflation || getProcessorId() != 0) {
         // if the publisher's region attributes do not support conflation

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java
index e4658b4..bded899 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java
@@ -365,13 +365,7 @@ public abstract class DistributedCacheOperation {
         if (!reliableOp || region.isNoDistributionOk()) {
           // nothing needs be done in this case
         } else {
-          // create the message so it can be passed to
-          // handleReliableDistribution
-          // for queuing
-          CacheOperationMessage msg = createMessage();
-          initMessage(msg, null);
-          msg.setRecipients(recipients); // it is going to no one
-          region.handleReliableDistribution(msg, Collections.EMPTY_SET);
+          region.handleReliableDistribution(Collections.EMPTY_SET);
         }
 
         /** compute local client routing before waiting for an ack only for a bucket */
@@ -625,7 +619,7 @@ public abstract class DistributedCacheOperation {
           if (departedMembers != null) {
             successfulRecips.removeAll(departedMembers);
           }
-          region.handleReliableDistribution(msg, successfulRecips);
+          region.handleReliableDistribution(successfulRecips);
         }
       }
 
@@ -864,7 +858,7 @@ public abstract class DistributedCacheOperation {
   }
 
   public static abstract class CacheOperationMessage extends SerialDistributionMessage
-      implements MessageWithReply, DirectReplyMessage, ReliableDistributionData, OldValueImporter {
+      implements MessageWithReply, DirectReplyMessage, OldValueImporter {
 
     protected final static short POSSIBLE_DUPLICATE_MASK = POS_DUP;
     protected final static short OLD_VALUE_MASK = DistributionMessage.UNRESERVED_FLAGS_START;
@@ -1482,21 +1476,6 @@ public abstract class DistributedCacheOperation {
       return this.directAck;
     }
 
-    // ////////////////////////////////////////////////////////////////////
-    // ReliableDistributionData methods
-    // ////////////////////////////////////////////////////////////////////
-
-    public int getOperationCount() {
-      return 1;
-    }
-
-    public List getOperations() {
-      byte noDeserialize = DistributedCacheOperation.DESERIALIZATION_POLICY_NONE;
-      QueuedOperation qOp =
-          new QueuedOperation(getOperation(), null, null, null, noDeserialize, this.callbackArg);
-      return Collections.singletonList(qOp);
-    }
-
     public void setSendDelta(boolean sendDelta) {
       this.sendDelta = sendDelta;
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedPutAllOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedPutAllOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedPutAllOperation.java
index 4082a29..61542c4 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedPutAllOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedPutAllOperation.java
@@ -1261,11 +1261,6 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation {
       return s;
     }
 
-    @Override
-    public int getOperationCount() {
-      return this.putAllDataSize;
-    }
-
     public ClientProxyMembershipID getContext() {
       return this.context;
     }
@@ -1274,27 +1269,5 @@ public class DistributedPutAllOperation extends AbstractUpdateOperation {
       return this.putAllData;
     }
 
-    @Override
-    public List getOperations() {
-      QueuedOperation[] ops = new QueuedOperation[getOperationCount()];
-      for (int i = 0; i < ops.length; i++) {
-        PutAllEntryData entry = this.putAllData[i];
-        byte[] valueBytes = null;
-        Object valueObj = null;
-        Object v = entry.getValue();
-        byte deserializationPolicy;
-        if (v instanceof CachedDeserializable) {
-          deserializationPolicy = DESERIALIZATION_POLICY_LAZY;
-          valueBytes = ((CachedDeserializable) v).getSerializedValue();
-        } else {
-          deserializationPolicy = DESERIALIZATION_POLICY_NONE;
-          valueBytes = (byte[]) v;
-        }
-
-        ops[i] = new QueuedOperation(entry.getOp(), entry.getKey(), valueBytes, valueObj,
-            deserializationPolicy, this.callbackArg);
-      }
-      return Arrays.asList(ops);
-    }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
index 1aaf6c3..cc6ccf7 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
@@ -110,13 +110,6 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
   private final boolean requiresReliabilityCheck;
 
   /**
-   * Provides a queue for reliable message delivery
-   * 
-   * @since GemFire 5.0
-   */
-  protected final ReliableMessageQueue rmq;
-
-  /**
    * Latch that is opened after initialization waits for required roles up to the
    * <a href="DistributedSystem#member-timeout">member-timeout </a>.
    */
@@ -183,18 +176,6 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
 
     this.requiresReliabilityCheck = setRequiresReliabilityCheck;
 
-    {
-      ReliableMessageQueue tmp = null;
-      if (this.requiresReliabilityCheck) {
-        // if
-        // (attrs.getMembershipAttributes().getLossAction().isAllAccessWithQueuing())
-        // {
-        // tmp = cache.getReliableMessageQueueFactory().create(this);
-        // }
-      }
-      this.rmq = tmp;
-    }
-
     if (internalRegionArgs.isUsedForPartitionedRegionBucket()) {
       this.persistenceAdvisor = internalRegionArgs.getPersistenceAdvisor();
     } else if (this.allowsPersistence()) {
@@ -567,14 +548,12 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
   }
 
   @Override
-  protected void handleReliableDistribution(ReliableDistributionData data,
-      Set successfulRecipients) {
-    handleReliableDistribution(data, successfulRecipients, Collections.EMPTY_SET,
-        Collections.EMPTY_SET);
+  protected void handleReliableDistribution(Set successfulRecipients) {
+    handleReliableDistribution(successfulRecipients, Collections.EMPTY_SET, Collections.EMPTY_SET);
   }
 
-  protected void handleReliableDistribution(ReliableDistributionData data, Set successfulRecipients,
-      Set otherRecipients1, Set otherRecipients2) {
+  protected void handleReliableDistribution(Set successfulRecipients, Set otherRecipients1,
+      Set otherRecipients2) {
     if (this.requiresReliabilityCheck) {
       MembershipAttributes ra = getMembershipAttributes();
       Set recipients = successfulRecipients;
@@ -2140,19 +2119,6 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
     return getSystem().getDistributionManager().getConfig();
   }
 
-  /**
-   * Sends a list of queued messages to members playing a specified role
-   * 
-   * @param list List of QueuedOperation instances to send. Any messages sent will be removed from
-   *        this list
-   * @param role the role that a recipient must be playing
-   * @return true if at least one message made it to at least one guy playing the role
-   */
-  boolean sendQueue(List list, Role role) {
-    SendQueueOperation op = new SendQueueOperation(getDistributionManager(), this, list, role);
-    return op.distribute();
-  }
-
   /*
    * @see SearchLoadAndWriteProcessor#initialize(LocalRegion, Object, Object)
    */
@@ -2521,10 +2487,6 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
             this.getFullPath()), ex);
       }
     }
-    if (this.rmq != null) {
-      this.rmq.close();
-    }
-
     // Fix for #48066 - make sure that region operations are completely
     // distributed to peers before destroying the region.
     long timeout = 1000L * getCache().getDistributedSystem().getConfig().getAckWaitThreshold();
@@ -2628,9 +2590,6 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
       logger.warn("postDestroyRegion: encountered cancellation", e);
     }
 
-    if (this.rmq != null && destroyDiskRegion) {
-      this.rmq.destroy();
-    }
   }
 
   @Override
@@ -3601,27 +3560,6 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
             newlyAcquiredRoles = new HashSet(missingRequiredRoles);
             newlyAcquiredRoles.retainAll(roles); // find the intersection
             if (!newlyAcquiredRoles.isEmpty()) {
-              if (DistributedRegion.this.rmq != null) {
-                Iterator it = newlyAcquiredRoles.iterator();
-                final DM dm = getDistributionManager();
-                while (it.hasNext()) {
-                  getCache().getCancelCriterion().checkCancelInProgress(null);
-                  final Role role = (Role) it.next();
-                  try {
-                    // do this in the waiting pool to make it async
-                    // @todo darrel/klund: add a single serial executor for
-                    // queue flush
-                    dm.getWaitingThreadPool().execute(new Runnable() {
-                      public void run() {
-                        DistributedRegion.this.rmq.roleReady(role);
-                      }
-                    });
-                    break;
-                  } catch (RejectedExecutionException ex) {
-                    throw ex;
-                  }
-                } // while
-              }
               missingRequiredRoles.removeAll(newlyAcquiredRoles);
               if (this.members == null && missingRequiredRoles.isEmpty()) {
                 isMissingRequiredRoles = false;

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRemoveAllOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRemoveAllOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRemoveAllOperation.java
index 4a86167..0c13b59 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRemoveAllOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRemoveAllOperation.java
@@ -1042,11 +1042,6 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
       return s;
     }
 
-    @Override
-    public int getOperationCount() {
-      return this.removeAllDataSize;
-    }
-
     public ClientProxyMembershipID getContext() {
       return this.context;
     }
@@ -1055,15 +1050,5 @@ public class DistributedRemoveAllOperation extends AbstractUpdateOperation // TO
       return this.removeAllData;
     }
 
-    @Override
-    public List getOperations() {
-      QueuedOperation[] ops = new QueuedOperation[getOperationCount()];
-      for (int i = 0; i < ops.length; i++) {
-        RemoveAllEntryData entry = this.removeAllData[i];
-        ops[i] = new QueuedOperation(entry.getOp(), entry.getKey(), null, null, (byte) 0,
-            this.callbackArg);
-      }
-      return Arrays.asList(ops);
-    }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 6e374ec..66f1a4a 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -878,8 +878,6 @@ public class GemFireCacheImpl
 
       this.cqService = CqServiceProvider.create(this);
 
-      this.rmqFactory = new ReliableMessageQueueFactoryImpl();
-
       // Create the CacheStatistics
       this.cachePerfStats = new CachePerfStats(system);
       CachePerfStats.enableClockStats = this.system.getConfig().getEnableTimeStatistics();
@@ -2327,17 +2325,6 @@ public class GemFireCacheImpl
           PoolManager.close(keepalive);
 
           if (isDebugEnabled) {
-            logger.debug("{}: closing reliable message queue...", this);
-          }
-          try {
-            getReliableMessageQueueFactory().close(true);
-          } catch (CancelException e) {
-            if (isDebugEnabled) {
-              logger.debug("Ignored cancellation while closing reliable message queue", e);
-            }
-          }
-
-          if (isDebugEnabled) {
             logger.debug("{}: notifying admins of close...", this);
           }
           try {
@@ -4497,22 +4484,8 @@ public class GemFireCacheImpl
     PoolManagerImpl.readyForEvents(this.system, false);
   }
 
-  /**
-   * This cache's reliable message queue factory. Should always have an instance of it.
-   */
-  private final ReliableMessageQueueFactory rmqFactory;
-
   private List<File> backupFiles = Collections.emptyList();
 
-  /**
-   * Returns this cache's ReliableMessageQueueFactory.
-   *
-   * @since GemFire 5.0
-   */
-  public ReliableMessageQueueFactory getReliableMessageQueueFactory() {
-    return this.rmqFactory;
-  }
-
   public InternalResourceManager getResourceManager() {
     return getResourceManager(true);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/InvalidateOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/InvalidateOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/InvalidateOperation.java
index d6d38ef..eceb194 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/InvalidateOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/InvalidateOperation.java
@@ -146,14 +146,6 @@ public class InvalidateOperation extends DistributedCacheOperation {
     }
 
     @Override
-    public List getOperations() {
-      byte deserializationPolicy = DistributedCacheOperation.DESERIALIZATION_POLICY_NONE;
-      QueuedOperation qOp = new QueuedOperation(getOperation(), this.key, null, null,
-          deserializationPolicy, this.callbackArg);
-      return Collections.singletonList(qOp);
-    }
-
-    @Override
     public ConflationKey getConflationKey() {
       if (!super.regionAllowsConflation || getProcessorId() != 0) {
         // if the publisher's region attributes do not support conflation

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableDistributionData.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableDistributionData.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableDistributionData.java
deleted file mode 100644
index 5c635ee..0000000
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableDistributionData.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 org.apache.geode.internal.cache;
-
-import java.util.*;
-
-/**
- * Represents one or more distributed operations that can be reliably distributed. This interface
- * allows the data to be queued and checked for reliable distribution.
- * 
- * @since GemFire 5.0
- */
-public interface ReliableDistributionData {
-  // /**
-  // * Returns a set of the recipients that this data was sent to successfully.
-  // * @param processor the reply processor used for responses to this data.
-  // */
-  // public Set getSuccessfulRecipients(ReliableReplyProcessor21 processor);
-  /**
-   * Returns the number of logical operations this data contains.
-   */
-  public int getOperationCount();
-
-  /**
-   * Returns a list of QueuedOperation instances one for each logical operation done by this data
-   * instance.
-   */
-  public List getOperations();
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueue.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueue.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueue.java
deleted file mode 100644
index 55c1039..0000000
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueue.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 org.apache.geode.internal.cache;
-
-import org.apache.geode.distributed.Role;
-
-import java.util.Set;
-
-/**
- * A reliable message queue is used by a DistributedRegion to queue up distributed operations for
- * required roles that are not present at the time the operation is done. Instances of this
- * interface can be obtained from {@link ReliableMessageQueueFactory} which can be obtained from
- * {@link GemFireCacheImpl#getReliableMessageQueueFactory}.
- * 
- * @since GemFire 5.0
- */
-public interface ReliableMessageQueue {
-  /**
-   * Returns the region this queue belongs to.
-   */
-  public DistributedRegion getRegion();
-
-  /**
-   * Adds a message to the queue to be sent to the list of roles.
-   * 
-   * @param data the actual data that describes the operation to enqueue
-   * @param roles the roles that need to receive this message.
-   */
-  public void add(ReliableDistributionData data, Set roles);
-
-  /**
-   * Gets the roles that this queue currently has messages for.
-   * 
-   * @return a set of {link Role}s that currently have queued messages. <code>null</code> is
-   *         returned if no messages are queued.
-   */
-  public Set getQueuingRoles();
-
-  /**
-   * Attempts to send any messages that have been added for the given role to all members that are
-   * currently playing that role.
-   * 
-   * @param role the role whose queued messages should be sent
-   * @return true if send was successful; false if it was not and the messages are still queued.
-   */
-  public boolean roleReady(Role role);
-
-  /**
-   * Removes all the data in this queue causing it to never be sent.
-   */
-  public void destroy();
-
-  /**
-   * Closes this queue. This frees up any memory used by the queue but its persistent data remains.
-   */
-  public void close();
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueueFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueueFactory.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueueFactory.java
deleted file mode 100644
index 39da937..0000000
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueueFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 org.apache.geode.internal.cache;
-
-/**
- * Represents a factory for instances of {@link ReliableMessageQueue}. The Cache will have an
- * instance of the factory that can be obtained from
- * {@link GemFireCacheImpl#getReliableMessageQueueFactory}.
- * 
- * @since GemFire 5.0
- */
-public interface ReliableMessageQueueFactory {
-  /**
-   * Creates an instance of {@link ReliableMessageQueue} given the region that the queue will be on.
-   * 
-   * @param region the distributed region that the created queue will service.
-   * @return the created queue
-   */
-  public ReliableMessageQueue create(DistributedRegion region);
-
-  /**
-   * Cleanly shutdown this factory flushing any persistent data to disk.
-   * 
-   * @param force true if close should always work
-   * @throws IllegalStateException if <code>force</code> is false and the factory is still in use.
-   *         The factory is in use as long as a queue it produced remains unclosed.
-   */
-  public void close(boolean force);
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueueFactoryImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueueFactoryImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueueFactoryImpl.java
deleted file mode 100644
index 282a0e1..0000000
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ReliableMessageQueueFactoryImpl.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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 org.apache.geode.internal.cache;
-
-import org.apache.geode.distributed.Role;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-
-import java.util.*;
-
-/**
- * Implementation of {@link ReliableMessageQueueFactory}
- * 
- * @since GemFire 5.0
- */
-public class ReliableMessageQueueFactoryImpl implements ReliableMessageQueueFactory {
-  private boolean closed;
-
-  /**
-   * Create a factory given its persistence attributes.
-   */
-  public ReliableMessageQueueFactoryImpl() {
-    this.closed = false;
-  }
-
-  /**
-   * Contains all the unclosed queues that have been created by this factory.
-   */
-  private final ArrayList queues = new ArrayList();
-
-  public ReliableMessageQueue create(DistributedRegion region) {
-    if (this.closed) {
-      throw new IllegalStateException(
-          LocalizedStrings.ReliableMessageQueueFactoryImpl_RELIABLE_MESSAGE_QUEUE_IS_CLOSED
-              .toLocalizedString());
-    }
-    synchronized (this.queues) {
-      Queue q = new Queue(region);
-      this.queues.add(q);
-      return q;
-    }
-  }
-
-  public void close(boolean force) {
-    // @todo darrel: nyi
-    if (!force) {
-      synchronized (this.queues) {
-        if (!this.queues.isEmpty()) {
-          throw new IllegalStateException(
-              LocalizedStrings.ReliableMessageQueueFactoryImpl_REGIONS_WITH_MESSAGE_QUEUING_ALREADY_EXIST
-                  .toLocalizedString());
-        }
-      }
-    }
-    this.closed = true;
-  }
-
-  /**
-   * Maps DistributedRegion keys to QueuedRegionData values
-   */
-  private final IdentityHashMap regionMap = new IdentityHashMap(128);
-
-  /**
-   * Adds data in the specified region to be sent to the specified roles
-   */
-  protected void add(DistributedRegion r, ReliableDistributionData data, Set roles) {
-    QueuedRegionData qrd = null;
-    synchronized (this.regionMap) {
-      qrd = (QueuedRegionData) this.regionMap.get(r);
-    }
-    qrd.add(r, data, roles);
-    r.getCachePerfStats().incReliableQueuedOps(data.getOperationCount() * roles.size());
-  }
-
-  public Set getQueuingRoles(DistributedRegion r) {
-    QueuedRegionData qrd = null;
-    synchronized (this.regionMap) {
-      qrd = (QueuedRegionData) this.regionMap.get(r);
-    }
-    return qrd.getQueuingRoles(r);
-  }
-
-  protected boolean roleReady(DistributedRegion r, Role role) {
-    QueuedRegionData qrd = null;
-    synchronized (this.regionMap) {
-      qrd = (QueuedRegionData) this.regionMap.get(r);
-    }
-    return qrd.roleReady(r, role);
-  }
-
-  /**
-   * Initializes data queuing for the given region
-   */
-  protected void init(DistributedRegion r) {
-    QueuedRegionData qrd = new QueuedRegionData();
-    synchronized (this.regionMap) {
-      Object old = this.regionMap.put(r, qrd);
-      if (old != null) {
-        throw new IllegalStateException(
-            LocalizedStrings.ReliableMessageQueueFactoryImpl_UNEXPECTED_QUEUEDREGIONDATA_0_FOR_REGION_1
-                .toLocalizedString(new Object[] {old, r}));
-      }
-    }
-  }
-
-  /**
-   * Removes any data queued for the given region
-   */
-  protected void destroy(DistributedRegion r) {
-    QueuedRegionData qrd = null;
-    synchronized (this.regionMap) {
-      qrd = (QueuedRegionData) this.regionMap.remove(r);
-    }
-    if (qrd != null) {
-      qrd.destroy(r);
-    }
-  }
-
-  /**
-   * Removes a previously created queue from this factory.
-   */
-  protected void removeQueue(Queue q) {
-    synchronized (this.queues) {
-      this.queues.remove(q);
-    }
-  }
-
-  /**
-   * Implements ReliableMessageQueue.
-   * 
-   * @since GemFire 5.0
-   */
-  public class Queue implements ReliableMessageQueue {
-    private final DistributedRegion r;
-
-    Queue(DistributedRegion r) {
-      this.r = r;
-      init(this.r);
-    }
-
-    public DistributedRegion getRegion() {
-      return this.r;
-    }
-
-    public void add(ReliableDistributionData data, Set roles) {
-      ReliableMessageQueueFactoryImpl.this.add(this.r, data, roles);
-    }
-
-    public Set getQueuingRoles() {
-      return ReliableMessageQueueFactoryImpl.this.getQueuingRoles(this.r);
-    }
-
-    public boolean roleReady(Role role) {
-      return ReliableMessageQueueFactoryImpl.this.roleReady(this.r, role);
-    }
-
-    public void destroy() {
-      ReliableMessageQueueFactoryImpl.this.destroy(this.r);
-    }
-
-    public void close() {
-      removeQueue(this);
-    }
-  }
-  /**
-   * Used to organize all the queued data for a region.
-   */
-  static protected class QueuedRegionData {
-    /**
-     * Maps Role keys to lists of ReliableDistributionData
-     */
-    private final HashMap roleMap = new HashMap();
-
-    /**
-     * Adds data in the specified region to be sent to the specified roles
-     */
-    protected void add(DistributedRegion r, ReliableDistributionData data, Set roles) {
-      synchronized (this) {
-        Iterator it = roles.iterator();
-        while (it.hasNext()) {
-          Role role = (Role) it.next();
-          List l = (List) this.roleMap.get(role);
-          if (l == null) {
-            l = new ArrayList();
-            this.roleMap.put(role, l);
-          }
-          l.addAll(data.getOperations());
-        }
-      }
-    }
-
-    protected Set getQueuingRoles(DistributedRegion r) {
-      Set result = null;
-      synchronized (this) {
-        Iterator it = this.roleMap.entrySet().iterator();
-        while (it.hasNext()) {
-          Map.Entry me = (Map.Entry) it.next();
-          List l = (List) me.getValue();
-          if (l != null && !l.isEmpty()) {
-            // found a role with a non-empty list of operations so add to result
-            if (result == null) {
-              result = new HashSet();
-            }
-            result.add(me.getKey());
-          }
-        }
-      }
-      return result;
-    }
-
-    protected boolean roleReady(DistributedRegion r, Role role) {
-      List l = null;
-      synchronized (this) {
-        l = (List) this.roleMap.get(role);
-      }
-      if (l != null) {
-        // @todo darrel: do this in a background thread
-        while (!l.isEmpty()) {
-          if (!r.sendQueue(l, role)) {
-            // Couldn't send the last message so stop and return false
-            return false;
-          }
-        }
-      }
-      return true;
-    }
-
-    /**
-     * Blows away all the data in this object.
-     */
-    public void destroy(DistributedRegion r) {
-      // @todo darrel: nothing needs doing until we use disk
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/SendQueueOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/SendQueueOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/SendQueueOperation.java
deleted file mode 100644
index a72dee9..0000000
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/SendQueueOperation.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * 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 org.apache.geode.internal.cache;
-
-import java.util.*;
-import java.io.*;
-import org.apache.geode.*;
-import org.apache.geode.cache.*;
-import org.apache.geode.distributed.*;
-import org.apache.geode.distributed.internal.*;
-
-
-/**
- * Sends a chunk of queued messages to everyone currently playing a role.
- *
- * @since GemFire 5.0
- *
- */
-public class SendQueueOperation {
-  // private ReplyProcessor21 processor = null;
-  private DM dm;
-  private DistributedRegion r;
-  private List l;
-  private Role role;
-
-  SendQueueOperation(DM dm, DistributedRegion r, List l, Role role) {
-    this.dm = dm;
-    this.r = r;
-    this.l = l;
-    this.role = role;
-  }
-
-  /**
-   * Returns true if distribution successful. Also modifies message list by removing messages sent
-   * to the required role.
-   */
-  boolean distribute() {
-    CacheDistributionAdvisor advisor = this.r.getCacheDistributionAdvisor();
-    Set recipients = advisor.adviseCacheOpRole(this.role);
-    if (recipients.isEmpty()) {
-      return false;
-    }
-    ReplyProcessor21 processor = new ReplyProcessor21(this.dm, recipients);
-    // @todo darrel: make this a reliable one
-    SendQueueMessage msg = new SendQueueMessage();
-    msg.setRecipients(recipients);
-    msg.setRegionPath(this.r.getFullPath());
-    msg.setProcessorId(processor.getProcessorId());
-    msg.setOperations(this.l);
-    dm.putOutgoing(msg);
-    try {
-      processor.waitForReplies();
-    } catch (InterruptedException ex) {
-      Thread.currentThread().interrupt();
-      // It's OK to keep going, no significant work below.
-    } catch (ReplyException ex) {
-      ex.handleAsUnexpected();
-    }
-    if (msg.getSuccessfulRecipients().isEmpty()) {
-      return false;
-    }
-    // @todo darrel: now remove sent items from the list
-    this.r.getCachePerfStats().incReliableQueuedOps(-l.size());
-    this.l.clear();
-    return true;
-  }
-
-  /**
-   * A batch of queued messages. Once they are processed on the other side an ack is sent.
-   */
-  public static final class SendQueueMessage extends SerialDistributionMessage
-      implements MessageWithReply {
-    private int processorId;
-    private String regionPath;
-    /**
-     * List of QueuedOperation instances
-     */
-    private List ops;
-
-    @Override
-    public int getProcessorId() {
-      return this.processorId;
-    }
-
-    public void setProcessorId(int id) {
-      this.processorId = id;
-    }
-
-    public String getRegionPath() {
-      return this.regionPath;
-    }
-
-    public void setRegionPath(String rp) {
-      this.regionPath = rp;
-    }
-
-    public void setOperations(List l) {
-      this.ops = l;
-    }
-
-    @Override
-    protected void process(DistributionManager dm) {
-      ReplyException rex = null;
-      boolean ignored = false;
-      try {
-        GemFireCacheImpl gfc = (GemFireCacheImpl) CacheFactory.getInstance(dm.getSystem());
-        final LocalRegion lclRgn = gfc.getRegionByPathForProcessing(this.regionPath);
-        if (lclRgn != null) {
-          lclRgn.waitOnInitialization();
-          final long lastMod = gfc.cacheTimeMillis();
-          Iterator it = this.ops.iterator();
-          while (it.hasNext()) {
-            QueuedOperation op = (QueuedOperation) it.next();
-            op.process(lclRgn, getSender(), lastMod);
-          }
-        } else {
-          ignored = true;
-        }
-      } catch (RegionDestroyedException e) {
-        ignored = true;
-      } catch (CancelException e) {
-        ignored = true;
-      } finally {
-        ReplyMessage.send(getSender(), this.processorId, rex, dm, ignored, false, false);
-      }
-    }
-
-    public int getDSFID() {
-      return SEND_QUEUE_MESSAGE;
-    }
-
-    @Override
-    public void fromData(DataInput in) throws IOException, ClassNotFoundException {
-      super.fromData(in);
-      this.regionPath = DataSerializer.readString(in);
-      this.processorId = in.readInt();
-      {
-        int opCount = in.readInt();
-        QueuedOperation[] ops = new QueuedOperation[opCount];
-        for (int i = 0; i < opCount; i++) {
-          ops[i] = QueuedOperation.createFromData(in);
-        }
-        this.ops = Arrays.asList(ops);
-      }
-    }
-
-    @Override
-    public void toData(DataOutput out) throws IOException {
-      super.toData(out);
-      DataSerializer.writeString(this.regionPath, out);
-      out.writeInt(this.processorId);
-      {
-        int opCount = this.ops.size();
-        out.writeInt(opCount);
-        for (int i = 0; i < opCount; i++) {
-          QueuedOperation op = (QueuedOperation) this.ops.get(i);
-          op.toData(out);
-        }
-      }
-    }
-
-    @Override
-    public String toString() {
-      StringBuffer buff = new StringBuffer();
-      buff.append(getClass().getName());
-      buff.append("(region path='"); // make sure this is the first one
-      buff.append(this.regionPath);
-      buff.append("'");
-      buff.append("; processorId=");
-      buff.append(this.processorId);
-      buff.append("; queuedOps=");
-      buff.append(this.ops.size());
-      buff.append(")");
-      return buff.toString();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java
index e325bf1..7c2a3e3 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java
@@ -526,19 +526,7 @@ public class TXCommitMessage extends PooledDistributionMessage
       successfulRecipients.removeAll(regionDestroyedMembers);
 
       try {
-        ReliableDistributionData rdd = new ReliableDistributionData() {
-          // public Set getSuccessfulRecipients(ReliableReplyProcessor21 processor) {
-          // return successfulRecipients;
-          // }
-          public int getOperationCount() {
-            return rc.getOperationCount();
-          }
-
-          public List getOperations() {
-            return rc.getOperations();
-          }
-        };
-        rc.r.handleReliableDistribution(rdd, successfulRecipients);
+        rc.r.handleReliableDistribution(successfulRecipients);
       } catch (RegionDistributionException e) {
         if (regionDistributionExceptions == Collections.EMPTY_SET) {
           regionDistributionExceptions = new HashSet();
@@ -1408,19 +1396,6 @@ public class TXCommitMessage extends PooledDistributionMessage
       return this.opKeys == null;
     }
 
-    /**
-     * Returns the number of operations this region commit will do
-     * 
-     * @since GemFire 5.0
-     */
-    int getOperationCount() {
-      int result = 0;
-      if (!isEmpty()) {
-        result = this.opKeys.size();
-      }
-      return result;
-    }
-
     boolean needsAck() {
       return this.r.getScope().isDistributedAck();
     }
@@ -1481,20 +1456,6 @@ public class TXCommitMessage extends PooledDistributionMessage
       return result.toString();
     }
 
-    /**
-     * Returns a list of QueuedOperation instances for reliable distribution
-     * 
-     * @since GemFire 5.0
-     */
-    List getOperations() {
-      QueuedOperation[] ops = new QueuedOperation[getOperationCount()];
-      for (int i = 0; i < ops.length; i++) {
-        TXEntryState es = (TXEntryState) this.opEntries.get(i);
-        ops[i] = es.toFarSideQueuedOp(this.opKeys.get(i));
-      }
-      return Arrays.asList(ops);
-    }
-
     private void basicToData(DataOutput out) throws IOException {
       if (this.r != null) {
         DataSerializer.writeString(this.r.getFullPath(), out);

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateEntryVersionOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateEntryVersionOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateEntryVersionOperation.java
index f534a6e..f82f0ce 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateEntryVersionOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateEntryVersionOperation.java
@@ -104,12 +104,6 @@ public class UpdateEntryVersionOperation extends DistributedCacheOperation {
     }
 
     @Override
-    public List getOperations() {
-      return Collections.singletonList(new QueuedOperation(getOperation(), this.key, null, null,
-          DistributedCacheOperation.DESERIALIZATION_POLICY_NONE, this.callbackArg));
-    }
-
-    @Override
     protected void appendFields(StringBuilder buff) {
       super.appendFields(buff);
       buff.append("; key=");

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateOperation.java
index 09ce587..1afae86 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/UpdateOperation.java
@@ -445,19 +445,6 @@ public class UpdateOperation extends AbstractUpdateOperation {
       }
     }
 
-    @Override
-    public List getOperations() {
-      byte[] valueBytes = null;
-      Object valueObj = null;
-      if (this.newValueObj != null) {
-        valueBytes = EntryEventImpl.serialize(this.newValueObj);
-      } else {
-        valueBytes = this.newValue;
-      }
-      return Collections.singletonList(new QueuedOperation(getOperation(), this.key, valueBytes,
-          valueObj, this.deserializationPolicy, this.callbackArg));
-    }
-
     public boolean hasBridgeContext() {
       if (this.event != null) {
         return this.event.getContext() != null;

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java
index 5da18a8..a368b60 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java
@@ -37,7 +37,6 @@ import org.apache.geode.internal.cache.DistributedRegion;
 import org.apache.geode.internal.cache.EntryEventImpl;
 import org.apache.geode.internal.cache.EventID;
 import org.apache.geode.internal.cache.InternalCacheEvent;
-import org.apache.geode.internal.cache.QueuedOperation;
 import org.apache.geode.internal.cache.RegionQueue;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
@@ -210,12 +209,6 @@ public class BatchDestroyOperation extends DistributedCacheOperation {
     }
 
     @Override
-    public List getOperations() {
-      return Collections.singletonList(new QueuedOperation(getOperation(), this.key, null, null,
-          DistributedCacheOperation.DESERIALIZATION_POLICY_NONE, this.callbackArg));
-    }
-
-    @Override
     public ConflationKey getConflationKey() {
       if (!super.regionAllowsConflation || getProcessorId() != 0) {
         // if the publisher's region attributes do not support conflation

http://git-wip-us.apache.org/repos/asf/geode/blob/5ec0d470/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
index fa63437..47ae0c5 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
@@ -3604,12 +3604,6 @@ public class LocalizedStrings {
   public static final StringId RegisterInterest_CACHECLIENTPROXY_FOR_THIS_CLIENT_IS_NO_LONGER_ON_THE_SERVER_SO_REGISTERINTEREST_OPERATION_IS_UNSUCCESSFUL =
       new StringId(3176,
           "CacheClientProxy for this client is no longer on the server , so registerInterest operation is unsuccessful");
-  public static final StringId ReliableMessageQueueFactoryImpl_REGIONS_WITH_MESSAGE_QUEUING_ALREADY_EXIST =
-      new StringId(3177, "Regions with message queuing already exist");
-  public static final StringId ReliableMessageQueueFactoryImpl_RELIABLE_MESSAGE_QUEUE_IS_CLOSED =
-      new StringId(3178, "reliable message queue is closed");
-  public static final StringId ReliableMessageQueueFactoryImpl_UNEXPECTED_QUEUEDREGIONDATA_0_FOR_REGION_1 =
-      new StringId(3179, "unexpected QueuedRegionData  {0}  for region  {1}");
   public static final StringId RemoteBridgeServer_A_REMOTE_BRIDGESERVER_CANNOT_BE_STARTED =
       new StringId(3180, "A remote BridgeServer cannot be started.");
   public static final StringId RemoteBridgeServer_A_REMOTE_BRIDGESERVER_CANNOT_BE_STOPPED =


[19/51] [abbrv] geode git commit: GEODE-2515: Disabling BaseLineAndCompareQueryPerfJUnitTest

Posted by ds...@apache.org.
GEODE-2515: Disabling BaseLineAndCompareQueryPerfJUnitTest

This is a performance test, it should not be run as part of precheckin.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/8ff2fd40
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/8ff2fd40
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/8ff2fd40

Branch: refs/heads/feature/GEM-1195
Commit: 8ff2fd4017ade81510e7705bf0f3254154a8805d
Parents: f2262d1
Author: Dan Smith <up...@apache.org>
Authored: Fri Feb 24 17:09:29 2017 -0800
Committer: Dan Smith <up...@apache.org>
Committed: Mon Feb 27 08:59:50 2017 -0800

----------------------------------------------------------------------
 .../geode/cache/query/BaseLineAndCompareQueryPerfJUnitTest.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/8ff2fd40/geode-core/src/test/java/org/apache/geode/cache/query/BaseLineAndCompareQueryPerfJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/BaseLineAndCompareQueryPerfJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/BaseLineAndCompareQueryPerfJUnitTest.java
index 50a57c4..a46e1c4 100755
--- a/geode-core/src/test/java/org/apache/geode/cache/query/BaseLineAndCompareQueryPerfJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/BaseLineAndCompareQueryPerfJUnitTest.java
@@ -29,15 +29,18 @@ import org.apache.geode.test.junit.categories.IntegrationTest;
 import java.util.*;
 import java.io.*;
 
+import org.apache.geode.test.junit.categories.PerformanceTest;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 /**
  * This test is to baseline and compare the performance figures for index usage benchmarks.
  */
-@Category(IntegrationTest.class)
+@Category(PerformanceTest.class)
+@Ignore("Performance tests should not be run as part of precheckin")
 public class BaseLineAndCompareQueryPerfJUnitTest {
 
   /** Creates a new instance of BaseLineAndCompareQueryPerfJUnitTest */


[47/51] [abbrv] geode git commit: GEODE-2488: Remove lsof from netstat command tests

Posted by ds...@apache.org.
GEODE-2488: Remove lsof from netstat command tests

Removed the --with-lsof option from netstat command to reduce the
command response size. Avoids OOME's on JVMs in the test environment
with small heaps.

The original tests with lsof have been retained, but annotated with
@Ignore.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/6118d54c
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/6118d54c
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/6118d54c

Branch: refs/heads/feature/GEM-1195
Commit: 6118d54c88401d52a9cd829252349a62e84a8afb
Parents: 9766cf2
Author: Ken Howe <kh...@pivotal.io>
Authored: Thu Mar 2 09:40:55 2017 -0800
Committer: Ken Howe <kh...@pivotal.io>
Committed: Thu Mar 2 13:52:26 2017 -0800

----------------------------------------------------------------------
 .../internal/cli/NetstatDUnitTest.java          | 26 +++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6118d54c/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
index c6248e0..e987fc2 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
@@ -24,6 +24,7 @@ import org.apache.geode.test.junit.categories.FlakyTest;
 import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -40,6 +41,7 @@ public class NetstatDUnitTest {
   private static int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
 
   private static String netStatCommand = null;
+  private static String netStatLsofCommand = null;
 
   @BeforeClass
   public static void beforeClass() throws Exception {
@@ -67,7 +69,8 @@ public class NetstatDUnitTest {
     // start another server
     lsRule.startServerVM(3, properties);
 
-    netStatCommand = "netstat --with-lsof=true --member=" + server.getName();
+    netStatCommand = "netstat --with-lsof=false --member=" + server.getName();
+    netStatLsofCommand = "netstat --with-lsof=true --member=" + server.getName();
   }
 
   @Test
@@ -88,6 +91,27 @@ public class NetstatDUnitTest {
     gfshConnector.executeAndVerifyCommand(netStatCommand);
   }
 
+  @Ignore
+  @Test
+  public void testConnectToLocatorWithLargeCommandResponse() throws Exception {
+    gfshConnector.connect(ports[0], GfshShellConnectionRule.PortType.locator);
+    gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+  }
+
+  @Ignore
+  @Test
+  public void testConnectToJmxManagerOneWithLargeCommandResponse() throws Exception {
+    gfshConnector.connect(ports[1], GfshShellConnectionRule.PortType.jmxManger);
+    gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+  }
+
+  @Ignore
+  @Test
+  public void testConnectToJmxManagerTwoWithLargeCommandResponse() throws Exception {
+    gfshConnector.connect(ports[2], GfshShellConnectionRule.PortType.jmxManger);
+    gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+  }
+
   @After
   public void after() throws Exception {
     gfshConnector.disconnect();


[22/51] [abbrv] geode git commit: GEODE-2538: Don't invoke a cache loader when fetching values for a lucene query

Posted by ds...@apache.org.
GEODE-2538: Don't invoke a cache loader when fetching values for a lucene query

Instead of using getAll, fetch the values of a lucene query using a
function that calls getEntry. We can then avoid invoking the cache
loader.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/712d87f7
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/712d87f7
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/712d87f7

Branch: refs/heads/feature/GEM-1195
Commit: 712d87f791906cbd1c11dd0f4655032dabf57755
Parents: 11521a8
Author: Dan Smith <up...@apache.org>
Authored: Mon Feb 27 14:21:58 2017 -0800
Committer: Dan Smith <up...@apache.org>
Committed: Mon Feb 27 14:26:15 2017 -0800

----------------------------------------------------------------------
 .../cache/lucene/internal/LuceneQueryImpl.java  |  5 +
 .../lucene/internal/LuceneServiceImpl.java      |  2 +
 .../PageableLuceneQueryResultsImpl.java         | 23 ++++-
 .../internal/results/LuceneGetPageFunction.java | 96 ++++++++++++++++++++
 .../internal/results/MapResultCollector.java    | 55 +++++++++++
 .../lucene/LuceneQueriesIntegrationTest.java    | 41 +++++++++
 .../geode/cache/lucene/PaginationDUnitTest.java |  7 +-
 .../internal/LuceneQueryImplJUnitTest.java      | 54 +++++++----
 ...PageableLuceneQueryResultsImplJUnitTest.java | 39 +++++++-
 .../results/LuceneGetPageFunctionJUnitTest.java | 59 ++++++++++++
 10 files changed, 351 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
index de622e0..1ece774 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
@@ -93,6 +93,11 @@ public class LuceneQueryImpl<K, V> implements LuceneQuery<K, V> {
 
   private PageableLuceneQueryResults<K, V> findPages(int pageSize) throws LuceneQueryException {
     TopEntries<K> entries = findTopEntries();
+    return newPageableResults(pageSize, entries);
+  }
+
+  protected PageableLuceneQueryResults<K, V> newPageableResults(final int pageSize,
+      final TopEntries<K> entries) {
     return new PageableLuceneQueryResultsImpl<K, V>(entries.getHits(), region, pageSize);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index a608dd9..dd32000 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -21,6 +21,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.geode.cache.lucene.internal.distributed.LuceneQueryFunction;
 import org.apache.geode.cache.lucene.internal.management.LuceneServiceMBean;
 import org.apache.geode.cache.lucene.internal.management.ManagementIndexListener;
+import org.apache.geode.cache.lucene.internal.results.LuceneGetPageFunction;
 import org.apache.geode.management.internal.beans.CacheServiceMBeanBase;
 import org.apache.logging.log4j.Logger;
 import org.apache.lucene.analysis.Analyzer;
@@ -89,6 +90,7 @@ public class LuceneServiceImpl implements InternalLuceneService {
     this.cache = gfc;
 
     FunctionService.registerFunction(new LuceneQueryFunction());
+    FunctionService.registerFunction(new LuceneGetPageFunction());
     FunctionService.registerFunction(new WaitUntilFlushedFunction());
     FunctionService.registerFunction(new DumpDirectoryFiles());
     registerDataSerializables();

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImpl.java
index 5c5d825..8db98a5 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImpl.java
@@ -17,14 +17,21 @@ package org.apache.geode.cache.lucene.internal;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Set;
 
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache.execute.Execution;
+import org.apache.geode.cache.execute.FunctionService;
+import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.lucene.PageableLuceneQueryResults;
 import org.apache.geode.cache.lucene.LuceneResultStruct;
 import org.apache.geode.cache.lucene.internal.distributed.EntryScore;
+import org.apache.geode.cache.lucene.internal.results.LuceneGetPageFunction;
+import org.apache.geode.cache.lucene.internal.results.MapResultCollector;
 
 /**
  * Implementation of PageableLuceneQueryResults that fetchs a page at a time from the server, given
@@ -74,15 +81,15 @@ public class PageableLuceneQueryResultsImpl<K, V> implements PageableLuceneQuery
 
   public List<LuceneResultStruct<K, V>> getHitEntries(int fromIndex, int toIndex) {
     List<EntryScore<K>> scores = hits.subList(fromIndex, toIndex);
-    ArrayList<K> keys = new ArrayList<K>(scores.size());
+    Set<K> keys = new HashSet<K>(scores.size());
     for (EntryScore<K> score : scores) {
       keys.add(score.getKey());
     }
 
-    Map<K, V> values = userRegion.getAll(keys);
+    Map<K, V> values = getValues(keys);
 
     ArrayList<LuceneResultStruct<K, V>> results =
-        new ArrayList<LuceneResultStruct<K, V>>(scores.size());
+        new ArrayList<LuceneResultStruct<K, V>>(values.size());
     for (EntryScore<K> score : scores) {
       V value = values.get(score.getKey());
       if (value != null)
@@ -91,6 +98,16 @@ public class PageableLuceneQueryResultsImpl<K, V> implements PageableLuceneQuery
     return results;
   }
 
+  protected Map<K, V> getValues(final Set<K> keys) {
+    ResultCollector resultCollector = onRegion().withFilter(keys)
+        .withCollector(new MapResultCollector()).execute(LuceneGetPageFunction.ID);
+    return (Map<K, V>) resultCollector.getResult();
+  }
+
+  protected Execution onRegion() {
+    return FunctionService.onRegion(userRegion);
+  }
+
   @Override
   public List<LuceneResultStruct<K, V>> next() {
     if (!hasNext()) {

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java
new file mode 100644
index 0000000..f5c2b99
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java
@@ -0,0 +1,96 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.results;
+
+import org.apache.geode.cache.EntryDestroyedException;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Region.Entry;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.RegionFunctionContext;
+import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.cache.lucene.LuceneQueryException;
+import org.apache.geode.cache.lucene.LuceneQueryProvider;
+import org.apache.geode.cache.lucene.LuceneService;
+import org.apache.geode.cache.lucene.LuceneServiceProvider;
+import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
+import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
+import org.apache.geode.cache.lucene.internal.distributed.CollectorManager;
+import org.apache.geode.cache.lucene.internal.distributed.LuceneFunctionContext;
+import org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollector;
+import org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollectorManager;
+import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
+import org.apache.geode.cache.lucene.internal.repository.IndexResultCollector;
+import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
+import org.apache.geode.cache.partition.PartitionRegionHelper;
+import org.apache.geode.internal.InternalEntity;
+import org.apache.geode.internal.cache.BucketNotFoundException;
+import org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.logging.log4j.Logger;
+import org.apache.lucene.search.Query;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * {@link LuceneGetPageFunction} Returns the values of entries back to the user This behaves
+ * basically like a getAll, but it does not invoke a cache loader
+ */
+public class LuceneGetPageFunction implements Function, InternalEntity {
+  private static final long serialVersionUID = 1L;
+  public static final String ID = LuceneGetPageFunction.class.getName();
+
+  private static final Logger logger = LogService.getLogger();
+
+  @Override
+  public void execute(FunctionContext context) {
+    RegionFunctionContext ctx = (RegionFunctionContext) context;
+    Region region = PartitionRegionHelper.getLocalDataForContext(ctx);
+    Set<?> keys = ctx.getFilter();
+
+    Map<Object, Object> results = new HashMap<>(keys.size());
+
+    for (Object key : keys) {
+      final Entry entry = region.getEntry(key);
+      try {
+        Object value = entry == null ? null : entry.getValue();
+        if (value != null) {
+          results.put(key, value);
+        }
+      } catch (EntryDestroyedException e) {
+        // skip
+      }
+    }
+    ctx.getResultSender().lastResult(results);
+  }
+
+
+  @Override
+  public String getId() {
+    return ID;
+  }
+
+  @Override
+  public boolean optimizeForWrite() {
+    return false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java
new file mode 100644
index 0000000..9264126
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java
@@ -0,0 +1,55 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.results;
+
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+public class MapResultCollector implements ResultCollector<Map<?, ?>, Map<Object, Object>> {
+  private final Map<Object, Object> results = new HashMap<>();
+
+  @Override
+  public Map<Object, Object> getResult() throws FunctionException {
+    return results;
+  }
+
+  @Override
+  public Map<Object, Object> getResult(final long timeout, final TimeUnit unit)
+      throws FunctionException, InterruptedException {
+    return results;
+  }
+
+  @Override
+  public void addResult(final DistributedMember memberID, final Map<?, ?> resultOfSingleExecution) {
+    this.results.putAll(resultOfSingleExecution);
+
+  }
+
+  @Override
+  public void endResults() {
+
+  }
+
+  @Override
+  public void clearResults() {
+    results.clear();
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
index 01bdca4..6420307 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
@@ -29,6 +29,9 @@ import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
+import org.apache.geode.cache.CacheLoader;
+import org.apache.geode.cache.CacheLoaderException;
+import org.apache.geode.cache.LoaderHelper;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.Tokenizer;
@@ -363,6 +366,44 @@ public class LuceneQueriesIntegrationTest extends LuceneIntegrationTest {
   }
 
   @Test
+  public void shouldReturnCorrectResultsOnDeletionAfterQueryExecutionWithLoader() throws Exception {
+    final int pageSize = 2;
+    final LuceneQuery<Object, Object> query = addValuesAndCreateQuery(pageSize);
+    region.getAttributesMutator().setCacheLoader(new CacheLoader() {
+      @Override
+      public Object load(final LoaderHelper helper) throws CacheLoaderException {
+        return new TestObject("should not", "load this");
+      }
+
+      @Override
+      public void close() {
+
+      }
+    });
+    final PageableLuceneQueryResults<Object, Object> pages = query.findPages();
+    List<LuceneResultStruct<Object, Object>> allEntries = new ArrayList<>();
+    assertTrue(pages.hasNext());
+    assertEquals(7, pages.size());
+    // Destroying an entry from the region after the query is executed.
+    region.destroy("C");
+    final List<LuceneResultStruct<Object, Object>> page1 = pages.next();
+    assertEquals(pageSize, page1.size());
+    final List<LuceneResultStruct<Object, Object>> page2 = pages.next();
+    assertEquals(pageSize, page2.size());
+    final List<LuceneResultStruct<Object, Object>> page3 = pages.next();
+    assertEquals(pageSize, page3.size());
+    assertFalse(pages.hasNext());
+
+    allEntries.addAll(page1);
+    allEntries.addAll(page2);
+    allEntries.addAll(page3);
+    assertEquals(region.keySet(),
+        allEntries.stream().map(entry -> entry.getKey()).collect(Collectors.toSet()));
+    assertEquals(region.values(),
+        allEntries.stream().map(entry -> entry.getValue()).collect(Collectors.toSet()));
+  }
+
+  @Test
   public void shouldReturnCorrectResultsOnMultipleDeletionsAfterQueryExecution() throws Exception {
     final LuceneQuery<Object, Object> query = addValuesAndCreateQuery(2);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/test/java/org/apache/geode/cache/lucene/PaginationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/PaginationDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/PaginationDUnitTest.java
index de71c08..3ff86f7 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/PaginationDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/PaginationDUnitTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.PartitionedRegionStorageException;
 import org.apache.geode.cache.Region;
 import org.apache.geode.test.dunit.Assert;
 import org.apache.geode.test.dunit.SerializableRunnableIF;
@@ -59,7 +60,7 @@ public class PaginationDUnitTest extends LuceneQueriesAccessorBase {
 
   @Test
   @Parameters(method = "getListOfRegionTestTypes")
-  public void noSuchElementExceptionWhenAllDataStoreAreClosedWhilePagination(
+  public void partitionedRegionStorageExceptionWhenAllDataStoreAreClosedWhilePagination(
       RegionTestableType regionTestType) {
     SerializableRunnableIF createIndex = () -> {
       LuceneService luceneService = LuceneServiceProvider.get(getCache());
@@ -90,8 +91,8 @@ public class PaginationDUnitTest extends LuceneQueriesAccessorBase {
         fail();
       } catch (Exception e) {
         Assert.assertEquals(
-            "Expected Exception = java.util.NoSuchElementException but hit " + e.toString(), true,
-            e instanceof java.util.NoSuchElementException);
+            "Expected Exception = PartitionedRegionStorageException but hit " + e.toString(), true,
+            e instanceof PartitionedRegionStorageException);
       }
     });
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
index ca439fe..20f5d1d 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
@@ -16,35 +16,38 @@
 package org.apache.geode.cache.lucene.internal;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.geode.cache.lucene.internal.distributed.LuceneQueryFunction;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.ArgumentCaptor;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.lucene.LuceneQueryException;
 import org.apache.geode.cache.lucene.LuceneQueryProvider;
-import org.apache.geode.cache.lucene.PageableLuceneQueryResults;
 import org.apache.geode.cache.lucene.LuceneResultStruct;
+import org.apache.geode.cache.lucene.PageableLuceneQueryResults;
 import org.apache.geode.cache.lucene.internal.distributed.EntryScore;
 import org.apache.geode.cache.lucene.internal.distributed.LuceneFunctionContext;
+import org.apache.geode.cache.lucene.internal.distributed.LuceneQueryFunction;
 import org.apache.geode.cache.lucene.internal.distributed.TopEntries;
 import org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollector;
 import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.ArgumentCaptor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Category(UnitTest.class)
 public class LuceneQueryImplJUnitTest {
@@ -54,6 +57,7 @@ public class LuceneQueryImplJUnitTest {
   private LuceneQueryProvider provider;
   private ResultCollector<TopEntriesCollector, TopEntries> collector;
   private Region region;
+  private PageableLuceneQueryResults<Object, Object> results;
 
   @Before
   public void createMocks() {
@@ -65,12 +69,20 @@ public class LuceneQueryImplJUnitTest {
     when(execution.withArgs(any())).thenReturn(execution);
     when(execution.withCollector(any())).thenReturn(execution);
     when(execution.execute(anyString())).thenReturn((ResultCollector) collector);
+    results = mock(PageableLuceneQueryResults.class);
 
     query = new LuceneQueryImpl<Object, Object>("index", region, provider, LIMIT, 20) {
+
       @Override
       protected Execution onRegion() {
         return execution;
       }
+
+      @Override
+      protected PageableLuceneQueryResults<Object, Object> newPageableResults(final int pageSize,
+          final TopEntries<Object> entries) {
+        return results;
+      }
     };
   }
 
@@ -79,9 +91,12 @@ public class LuceneQueryImplJUnitTest {
     entries.addHit(new EntryScore("hi", 5));
     when(collector.getResult()).thenReturn(entries);
 
-    Map<String, String> getAllResult = new HashMap<String, String>();
-    getAllResult.put("hi", "value");
-    when(region.getAll(eq(Collections.singletonList("hi")))).thenReturn(getAllResult);
+    when(results.getMaxScore()).thenReturn(5f);
+    when(results.size()).thenReturn(1);
+    List<LuceneResultStruct<Object, Object>> page =
+        Collections.singletonList(new LuceneResultStructImpl<>("hi", "value", 5f));
+    when(results.next()).thenReturn(page);
+    when(results.hasNext()).thenReturn(true);
   }
 
   @Test
@@ -137,6 +152,7 @@ public class LuceneQueryImplJUnitTest {
     assertEquals("index", context.getIndexName());
 
     assertEquals(5, results.getMaxScore(), 0.01);
+    assertEquals(1, results.size());
     final List<LuceneResultStruct<Object, Object>> page = results.next();
     assertEquals(1, page.size());
     LuceneResultStruct element = page.iterator().next();

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImplJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImplJUnitTest.java
index 35a4c91..bc38112 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImplJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PageableLuceneQueryResultsImplJUnitTest.java
@@ -15,6 +15,12 @@
 package org.apache.geode.cache.lucene.internal;
 
 import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -23,12 +29,16 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Set;
 
+import org.apache.geode.cache.execute.Execution;
+import org.apache.geode.cache.execute.ResultCollector;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.ExpectedException;
+import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
@@ -48,6 +58,7 @@ public class PageableLuceneQueryResultsImplJUnitTest {
   private List<EntryScore<String>> hits;
   private List<LuceneResultStruct> expected = new ArrayList<LuceneResultStruct>();
   private Region<String, String> userRegion;
+  private Execution execution;
 
   @Before
   public void setUp() {
@@ -58,13 +69,21 @@ public class PageableLuceneQueryResultsImplJUnitTest {
       expected.add(new LuceneResultStructImpl<String, String>("key_" + i, "value_" + i, i));
     }
 
-    userRegion = Mockito.mock(Region.class);
+    userRegion = mock(Region.class);
 
-    Mockito.when(userRegion.getAll(Mockito.anyCollection())).thenAnswer(new Answer() {
+    final ResultCollector collector = mock(ResultCollector.class);
+    execution = mock(Execution.class);
+    when(execution.withFilter(any())).thenReturn(execution);
+    when(execution.withCollector(any())).thenReturn(execution);
+    when(execution.execute(anyString())).thenReturn(collector);
+
+    when(collector.getResult()).then(new Answer() {
 
       @Override
       public Map answer(InvocationOnMock invocation) throws Throwable {
-        Collection<String> keys = invocation.getArgumentAt(0, Collection.class);
+        ArgumentCaptor<Set> captor = ArgumentCaptor.forClass(Set.class);
+        verify(execution, atLeast(1)).withFilter(captor.capture());
+        Collection<String> keys = captor.getValue();
         Map<String, String> results = new HashMap<String, String>();
         for (String key : keys) {
           results.put(key, key.replace("key_", "value_"));
@@ -88,7 +107,12 @@ public class PageableLuceneQueryResultsImplJUnitTest {
   @Test
   public void testPagination() {
     PageableLuceneQueryResultsImpl<String, String> results =
-        new PageableLuceneQueryResultsImpl<String, String>(hits, userRegion, 10);
+        new PageableLuceneQueryResultsImpl<String, String>(hits, userRegion, 10) {
+          @Override
+          protected Execution onRegion() {
+            return execution;
+          }
+        };
 
     assertEquals(23, results.size());
 
@@ -114,7 +138,12 @@ public class PageableLuceneQueryResultsImplJUnitTest {
   @Test
   public void testNoPagination() {
     PageableLuceneQueryResultsImpl<String, String> results =
-        new PageableLuceneQueryResultsImpl<String, String>(hits, userRegion, 0);
+        new PageableLuceneQueryResultsImpl<String, String>(hits, userRegion, 0) {
+          @Override
+          protected Execution onRegion() {
+            return execution;
+          }
+        };
 
     assertEquals(23, results.size());
 

http://git-wip-us.apache.org/repos/asf/geode/blob/712d87f7/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java
new file mode 100644
index 0000000..c62082c
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.results;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Region.Entry;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.RegionFunctionContext;
+import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.InternalRegionFunctionContext;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Collections;
+import java.util.Set;
+
+@Category(UnitTest.class)
+public class LuceneGetPageFunctionJUnitTest {
+
+  @Test
+  public void shouldReturnMapWithKeyAndValue() {
+    PartitionedRegion region = mock(PartitionedRegion.class);
+    InternalRegionFunctionContext context = mock(InternalRegionFunctionContext.class);
+    when(context.getDataSet()).thenReturn(region);
+    ResultSender resultSender = mock(ResultSender.class);
+    when(context.getResultSender()).thenReturn(resultSender);
+    LuceneGetPageFunction function = new LuceneGetPageFunction();
+    when(context.getLocalDataSet(any())).thenReturn(region);
+    final Entry entry = mock(Entry.class);
+    when(region.getEntry(any())).thenReturn(entry);
+    when(entry.getValue()).thenReturn("value");
+    when(context.getFilter()).thenReturn((Set) Collections.singleton("key"));
+    function.execute(context);
+
+    verify(resultSender).lastResult(eq(Collections.singletonMap("key", "value")));
+  }
+
+}


[31/51] [abbrv] geode git commit: Revert "GEODE-1887: Now Size api goes through ServerProxy when cache is of type client and DataPolicy is Empty."

Posted by ds...@apache.org.
Revert "GEODE-1887: Now Size api goes through ServerProxy when cache is of type client and DataPolicy is Empty."

This reverts commit f2721dc81256bcec84e855e9dc52d2f234e745da.

The commit breaks ClientServerMiscBCDUnitTest.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/8a2983f6
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/8a2983f6
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/8a2983f6

Branch: refs/heads/feature/GEM-1195
Commit: 8a2983f6e0d95f5adc4b864544c057ee31d877c0
Parents: 8b762be
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Feb 28 17:44:18 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Feb 28 17:59:25 2017 -0800

----------------------------------------------------------------------
 .../geode/internal/cache/LocalRegion.java       |  6 --
 .../tier/sockets/ClientServerMiscDUnitTest.java | 84 +++++---------------
 2 files changed, 21 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/8a2983f6/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 382c225..5d5c7e2 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -9122,12 +9122,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
       lockRIReadLock(); // bug #40871 - test sees wrong size for region during RI
     }
     try {
-      if (isClient && getDataPolicy() == DataPolicy.EMPTY) {
-        ServerRegionProxy srp = getServerProxy();
-        if (srp != null) {
-          return srp.size();
-        }
-      }
       return entryCount();
     } finally {
       if (isClient) {

http://git-wip-us.apache.org/repos/asf/geode/blob/8a2983f6/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java
index 06ea6ba..b4f3185 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientServerMiscDUnitTest.java
@@ -23,12 +23,20 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
 import org.apache.geode.GemFireConfigException;
 import org.apache.geode.GemFireIOException;
-import org.apache.geode.cache.*;
-import org.apache.geode.cache.client.*;
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheException;
+import org.apache.geode.cache.CacheWriterException;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.geode.cache.client.NoAvailableServersException;
+import org.apache.geode.cache.client.Pool;
+import org.apache.geode.cache.client.PoolManager;
 import org.apache.geode.cache.client.internal.Connection;
 import org.apache.geode.cache.client.internal.Op;
 import org.apache.geode.cache.client.internal.PoolImpl;
@@ -41,7 +49,15 @@ import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.cache.CacheServerImpl;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.LocalRegion;
-import org.apache.geode.test.dunit.*;
+import org.apache.geode.test.dunit.Assert;
+import org.apache.geode.test.dunit.DistributedTestUtils;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.dunit.LogWriterUtils;
+import org.apache.geode.test.dunit.NetworkUtils;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.Wait;
+import org.apache.geode.test.dunit.WaitCriterion;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.dunit.standalone.VersionManager;
 import org.apache.geode.test.junit.categories.ClientServerTest;
@@ -61,7 +77,6 @@ import java.util.Set;
  * Tests client server corner cases between Region and Pool
  */
 @Category({DistributedTest.class, ClientServerTest.class})
-@RunWith(JUnitParamsRunner.class)
 public class ClientServerMiscDUnitTest extends JUnit4CacheTestCase {
 
   protected static PoolImpl pool = null;
@@ -758,63 +773,6 @@ public class ClientServerMiscDUnitTest extends JUnit4CacheTestCase {
   }
 
 
-  @Test
-  @Parameters(method = "regionShortcut")
-  public void testProxyRegionClientServerOp(RegionShortcut shortcut) throws Exception {
-    // start server first
-    final String REGION_NAME = "proxyRegionClientServerOp";
-    PORT1 = initServerCache(false);
-    // Create regions on servers.
-    server1.invoke(() -> {
-      Cache cache = CacheFactory.getAnyInstance();
-      Region<Object, Object> region = cache.createRegionFactory(shortcut).create(REGION_NAME);
-      assertNotNull(region);
-    });
-
-    String host = NetworkUtils.getServerHostName(server1.getHost());
-
-    Properties props = new Properties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(LOCATORS, "");
-    ClientCacheFactory ccf = new ClientCacheFactory(props);
-    ccf.addPoolServer(host, PORT1);
-
-    ClientCache clientCache = ccf.create();
-    Region<Object, Object> clientRegion =
-        clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
-    assertNotNull(clientRegion);
-
-    // let us populate this region from client.
-    for (int i = 0; i < 10; i++) {
-      clientRegion.put(i, i * 10);
-    }
-    // Verify using gets
-    for (int i = 0; i < 10; i++) {
-      assertEquals(i * 10, clientRegion.get(i));
-    }
-    assertEquals(10, clientRegion.size());
-    assertFalse(clientRegion.isEmpty());
-    // delete all the entries from the server
-    server1.invoke(() -> {
-      Cache cache = CacheFactory.getAnyInstance();
-      Region<Object, Object> region = cache.getRegion(REGION_NAME);
-      assertNotNull(region);
-      for (int i = 0; i < 10; i++) {
-        region.remove(i);
-      }
-    });
-    assertEquals(0, clientRegion.size());
-    assertTrue(clientRegion.isEmpty());
-
-    clientRegion.destroyRegion();
-    clientCache.close();
-  }
-
-  private RegionShortcut[] regionShortcut() {
-    return new RegionShortcut[] {RegionShortcut.PARTITION, RegionShortcut.REPLICATE};
-  }
-
-
   private void createCache(Properties props) throws Exception {
     createCacheV(props);
   }


[08/51] [abbrv] geode git commit: GEODE-2142: Removal of offending JSON.ORG code and license information

Posted by ds...@apache.org.
GEODE-2142: Removal of offending JSON.ORG code and license information


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/76ea6c3c
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/76ea6c3c
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/76ea6c3c

Branch: refs/heads/feature/GEM-1195
Commit: 76ea6c3cae06442fed9ca680d5aacedaf6a4f2dd
Parents: f2721dc
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Feb 17 14:14:50 2017 -0800
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Mon Feb 27 07:18:55 2017 -0800

----------------------------------------------------------------------
 LICENSE                                         |   29 -
 geode-json/src/main/java/org/json/CDL.java      |  272 ----
 geode-json/src/main/java/org/json/Cookie.java   |  162 --
 .../src/main/java/org/json/CookieList.java      |   87 -
 geode-json/src/main/java/org/json/HTTP.java     |  185 ---
 .../src/main/java/org/json/HTTPTokener.java     |   77 -
 .../src/main/java/org/json/JSONArray.java       |  868 ----------
 .../src/main/java/org/json/JSONException.java   |   30 -
 geode-json/src/main/java/org/json/JSONML.java   |  454 ------
 .../src/main/java/org/json/JSONObject.java      | 1525 ------------------
 .../src/main/java/org/json/JSONString.java      |   17 -
 .../src/main/java/org/json/JSONStringer.java    |   75 -
 .../src/main/java/org/json/JSONTokener.java     |  437 -----
 .../src/main/java/org/json/JSONWriter.java      |  321 ----
 geode-json/src/main/java/org/json/XML.java      |  504 ------
 .../src/main/java/org/json/XMLTokener.java      |  362 -----
 16 files changed, 5405 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 4d22d30..e5f1557 100644
--- a/LICENSE
+++ b/LICENSE
@@ -275,35 +275,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
 IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ---------------------------------------------------------------------------
-The JSON License (http://www.json.org/license.html)
----------------------------------------------------------------------------
-
-Apache Geode bundles the following file under the JSON license:
-
-  - JSON (http://www.json.org), Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-
-
----------------------------------------------------------------------------
 The MIT License (http://opensource.org/licenses/mit-license.html)
 ---------------------------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/CDL.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/CDL.java b/geode-json/src/main/java/org/json/CDL.java
deleted file mode 100755
index d78935b..0000000
--- a/geode-json/src/main/java/org/json/CDL.java
+++ /dev/null
@@ -1,272 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * This provides static methods to convert comma delimited text into a JSONArray, and to covert a
- * JSONArray into comma delimited text. Comma delimited text is a very popular format for data
- * interchange. It is understood by most database, spreadsheet, and organizer programs.
- * <p>
- * Each row of text represents a row in a table or a data record. Each row ends with a NEWLINE
- * character. Each row contains one or more values. Values are separated by commas. A value can
- * contain any character except for comma, unless is is wrapped in single quotes or double quotes.
- * <p>
- * The first row usually contains the names of the columns.
- * <p>
- * A comma delimited list can be converted into a JSONArray of JSONObjects. The names for the
- * elements in the JSONObjects can be taken from the names in the first row.
- * 
- * @author JSON.org
- * @version 2010-12-24
- */
-public class CDL {
-
-  /**
-   * Get the next value. The value can be wrapped in quotes. The value can be empty.
-   * 
-   * @param x A JSONTokener of the source text.
-   * @return The value string, or null if empty.
-   * @throws JSONException if the quoted string is badly formed.
-   */
-  private static String getValue(JSONTokener x) throws JSONException {
-    char c;
-    char q;
-    StringBuffer sb;
-    do {
-      c = x.next();
-    } while (c == ' ' || c == '\t');
-    switch (c) {
-      case 0:
-        return null;
-      case '"':
-      case '\'':
-        q = c;
-        sb = new StringBuffer();
-        for (;;) {
-          c = x.next();
-          if (c == q) {
-            break;
-          }
-          if (c == 0 || c == '\n' || c == '\r') {
-            throw x.syntaxError("Missing close quote '" + q + "'.");
-          }
-          sb.append(c);
-        }
-        return sb.toString();
-      case ',':
-        x.back();
-        return "";
-      default:
-        x.back();
-        return x.nextTo(',');
-    }
-  }
-
-  /**
-   * Produce a JSONArray of strings from a row of comma delimited values.
-   * 
-   * @param x A JSONTokener of the source text.
-   * @return A JSONArray of strings.
-   * @throws JSONException
-   */
-  public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
-    JSONArray ja = new JSONArray();
-    for (;;) {
-      String value = getValue(x);
-      char c = x.next();
-      if (value == null || (ja.length() == 0 && value.length() == 0 && c != ',')) {
-        return null;
-      }
-      ja.put(value);
-      for (;;) {
-        if (c == ',') {
-          break;
-        }
-        if (c != ' ') {
-          if (c == '\n' || c == '\r' || c == 0) {
-            return ja;
-          }
-          throw x.syntaxError("Bad character '" + c + "' (" + (int) c + ").");
-        }
-        c = x.next();
-      }
-    }
-  }
-
-  /**
-   * Produce a JSONObject from a row of comma delimited text, using a parallel JSONArray of strings
-   * to provides the names of the elements.
-   * 
-   * @param names A JSONArray of names. This is commonly obtained from the first row of a comma
-   *        delimited text file using the rowToJSONArray method.
-   * @param x A JSONTokener of the source text.
-   * @return A JSONObject combining the names and values.
-   * @throws JSONException
-   */
-  public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) throws JSONException {
-    JSONArray ja = rowToJSONArray(x);
-    return ja != null ? ja.toJSONObject(names) : null;
-  }
-
-  /**
-   * Produce a comma delimited text row from a JSONArray. Values containing the comma character will
-   * be quoted. Troublesome characters may be removed.
-   * 
-   * @param ja A JSONArray of strings.
-   * @return A string ending in NEWLINE.
-   */
-  public static String rowToString(JSONArray ja) {
-    StringBuffer sb = new StringBuffer();
-    for (int i = 0; i < ja.length(); i += 1) {
-      if (i > 0) {
-        sb.append(',');
-      }
-      Object object = ja.opt(i);
-      if (object != null) {
-        String string = object.toString();
-        if (string.length() > 0 && (string.indexOf(',') >= 0 || string.indexOf('\n') >= 0
-            || string.indexOf('\r') >= 0 || string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
-          sb.append('"');
-          int length = string.length();
-          for (int j = 0; j < length; j += 1) {
-            char c = string.charAt(j);
-            if (c >= ' ' && c != '"') {
-              sb.append(c);
-            }
-          }
-          sb.append('"');
-        } else {
-          sb.append(string);
-        }
-      }
-    }
-    sb.append('\n');
-    return sb.toString();
-  }
-
-  /**
-   * Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a
-   * source of names.
-   * 
-   * @param string The comma delimited text.
-   * @return A JSONArray of JSONObjects.
-   * @throws JSONException
-   */
-  public static JSONArray toJSONArray(String string) throws JSONException {
-    return toJSONArray(new JSONTokener(string));
-  }
-
-  /**
-   * Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a
-   * source of names.
-   * 
-   * @param x The JSONTokener containing the comma delimited text.
-   * @return A JSONArray of JSONObjects.
-   * @throws JSONException
-   */
-  public static JSONArray toJSONArray(JSONTokener x) throws JSONException {
-    return toJSONArray(rowToJSONArray(x), x);
-  }
-
-  /**
-   * Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied
-   * JSONArray as the source of element names.
-   * 
-   * @param names A JSONArray of strings.
-   * @param string The comma delimited text.
-   * @return A JSONArray of JSONObjects.
-   * @throws JSONException
-   */
-  public static JSONArray toJSONArray(JSONArray names, String string) throws JSONException {
-    return toJSONArray(names, new JSONTokener(string));
-  }
-
-  /**
-   * Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied
-   * JSONArray as the source of element names.
-   * 
-   * @param names A JSONArray of strings.
-   * @param x A JSONTokener of the source text.
-   * @return A JSONArray of JSONObjects.
-   * @throws JSONException
-   */
-  public static JSONArray toJSONArray(JSONArray names, JSONTokener x) throws JSONException {
-    if (names == null || names.length() == 0) {
-      return null;
-    }
-    JSONArray ja = new JSONArray();
-    for (;;) {
-      JSONObject jo = rowToJSONObject(names, x);
-      if (jo == null) {
-        break;
-      }
-      ja.put(jo);
-    }
-    if (ja.length() == 0) {
-      return null;
-    }
-    return ja;
-  }
-
-
-  /**
-   * Produce a comma delimited text from a JSONArray of JSONObjects. The first row will be a list of
-   * names obtained by inspecting the first JSONObject.
-   * 
-   * @param ja A JSONArray of JSONObjects.
-   * @return A comma delimited text.
-   * @throws JSONException
-   */
-  public static String toString(JSONArray ja) throws JSONException {
-    JSONObject jo = ja.optJSONObject(0);
-    if (jo != null) {
-      JSONArray names = jo.names();
-      if (names != null) {
-        return rowToString(names) + toString(names, ja);
-      }
-    }
-    return null;
-  }
-
-  /**
-   * Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names.
-   * The list of names is not included in the output.
-   * 
-   * @param names A JSONArray of strings.
-   * @param ja A JSONArray of JSONObjects.
-   * @return A comma delimited text.
-   * @throws JSONException
-   */
-  public static String toString(JSONArray names, JSONArray ja) throws JSONException {
-    if (names == null || names.length() == 0) {
-      return null;
-    }
-    StringBuffer sb = new StringBuffer();
-    for (int i = 0; i < ja.length(); i += 1) {
-      JSONObject jo = ja.optJSONObject(i);
-      if (jo != null) {
-        sb.append(rowToString(jo.toJSONArray(names)));
-      }
-    }
-    return sb.toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/Cookie.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/Cookie.java b/geode-json/src/main/java/org/json/Cookie.java
deleted file mode 100755
index 21f88d8..0000000
--- a/geode-json/src/main/java/org/json/Cookie.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * Convert a web browser cookie specification to a JSONObject and back. JSON and Cookies are both
- * notations for name/value pairs.
- * 
- * @author JSON.org
- * @version 2010-12-24
- */
-public class Cookie {
-
-  /**
-   * Produce a copy of a string in which the characters '+', '%', '=', ';' and control characters
-   * are replaced with "%hh". This is a gentle form of URL encoding, attempting to cause as little
-   * distortion to the string as possible. The characters '=' and ';' are meta characters in
-   * cookies. By convention, they are escaped using the URL-encoding. This is only a convention, not
-   * a standard. Often, cookies are expected to have encoded values. We encode '=' and ';' because
-   * we must. We encode '%' and '+' because they are meta characters in URL encoding.
-   * 
-   * @param string The source string.
-   * @return The escaped result.
-   */
-  public static String escape(String string) {
-    char c;
-    String s = string.trim();
-    StringBuffer sb = new StringBuffer();
-    int length = s.length();
-    for (int i = 0; i < length; i += 1) {
-      c = s.charAt(i);
-      if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') {
-        sb.append('%');
-        sb.append(Character.forDigit((char) ((c >>> 4) & 0x0f), 16));
-        sb.append(Character.forDigit((char) (c & 0x0f), 16));
-      } else {
-        sb.append(c);
-      }
-    }
-    return sb.toString();
-  }
-
-
-  /**
-   * Convert a cookie specification string into a JSONObject. The string will contain a name value
-   * pair separated by '='. The name and the value will be unescaped, possibly converting '+' and
-   * '%' sequences. The cookie properties may follow, separated by ';', also represented as
-   * name=value (except the secure property, which does not have a value). The name will be stored
-   * under the key "name", and the value will be stored under the key "value". This method does not
-   * do checking or validation of the parameters. It only converts the cookie string into a
-   * JSONObject.
-   * 
-   * @param string The cookie specification string.
-   * @return A JSONObject containing "name", "value", and possibly other members.
-   * @throws JSONException
-   */
-  public static JSONObject toJSONObject(String string) throws JSONException {
-    String name;
-    JSONObject jo = new JSONObject();
-    Object value;
-    JSONTokener x = new JSONTokener(string);
-    jo.put("name", x.nextTo('='));
-    x.next('=');
-    jo.put("value", x.nextTo(';'));
-    x.next();
-    while (x.more()) {
-      name = unescape(x.nextTo("=;"));
-      if (x.next() != '=') {
-        if (name.equals("secure")) {
-          value = Boolean.TRUE;
-        } else {
-          throw x.syntaxError("Missing '=' in cookie parameter.");
-        }
-      } else {
-        value = unescape(x.nextTo(';'));
-        x.next();
-      }
-      jo.put(name, value);
-    }
-    return jo;
-  }
-
-
-  /**
-   * Convert a JSONObject into a cookie specification string. The JSONObject must contain "name" and
-   * "value" members. If the JSONObject contains "expires", "domain", "path", or "secure" members,
-   * they will be appended to the cookie specification string. All other members are ignored.
-   * 
-   * @param jo A JSONObject
-   * @return A cookie specification string
-   * @throws JSONException
-   */
-  public static String toString(JSONObject jo) throws JSONException {
-    StringBuffer sb = new StringBuffer();
-
-    sb.append(escape(jo.getString("name")));
-    sb.append("=");
-    sb.append(escape(jo.getString("value")));
-    if (jo.has("expires")) {
-      sb.append(";expires=");
-      sb.append(jo.getString("expires"));
-    }
-    if (jo.has("domain")) {
-      sb.append(";domain=");
-      sb.append(escape(jo.getString("domain")));
-    }
-    if (jo.has("path")) {
-      sb.append(";path=");
-      sb.append(escape(jo.getString("path")));
-    }
-    if (jo.optBoolean("secure")) {
-      sb.append(";secure");
-    }
-    return sb.toString();
-  }
-
-  /**
-   * Convert <code>%</code><i>hh</i> sequences to single characters, and convert plus to space.
-   * 
-   * @param string A string that may contain <code>+</code>&nbsp;<small>(plus)</small> and
-   *        <code>%</code><i>hh</i> sequences.
-   * @return The unescaped string.
-   */
-  public static String unescape(String string) {
-    int length = string.length();
-    StringBuffer sb = new StringBuffer();
-    for (int i = 0; i < length; ++i) {
-      char c = string.charAt(i);
-      if (c == '+') {
-        c = ' ';
-      } else if (c == '%' && i + 2 < length) {
-        int d = JSONTokener.dehexchar(string.charAt(i + 1));
-        int e = JSONTokener.dehexchar(string.charAt(i + 2));
-        if (d >= 0 && e >= 0) {
-          c = (char) (d * 16 + e);
-          i += 2;
-        }
-      }
-      sb.append(c);
-    }
-    return sb.toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/CookieList.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/CookieList.java b/geode-json/src/main/java/org/json/CookieList.java
deleted file mode 100755
index 35e1a97..0000000
--- a/geode-json/src/main/java/org/json/CookieList.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-import java.util.Iterator;
-
-/**
- * Convert a web browser cookie list string to a JSONObject and back.
- * 
- * @author JSON.org
- * @version 2010-12-24
- */
-public class CookieList {
-
-  /**
-   * Convert a cookie list into a JSONObject. A cookie list is a sequence of name/value pairs. The
-   * names are separated from the values by '='. The pairs are separated by ';'. The names and the
-   * values will be unescaped, possibly converting '+' and '%' sequences.
-   *
-   * To add a cookie to a cooklist, cookielistJSONObject.put(cookieJSONObject.getString("name"),
-   * cookieJSONObject.getString("value"));
-   * 
-   * @param string A cookie list string
-   * @return A JSONObject
-   * @throws JSONException
-   */
-  public static JSONObject toJSONObject(String string) throws JSONException {
-    JSONObject jo = new JSONObject();
-    JSONTokener x = new JSONTokener(string);
-    while (x.more()) {
-      String name = Cookie.unescape(x.nextTo('='));
-      x.next('=');
-      jo.put(name, Cookie.unescape(x.nextTo(';')));
-      x.next();
-    }
-    return jo;
-  }
-
-
-  /**
-   * Convert a JSONObject into a cookie list. A cookie list is a sequence of name/value pairs. The
-   * names are separated from the values by '='. The pairs are separated by ';'. The characters '%',
-   * '+', '=', and ';' in the names and values are replaced by "%hh".
-   * 
-   * @param jo A JSONObject
-   * @return A cookie list string
-   * @throws JSONException
-   */
-  public static String toString(JSONObject jo) throws JSONException {
-    boolean b = false;
-    Iterator keys = jo.keys();
-    String string;
-    StringBuffer sb = new StringBuffer();
-    while (keys.hasNext()) {
-      string = keys.next().toString();
-      if (!jo.isNull(string)) {
-        if (b) {
-          sb.append(';');
-        }
-        sb.append(Cookie.escape(string));
-        sb.append("=");
-        sb.append(Cookie.escape(jo.getString(string)));
-        b = true;
-      }
-    }
-    return sb.toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/HTTP.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/HTTP.java b/geode-json/src/main/java/org/json/HTTP.java
deleted file mode 100755
index 1e815aa..0000000
--- a/geode-json/src/main/java/org/json/HTTP.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-import java.util.Iterator;
-
-/**
- * Convert an HTTP header to a JSONObject and back.
- * 
- * @author JSON.org
- * @version 2010-12-24
- */
-public class HTTP {
-
-  /** Carriage return/line feed. */
-  public static final String CRLF = "\r\n";
-
-  /**
-   * Convert an HTTP header string into a JSONObject. It can be a request header or a response
-   * header. A request header will contain
-   * 
-   * <pre>
-   * {
-   *    Method: "POST" (for example),
-   *    "Request-URI": "/" (for example),
-   *    "HTTP-Version": "HTTP/1.1" (for example)
-   * }
-   * </pre>
-   * 
-   * A response header will contain
-   * 
-   * <pre>
-   * {
-   *    "HTTP-Version": "HTTP/1.1" (for example),
-   *    "Status-Code": "200" (for example),
-   *    "Reason-Phrase": "OK" (for example)
-   * }
-   * </pre>
-   * 
-   * In addition, the other parameters in the header will be captured, using the HTTP field names as
-   * JSON names, so that
-   * 
-   * <pre>
-   *    Date: Sun, 26 May 2002 18:06:04 GMT
-   *    Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
-   *    Cache-Control: no-cache
-   * </pre>
-   * 
-   * become
-   * 
-   * <pre>
-   * {...
-   *    Date: "Sun, 26 May 2002 18:06:04 GMT",
-   *    Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
-   *    "Cache-Control": "no-cache",
-   * ...}
-   * </pre>
-   * 
-   * It does no further checking or conversion. It does not parse dates. It does not do '%'
-   * transforms on URLs.
-   * 
-   * @param string An HTTP header string.
-   * @return A JSONObject containing the elements and attributes of the XML string.
-   * @throws JSONException
-   */
-  public static JSONObject toJSONObject(String string) throws JSONException {
-    JSONObject jo = new JSONObject();
-    HTTPTokener x = new HTTPTokener(string);
-    String token;
-
-    token = x.nextToken();
-    if (token.toUpperCase().startsWith("HTTP")) {
-
-      // Response
-
-      jo.put("HTTP-Version", token);
-      jo.put("Status-Code", x.nextToken());
-      jo.put("Reason-Phrase", x.nextTo('\0'));
-      x.next();
-
-    } else {
-
-      // Request
-
-      jo.put("Method", token);
-      jo.put("Request-URI", x.nextToken());
-      jo.put("HTTP-Version", x.nextToken());
-    }
-
-    // Fields
-
-    while (x.more()) {
-      String name = x.nextTo(':');
-      x.next(':');
-      jo.put(name, x.nextTo('\0'));
-      x.next();
-    }
-    return jo;
-  }
-
-
-  /**
-   * Convert a JSONObject into an HTTP header. A request header must contain
-   * 
-   * <pre>
-   * {
-   *    Method: "POST" (for example),
-   *    "Request-URI": "/" (for example),
-   *    "HTTP-Version": "HTTP/1.1" (for example)
-   * }
-   * </pre>
-   * 
-   * A response header must contain
-   * 
-   * <pre>
-   * {
-   *    "HTTP-Version": "HTTP/1.1" (for example),
-   *    "Status-Code": "200" (for example),
-   *    "Reason-Phrase": "OK" (for example)
-   * }
-   * </pre>
-   * 
-   * Any other members of the JSONObject will be output as HTTP fields. The result will end with two
-   * CRLF pairs.
-   * 
-   * @param jo A JSONObject
-   * @return An HTTP header string.
-   * @throws JSONException if the object does not contain enough information.
-   */
-  public static String toString(JSONObject jo) throws JSONException {
-    Iterator keys = jo.keys();
-    String string;
-    StringBuffer sb = new StringBuffer();
-    if (jo.has("Status-Code") && jo.has("Reason-Phrase")) {
-      sb.append(jo.getString("HTTP-Version"));
-      sb.append(' ');
-      sb.append(jo.getString("Status-Code"));
-      sb.append(' ');
-      sb.append(jo.getString("Reason-Phrase"));
-    } else if (jo.has("Method") && jo.has("Request-URI")) {
-      sb.append(jo.getString("Method"));
-      sb.append(' ');
-      sb.append('"');
-      sb.append(jo.getString("Request-URI"));
-      sb.append('"');
-      sb.append(' ');
-      sb.append(jo.getString("HTTP-Version"));
-    } else {
-      throw new JSONException("Not enough material for an HTTP header.");
-    }
-    sb.append(CRLF);
-    while (keys.hasNext()) {
-      string = keys.next().toString();
-      if (!"HTTP-Version".equals(string) && !"Status-Code".equals(string)
-          && !"Reason-Phrase".equals(string) && !"Method".equals(string)
-          && !"Request-URI".equals(string) && !jo.isNull(string)) {
-        sb.append(string);
-        sb.append(": ");
-        sb.append(jo.getString(string));
-        sb.append(CRLF);
-      }
-    }
-    sb.append(CRLF);
-    return sb.toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/HTTPTokener.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/HTTPTokener.java b/geode-json/src/main/java/org/json/HTTPTokener.java
deleted file mode 100755
index 72c9b88..0000000
--- a/geode-json/src/main/java/org/json/HTTPTokener.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * The HTTPTokener extends the JSONTokener to provide additional methods for the parsing of HTTP
- * headers.
- * 
- * @author JSON.org
- * @version 2010-12-24
- */
-public class HTTPTokener extends JSONTokener {
-
-  /**
-   * Construct an HTTPTokener from a string.
-   * 
-   * @param string A source string.
-   */
-  public HTTPTokener(String string) {
-    super(string);
-  }
-
-
-  /**
-   * Get the next token or string. This is used in parsing HTTP headers.
-   * 
-   * @throws JSONException
-   * @return A String.
-   */
-  public String nextToken() throws JSONException {
-    char c;
-    char q;
-    StringBuffer sb = new StringBuffer();
-    do {
-      c = next();
-    } while (Character.isWhitespace(c));
-    if (c == '"' || c == '\'') {
-      q = c;
-      for (;;) {
-        c = next();
-        if (c < ' ') {
-          throw syntaxError("Unterminated string.");
-        }
-        if (c == q) {
-          return sb.toString();
-        }
-        sb.append(c);
-      }
-    }
-    for (;;) {
-      if (c == 0 || Character.isWhitespace(c)) {
-        return sb.toString();
-      }
-      sb.append(c);
-      c = next();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/JSONArray.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONArray.java b/geode-json/src/main/java/org/json/JSONArray.java
deleted file mode 100644
index edaefa4..0000000
--- a/geode-json/src/main/java/org/json/JSONArray.java
+++ /dev/null
@@ -1,868 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * A JSONArray is an ordered sequence of values. Its external text form is a string wrapped in
- * square brackets with commas separating the values. The internal form is an object having
- * <code>get</code> and <code>opt</code> methods for accessing the values by index, and
- * <code>put</code> methods for adding or replacing values. The values can be any of these types:
- * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
- * <code>String</code>, or the <code>JSONObject.NULL object</code>.
- * <p>
- * The constructor can convert a JSON text into a Java object. The <code>toString</code> method
- * converts to JSON text.
- * <p>
- * A <code>get</code> method returns a value if one can be found, and throws an exception if one
- * cannot be found. An <code>opt</code> method returns a default value instead of throwing an
- * exception, and so is useful for obtaining optional values.
- * <p>
- * The generic <code>get()</code> and <code>opt()</code> methods return an object which you can cast
- * or query for type. There are also typed <code>get</code> and <code>opt</code> methods that do
- * type checking and type coercion for you.
- * <p>
- * The texts produced by the <code>toString</code> methods strictly conform to JSON syntax rules.
- * The constructors are more forgiving in the texts they will accept:
- * <ul>
- * <li>An extra <code>,</code>&nbsp;<small>(comma)</small> may appear just before the closing
- * bracket.</li>
- * <li>The <code>null</code> value will be inserted when there is <code>,</code>
- * &nbsp;<small>(comma)</small> elision.</li>
- * <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single quote)</small>.</li>
- * <li>Strings do not need to be quoted at all if they do not begin with a quote or single quote,
- * and if they do not contain leading or trailing spaces, and if they do not contain any of these
- * characters: <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and if they
- * are not the reserved words <code>true</code>, <code>false</code>, or <code>null</code>.</li>
- * <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as well as by
- * <code>,</code> <small>(comma)</small>.</li>
- * </ul>
- *
- * @author JSON.org
- * @version 2012-04-20
- */
-public class JSONArray {
-
-
-  /**
-   * The arrayList where the JSONArray's properties are kept.
-   */
-  private final ArrayList myArrayList;
-
-
-  /**
-   * Construct an empty JSONArray.
-   */
-  public JSONArray() {
-    this.myArrayList = new ArrayList();
-  }
-
-  /**
-   * Construct a JSONArray from a JSONTokener.
-   * 
-   * @param x A JSONTokener
-   * @throws JSONException If there is a syntax error.
-   */
-  public JSONArray(JSONTokener x) throws JSONException {
-    this();
-    if (x.nextClean() != '[') {
-      throw x.syntaxError("A JSONArray text must start with '['");
-    }
-    if (x.nextClean() != ']') {
-      x.back();
-      for (;;) {
-        if (x.nextClean() == ',') {
-          x.back();
-          this.myArrayList.add(JSONObject.NULL);
-        } else {
-          x.back();
-          this.myArrayList.add(x.nextValue());
-        }
-        switch (x.nextClean()) {
-          case ';':
-          case ',':
-            if (x.nextClean() == ']') {
-              return;
-            }
-            x.back();
-            break;
-          case ']':
-            return;
-          default:
-            throw x.syntaxError("Expected a ',' or ']'");
-        }
-      }
-    }
-  }
-
-
-  /**
-   * Construct a JSONArray from a source JSON text.
-   * 
-   * @param source A string that begins with <code>[</code>&nbsp;<small>(left bracket)</small> and
-   *        ends with <code>]</code>&nbsp;<small>(right bracket)</small>.
-   * @throws JSONException If there is a syntax error.
-   */
-  public JSONArray(String source) throws JSONException {
-    this(new JSONTokener(source));
-  }
-
-
-  /**
-   * Construct a JSONArray from a Collection.
-   * 
-   * @param collection A Collection.
-   */
-  public JSONArray(Collection collection) {
-    this.myArrayList = new ArrayList();
-    if (collection != null) {
-      Iterator iter = collection.iterator();
-      while (iter.hasNext()) {
-        this.myArrayList.add(JSONObject.wrap(iter.next()));
-      }
-    }
-  }
-
-
-  /**
-   * Construct a JSONArray from an array
-   * 
-   * @throws JSONException If not an array.
-   */
-  public JSONArray(Object array) throws JSONException {
-    this();
-    if (array.getClass().isArray()) {
-      int length = Array.getLength(array);
-      for (int i = 0; i < length; i += 1) {
-        this.put(JSONObject.wrap(Array.get(array, i)));
-      }
-    } else {
-      throw new JSONException("JSONArray initial value should be a string or collection or array.");
-    }
-  }
-
-
-  /**
-   * Get the object value associated with an index.
-   * 
-   * @param index The index must be between 0 and length() - 1.
-   * @return An object value.
-   * @throws JSONException If there is no value for the index.
-   */
-  public Object get(int index) throws JSONException {
-    Object object = this.opt(index);
-    if (object == null) {
-      throw new JSONException("JSONArray[" + index + "] not found.");
-    }
-    return object;
-  }
-
-
-  /**
-   * Get the boolean value associated with an index. The string values "true" and "false" are
-   * converted to boolean.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return The truth.
-   * @throws JSONException If there is no value for the index or if the value is not convertible to
-   *         boolean.
-   */
-  public boolean getBoolean(int index) throws JSONException {
-    Object object = this.get(index);
-    if (object.equals(Boolean.FALSE)
-        || (object instanceof String && ((String) object).equalsIgnoreCase("false"))) {
-      return false;
-    } else if (object.equals(Boolean.TRUE)
-        || (object instanceof String && ((String) object).equalsIgnoreCase("true"))) {
-      return true;
-    }
-    throw new JSONException("JSONArray[" + index + "] is not a boolean.");
-  }
-
-
-  /**
-   * Get the double value associated with an index.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return The value.
-   * @throws JSONException If the key is not found or if the value cannot be converted to a number.
-   */
-  public double getDouble(int index) throws JSONException {
-    Object object = this.get(index);
-    try {
-      return object instanceof Number ? ((Number) object).doubleValue()
-          : Double.parseDouble((String) object);
-    } catch (Exception e) {
-      throw new JSONException("JSONArray[" + index + "] is not a number.");
-    }
-  }
-
-
-  /**
-   * Get the int value associated with an index.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return The value.
-   * @throws JSONException If the key is not found or if the value is not a number.
-   */
-  public int getInt(int index) throws JSONException {
-    Object object = this.get(index);
-    try {
-      return object instanceof Number ? ((Number) object).intValue()
-          : Integer.parseInt((String) object);
-    } catch (Exception e) {
-      throw new JSONException("JSONArray[" + index + "] is not a number.");
-    }
-  }
-
-
-  /**
-   * Get the JSONArray associated with an index.
-   * 
-   * @param index The index must be between 0 and length() - 1.
-   * @return A JSONArray value.
-   * @throws JSONException If there is no value for the index. or if the value is not a JSONArray
-   */
-  public JSONArray getJSONArray(int index) throws JSONException {
-    Object object = this.get(index);
-    if (object instanceof JSONArray) {
-      return (JSONArray) object;
-    }
-    throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
-  }
-
-
-  /**
-   * Get the JSONObject associated with an index.
-   * 
-   * @param index subscript
-   * @return A JSONObject value.
-   * @throws JSONException If there is no value for the index or if the value is not a JSONObject
-   */
-  public JSONObject getJSONObject(int index) throws JSONException {
-    Object object = this.get(index);
-    if (object instanceof JSONObject) {
-      return (JSONObject) object;
-    }
-    throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
-  }
-
-
-  /**
-   * Get the long value associated with an index.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return The value.
-   * @throws JSONException If the key is not found or if the value cannot be converted to a number.
-   */
-  public long getLong(int index) throws JSONException {
-    Object object = this.get(index);
-    try {
-      return object instanceof Number ? ((Number) object).longValue()
-          : Long.parseLong((String) object);
-    } catch (Exception e) {
-      throw new JSONException("JSONArray[" + index + "] is not a number.");
-    }
-  }
-
-
-  /**
-   * Get the string associated with an index.
-   * 
-   * @param index The index must be between 0 and length() - 1.
-   * @return A string value.
-   * @throws JSONException If there is no string value for the index.
-   */
-  public String getString(int index) throws JSONException {
-    Object object = this.get(index);
-    if (object instanceof String) {
-      return (String) object;
-    }
-    throw new JSONException("JSONArray[" + index + "] not a string.");
-  }
-
-
-  /**
-   * Determine if the value is null.
-   * 
-   * @param index The index must be between 0 and length() - 1.
-   * @return true if the value at the index is null, or if there is no value.
-   */
-  public boolean isNull(int index) {
-    return JSONObject.NULL.equals(this.opt(index));
-  }
-
-
-  /**
-   * Make a string from the contents of this JSONArray. The <code>separator</code> string is
-   * inserted between each element. Warning: This method assumes that the data structure is
-   * acyclical.
-   * 
-   * @param separator A string that will be inserted between the elements.
-   * @return a string.
-   * @throws JSONException If the array contains an invalid number.
-   */
-  public String join(String separator) throws JSONException {
-    int len = this.length();
-    StringBuffer sb = new StringBuffer();
-
-    for (int i = 0; i < len; i += 1) {
-      if (i > 0) {
-        sb.append(separator);
-      }
-      sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
-    }
-    return sb.toString();
-  }
-
-
-  /**
-   * Get the number of elements in the JSONArray, included nulls.
-   *
-   * @return The length (or size).
-   */
-  public int length() {
-    return this.myArrayList.size();
-  }
-
-
-  /**
-   * Get the optional object value associated with an index.
-   * 
-   * @param index The index must be between 0 and length() - 1.
-   * @return An object value, or null if there is no object at that index.
-   */
-  public Object opt(int index) {
-    return (index < 0 || index >= this.length()) ? null : this.myArrayList.get(index);
-  }
-
-
-  /**
-   * Get the optional boolean value associated with an index. It returns false if there is no value
-   * at that index, or if the value is not Boolean.TRUE or the String "true".
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return The truth.
-   */
-  public boolean optBoolean(int index) {
-    return this.optBoolean(index, false);
-  }
-
-
-  /**
-   * Get the optional boolean value associated with an index. It returns the defaultValue if there
-   * is no value at that index or if it is not a Boolean or the String "true" or "false" (case
-   * insensitive).
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @param defaultValue A boolean default.
-   * @return The truth.
-   */
-  public boolean optBoolean(int index, boolean defaultValue) {
-    try {
-      return this.getBoolean(index);
-    } catch (Exception e) {
-      return defaultValue;
-    }
-  }
-
-
-  /**
-   * Get the optional double value associated with an index. NaN is returned if there is no value
-   * for the index, or if the value is not a number and cannot be converted to a number.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return The value.
-   */
-  public double optDouble(int index) {
-    return this.optDouble(index, Double.NaN);
-  }
-
-
-  /**
-   * Get the optional double value associated with an index. The defaultValue is returned if there
-   * is no value for the index, or if the value is not a number and cannot be converted to a number.
-   *
-   * @param index subscript
-   * @param defaultValue The default value.
-   * @return The value.
-   */
-  public double optDouble(int index, double defaultValue) {
-    try {
-      return this.getDouble(index);
-    } catch (Exception e) {
-      return defaultValue;
-    }
-  }
-
-
-  /**
-   * Get the optional int value associated with an index. Zero is returned if there is no value for
-   * the index, or if the value is not a number and cannot be converted to a number.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return The value.
-   */
-  public int optInt(int index) {
-    return this.optInt(index, 0);
-  }
-
-
-  /**
-   * Get the optional int value associated with an index. The defaultValue is returned if there is
-   * no value for the index, or if the value is not a number and cannot be converted to a number.
-   * 
-   * @param index The index must be between 0 and length() - 1.
-   * @param defaultValue The default value.
-   * @return The value.
-   */
-  public int optInt(int index, int defaultValue) {
-    try {
-      return this.getInt(index);
-    } catch (Exception e) {
-      return defaultValue;
-    }
-  }
-
-
-  /**
-   * Get the optional JSONArray associated with an index.
-   * 
-   * @param index subscript
-   * @return A JSONArray value, or null if the index has no value, or if the value is not a
-   *         JSONArray.
-   */
-  public JSONArray optJSONArray(int index) {
-    Object o = this.opt(index);
-    return o instanceof JSONArray ? (JSONArray) o : null;
-  }
-
-
-  /**
-   * Get the optional JSONObject associated with an index. Null is returned if the key is not found,
-   * or null if the index has no value, or if the value is not a JSONObject.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return A JSONObject value.
-   */
-  public JSONObject optJSONObject(int index) {
-    Object o = this.opt(index);
-    return o instanceof JSONObject ? (JSONObject) o : null;
-  }
-
-
-  /**
-   * Get the optional long value associated with an index. Zero is returned if there is no value for
-   * the index, or if the value is not a number and cannot be converted to a number.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return The value.
-   */
-  public long optLong(int index) {
-    return this.optLong(index, 0);
-  }
-
-
-  /**
-   * Get the optional long value associated with an index. The defaultValue is returned if there is
-   * no value for the index, or if the value is not a number and cannot be converted to a number.
-   * 
-   * @param index The index must be between 0 and length() - 1.
-   * @param defaultValue The default value.
-   * @return The value.
-   */
-  public long optLong(int index, long defaultValue) {
-    try {
-      return this.getLong(index);
-    } catch (Exception e) {
-      return defaultValue;
-    }
-  }
-
-
-  /**
-   * Get the optional string value associated with an index. It returns an empty string if there is
-   * no value at that index. If the value is not a string and is not null, then it is coverted to a
-   * string.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @return A String value.
-   */
-  public String optString(int index) {
-    return this.optString(index, "");
-  }
-
-
-  /**
-   * Get the optional string associated with an index. The defaultValue is returned if the key is
-   * not found.
-   *
-   * @param index The index must be between 0 and length() - 1.
-   * @param defaultValue The default value.
-   * @return A String value.
-   */
-  public String optString(int index, String defaultValue) {
-    Object object = this.opt(index);
-    return JSONObject.NULL.equals(object) ? defaultValue : object.toString();
-  }
-
-
-  /**
-   * Append a boolean value. This increases the array's length by one.
-   *
-   * @param value A boolean value.
-   * @return this.
-   */
-  public JSONArray put(boolean value) {
-    this.put(value ? Boolean.TRUE : Boolean.FALSE);
-    return this;
-  }
-
-
-  /**
-   * Put a value in the JSONArray, where the value will be a JSONArray which is produced from a
-   * Collection.
-   * 
-   * @param value A Collection value.
-   * @return this.
-   */
-  public JSONArray put(Collection value) {
-    this.put(new JSONArray(value));
-    return this;
-  }
-
-
-  /**
-   * Append a double value. This increases the array's length by one.
-   *
-   * @param value A double value.
-   * @throws JSONException if the value is not finite.
-   * @return this.
-   */
-  public JSONArray put(double value) throws JSONException {
-    Double d = new Double(value);
-    JSONObject.testValidity(d);
-    this.put(d);
-    return this;
-  }
-
-
-  /**
-   * Append an int value. This increases the array's length by one.
-   *
-   * @param value An int value.
-   * @return this.
-   */
-  public JSONArray put(int value) {
-    this.put(new Integer(value));
-    return this;
-  }
-
-
-  /**
-   * Append an long value. This increases the array's length by one.
-   *
-   * @param value A long value.
-   * @return this.
-   */
-  public JSONArray put(long value) {
-    this.put(new Long(value));
-    return this;
-  }
-
-
-  /**
-   * Put a value in the JSONArray, where the value will be a JSONObject which is produced from a
-   * Map.
-   * 
-   * @param value A Map value.
-   * @return this.
-   */
-  public JSONArray put(Map value) {
-    this.put(new JSONObject(value));
-    return this;
-  }
-
-
-  /**
-   * Append an object value. This increases the array's length by one.
-   * 
-   * @param value An object value. The value should be a Boolean, Double, Integer, JSONArray,
-   *        JSONObject, Long, or String, or the JSONObject.NULL object.
-   * @return this.
-   */
-  public JSONArray put(Object value) {
-    this.myArrayList.add(value);
-    return this;
-  }
-
-
-  /**
-   * Put or replace a boolean value in the JSONArray. If the index is greater than the length of the
-   * JSONArray, then null elements will be added as necessary to pad it out.
-   * 
-   * @param index The subscript.
-   * @param value A boolean value.
-   * @return this.
-   * @throws JSONException If the index is negative.
-   */
-  public JSONArray put(int index, boolean value) throws JSONException {
-    this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
-    return this;
-  }
-
-
-  /**
-   * Put a value in the JSONArray, where the value will be a JSONArray which is produced from a
-   * Collection.
-   * 
-   * @param index The subscript.
-   * @param value A Collection value.
-   * @return this.
-   * @throws JSONException If the index is negative or if the value is not finite.
-   */
-  public JSONArray put(int index, Collection value) throws JSONException {
-    this.put(index, new JSONArray(value));
-    return this;
-  }
-
-
-  /**
-   * Put or replace a double value. If the index is greater than the length of the JSONArray, then
-   * null elements will be added as necessary to pad it out.
-   * 
-   * @param index The subscript.
-   * @param value A double value.
-   * @return this.
-   * @throws JSONException If the index is negative or if the value is not finite.
-   */
-  public JSONArray put(int index, double value) throws JSONException {
-    this.put(index, new Double(value));
-    return this;
-  }
-
-
-  /**
-   * Put or replace an int value. If the index is greater than the length of the JSONArray, then
-   * null elements will be added as necessary to pad it out.
-   * 
-   * @param index The subscript.
-   * @param value An int value.
-   * @return this.
-   * @throws JSONException If the index is negative.
-   */
-  public JSONArray put(int index, int value) throws JSONException {
-    this.put(index, new Integer(value));
-    return this;
-  }
-
-
-  /**
-   * Put or replace a long value. If the index is greater than the length of the JSONArray, then
-   * null elements will be added as necessary to pad it out.
-   * 
-   * @param index The subscript.
-   * @param value A long value.
-   * @return this.
-   * @throws JSONException If the index is negative.
-   */
-  public JSONArray put(int index, long value) throws JSONException {
-    this.put(index, new Long(value));
-    return this;
-  }
-
-
-  /**
-   * Put a value in the JSONArray, where the value will be a JSONObject that is produced from a Map.
-   * 
-   * @param index The subscript.
-   * @param value The Map value.
-   * @return this.
-   * @throws JSONException If the index is negative or if the the value is an invalid number.
-   */
-  public JSONArray put(int index, Map value) throws JSONException {
-    this.put(index, new JSONObject(value));
-    return this;
-  }
-
-
-  /**
-   * Put or replace an object value in the JSONArray. If the index is greater than the length of the
-   * JSONArray, then null elements will be added as necessary to pad it out.
-   * 
-   * @param index The subscript.
-   * @param value The value to put into the array. The value should be a Boolean, Double, Integer,
-   *        JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
-   * @return this.
-   * @throws JSONException If the index is negative or if the the value is an invalid number.
-   */
-  public JSONArray put(int index, Object value) throws JSONException {
-    JSONObject.testValidity(value);
-    if (index < 0) {
-      throw new JSONException("JSONArray[" + index + "] not found.");
-    }
-    if (index < this.length()) {
-      this.myArrayList.set(index, value);
-    } else {
-      while (index != this.length()) {
-        this.put(JSONObject.NULL);
-      }
-      this.put(value);
-    }
-    return this;
-  }
-
-
-  /**
-   * Remove an index and close the hole.
-   * 
-   * @param index The index of the element to be removed.
-   * @return The value that was associated with the index, or null if there was no value.
-   */
-  public Object remove(int index) {
-    Object o = this.opt(index);
-    this.myArrayList.remove(index);
-    return o;
-  }
-
-
-  /**
-   * Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray.
-   * 
-   * @param names A JSONArray containing a list of key strings. These will be paired with the
-   *        values.
-   * @return A JSONObject, or null if there are no names or if this JSONArray has no values.
-   * @throws JSONException If any of the names are null.
-   */
-  public JSONObject toJSONObject(JSONArray names) throws JSONException {
-    if (names == null || names.length() == 0 || this.length() == 0) {
-      return null;
-    }
-    JSONObject jo = new JSONObject();
-    for (int i = 0; i < names.length(); i += 1) {
-      jo.put(names.getString(i), this.opt(i));
-    }
-    return jo;
-  }
-
-
-  /**
-   * Make a JSON text of this JSONArray. For compactness, no unnecessary whitespace is added. If it
-   * is not possible to produce a syntactically correct JSON text then null will be returned
-   * instead. This could occur if the array contains an invalid number.
-   * <p>
-   * Warning: This method assumes that the data structure is acyclical.
-   *
-   * @return a printable, displayable, transmittable representation of the array.
-   */
-  public String toString() {
-    try {
-      return '[' + this.join(",") + ']';
-    } catch (Exception e) {
-      return null;
-    }
-  }
-
-
-  /**
-   * Make a prettyprinted JSON text of this JSONArray. Warning: This method assumes that the data
-   * structure is acyclical.
-   * 
-   * @param indentFactor The number of spaces to add to each level of indentation.
-   * @return a printable, displayable, transmittable representation of the object, beginning with
-   *         <code>[</code>&nbsp;<small>(left bracket)</small> and ending with
-   *         <code>]</code>&nbsp;<small>(right bracket)</small>.
-   * @throws JSONException
-   */
-  public String toString(int indentFactor) throws JSONException {
-    StringWriter sw = new StringWriter();
-    synchronized (sw.getBuffer()) {
-      return this.write(sw, indentFactor, 0).toString();
-    }
-  }
-
-  /**
-   * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is
-   * added.
-   * <p>
-   * Warning: This method assumes that the data structure is acyclical.
-   *
-   * @return The writer.
-   * @throws JSONException
-   */
-  public Writer write(Writer writer) throws JSONException {
-    return this.write(writer, 0, 0);
-  }
-
-  /**
-   * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is
-   * added.
-   * <p>
-   * Warning: This method assumes that the data structure is acyclical.
-   *
-   * @param indentFactor The number of spaces to add to each level of indentation.
-   * @param indent The indention of the top level.
-   * @return The writer.
-   * @throws JSONException
-   */
-  Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
-    try {
-      boolean commanate = false;
-      int length = this.length();
-      writer.write('[');
-
-      if (length == 1) {
-        JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent);
-      } else if (length != 0) {
-        final int newindent = indent + indentFactor;
-
-        for (int i = 0; i < length; i += 1) {
-          if (commanate) {
-            writer.write(',');
-          }
-          if (indentFactor > 0) {
-            writer.write('\n');
-          }
-          JSONObject.indent(writer, newindent);
-          JSONObject.writeValue(writer, this.myArrayList.get(i), indentFactor, newindent);
-          commanate = true;
-        }
-        if (indentFactor > 0) {
-          writer.write('\n');
-        }
-        JSONObject.indent(writer, indent);
-      }
-      writer.write(']');
-      return writer;
-    } catch (IOException e) {
-      throw new JSONException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/JSONException.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONException.java b/geode-json/src/main/java/org/json/JSONException.java
deleted file mode 100755
index b65efe2..0000000
--- a/geode-json/src/main/java/org/json/JSONException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.json;
-
-/**
- * The JSONException is thrown by the JSON.org classes when things are amiss.
- * 
- * @author JSON.org
- * @version 2010-12-24
- */
-public class JSONException extends Exception {
-  private static final long serialVersionUID = 0;
-  private Throwable cause;
-
-  /**
-   * Constructs a JSONException with an explanatory message.
-   * 
-   * @param message Detail about the reason for the exception.
-   */
-  public JSONException(String message) {
-    super(message);
-  }
-
-  public JSONException(Throwable cause) {
-    super(cause.getMessage());
-    this.cause = cause;
-  }
-
-  public Throwable getCause() {
-    return this.cause;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/JSONML.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONML.java b/geode-json/src/main/java/org/json/JSONML.java
deleted file mode 100755
index b535614..0000000
--- a/geode-json/src/main/java/org/json/JSONML.java
+++ /dev/null
@@ -1,454 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2008 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-import java.util.Iterator;
-
-
-/**
- * This provides static methods to convert an XML text into a JSONArray or JSONObject, and to covert
- * a JSONArray or JSONObject into an XML text using the JsonML transform.
- * 
- * @author JSON.org
- * @version 2012-03-28
- */
-public class JSONML {
-
-  /**
-   * Parse XML values and store them in a JSONArray.
-   * 
-   * @param x The XMLTokener containing the source string.
-   * @param arrayForm true if array form, false if object form.
-   * @param ja The JSONArray that is containing the current tag or null if we are at the outermost
-   *        level.
-   * @return A JSONArray if the value is the outermost tag, otherwise null.
-   * @throws JSONException
-   */
-  private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja) throws JSONException {
-    String attribute;
-    char c;
-    String closeTag = null;
-    int i;
-    JSONArray newja = null;
-    JSONObject newjo = null;
-    Object token;
-    String tagName = null;
-
-    // Test for and skip past these forms:
-    // <!-- ... -->
-    // <![ ... ]]>
-    // <! ... >
-    // <? ... ?>
-
-    while (true) {
-      if (!x.more()) {
-        throw x.syntaxError("Bad XML");
-      }
-      token = x.nextContent();
-      if (token == XML.LT) {
-        token = x.nextToken();
-        if (token instanceof Character) {
-          if (token == XML.SLASH) {
-
-            // Close tag </
-
-            token = x.nextToken();
-            if (!(token instanceof String)) {
-              throw new JSONException("Expected a closing name instead of '" + token + "'.");
-            }
-            if (x.nextToken() != XML.GT) {
-              throw x.syntaxError("Misshaped close tag");
-            }
-            return token;
-          } else if (token == XML.BANG) {
-
-            // <!
-
-            c = x.next();
-            if (c == '-') {
-              if (x.next() == '-') {
-                x.skipPast("-->");
-              } else {
-                x.back();
-              }
-            } else if (c == '[') {
-              token = x.nextToken();
-              if (token.equals("CDATA") && x.next() == '[') {
-                if (ja != null) {
-                  ja.put(x.nextCDATA());
-                }
-              } else {
-                throw x.syntaxError("Expected 'CDATA['");
-              }
-            } else {
-              i = 1;
-              do {
-                token = x.nextMeta();
-                if (token == null) {
-                  throw x.syntaxError("Missing '>' after '<!'.");
-                } else if (token == XML.LT) {
-                  i += 1;
-                } else if (token == XML.GT) {
-                  i -= 1;
-                }
-              } while (i > 0);
-            }
-          } else if (token == XML.QUEST) {
-
-            // <?
-
-            x.skipPast("?>");
-          } else {
-            throw x.syntaxError("Misshaped tag");
-          }
-
-          // Open tag <
-
-        } else {
-          if (!(token instanceof String)) {
-            throw x.syntaxError("Bad tagName '" + token + "'.");
-          }
-          tagName = (String) token;
-          newja = new JSONArray();
-          newjo = new JSONObject();
-          if (arrayForm) {
-            newja.put(tagName);
-            if (ja != null) {
-              ja.put(newja);
-            }
-          } else {
-            newjo.put("tagName", tagName);
-            if (ja != null) {
-              ja.put(newjo);
-            }
-          }
-          token = null;
-          for (;;) {
-            if (token == null) {
-              token = x.nextToken();
-            }
-            if (token == null) {
-              throw x.syntaxError("Misshaped tag");
-            }
-            if (!(token instanceof String)) {
-              break;
-            }
-
-            // attribute = value
-
-            attribute = (String) token;
-            if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) {
-              throw x.syntaxError("Reserved attribute.");
-            }
-            token = x.nextToken();
-            if (token == XML.EQ) {
-              token = x.nextToken();
-              if (!(token instanceof String)) {
-                throw x.syntaxError("Missing value");
-              }
-              newjo.accumulate(attribute, XML.stringToValue((String) token));
-              token = null;
-            } else {
-              newjo.accumulate(attribute, "");
-            }
-          }
-          if (arrayForm && newjo.length() > 0) {
-            newja.put(newjo);
-          }
-
-          // Empty tag <.../>
-
-          if (token == XML.SLASH) {
-            if (x.nextToken() != XML.GT) {
-              throw x.syntaxError("Misshaped tag");
-            }
-            if (ja == null) {
-              if (arrayForm) {
-                return newja;
-              } else {
-                return newjo;
-              }
-            }
-
-            // Content, between <...> and </...>
-
-          } else {
-            if (token != XML.GT) {
-              throw x.syntaxError("Misshaped tag");
-            }
-            closeTag = (String) parse(x, arrayForm, newja);
-            if (closeTag != null) {
-              if (!closeTag.equals(tagName)) {
-                throw x.syntaxError("Mismatched '" + tagName + "' and '" + closeTag + "'");
-              }
-              tagName = null;
-              if (!arrayForm && newja.length() > 0) {
-                newjo.put("childNodes", newja);
-              }
-              if (ja == null) {
-                if (arrayForm) {
-                  return newja;
-                } else {
-                  return newjo;
-                }
-              }
-            }
-          }
-        }
-      } else {
-        if (ja != null) {
-          ja.put(token instanceof String ? XML.stringToValue((String) token) : token);
-        }
-      }
-    }
-  }
-
-
-  /**
-   * Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML
-   * transform. Each XML tag is represented as a JSONArray in which the first element is the tag
-   * name. If the tag has attributes, then the second element will be JSONObject containing the
-   * name/value pairs. If the tag contains children, then strings and JSONArrays will represent the
-   * child tags. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
-   * 
-   * @param string The source string.
-   * @return A JSONArray containing the structured data from the XML string.
-   * @throws JSONException
-   */
-  public static JSONArray toJSONArray(String string) throws JSONException {
-    return toJSONArray(new XMLTokener(string));
-  }
-
-
-  /**
-   * Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML
-   * transform. Each XML tag is represented as a JSONArray in which the first element is the tag
-   * name. If the tag has attributes, then the second element will be JSONObject containing the
-   * name/value pairs. If the tag contains children, then strings and JSONArrays will represent the
-   * child content and tags. Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
-   * 
-   * @param x An XMLTokener.
-   * @return A JSONArray containing the structured data from the XML string.
-   * @throws JSONException
-   */
-  public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
-    return (JSONArray) parse(x, true, null);
-  }
-
-
-  /**
-   * Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML
-   * transform. Each XML tag is represented as a JSONObject with a "tagName" property. If the tag
-   * has attributes, then the attributes will be in the JSONObject as properties. If the tag
-   * contains children, the object will have a "childNodes" property which will be an array of
-   * strings and JsonML JSONObjects.
-   * 
-   * Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
-   * 
-   * @param x An XMLTokener of the XML source text.
-   * @return A JSONObject containing the structured data from the XML string.
-   * @throws JSONException
-   */
-  public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
-    return (JSONObject) parse(x, false, null);
-  }
-
-
-  /**
-   * Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML
-   * transform. Each XML tag is represented as a JSONObject with a "tagName" property. If the tag
-   * has attributes, then the attributes will be in the JSONObject as properties. If the tag
-   * contains children, the object will have a "childNodes" property which will be an array of
-   * strings and JsonML JSONObjects.
-   * 
-   * Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
-   * 
-   * @param string The XML source text.
-   * @return A JSONObject containing the structured data from the XML string.
-   * @throws JSONException
-   */
-  public static JSONObject toJSONObject(String string) throws JSONException {
-    return toJSONObject(new XMLTokener(string));
-  }
-
-
-  /**
-   * Reverse the JSONML transformation, making an XML text from a JSONArray.
-   * 
-   * @param ja A JSONArray.
-   * @return An XML string.
-   * @throws JSONException
-   */
-  public static String toString(JSONArray ja) throws JSONException {
-    int i;
-    JSONObject jo;
-    String key;
-    Iterator keys;
-    int length;
-    Object object;
-    StringBuffer sb = new StringBuffer();
-    String tagName;
-    String value;
-
-    // Emit <tagName
-
-    tagName = ja.getString(0);
-    XML.noSpace(tagName);
-    tagName = XML.escape(tagName);
-    sb.append('<');
-    sb.append(tagName);
-
-    object = ja.opt(1);
-    if (object instanceof JSONObject) {
-      i = 2;
-      jo = (JSONObject) object;
-
-      // Emit the attributes
-
-      keys = jo.keys();
-      while (keys.hasNext()) {
-        key = keys.next().toString();
-        XML.noSpace(key);
-        value = jo.optString(key);
-        if (value != null) {
-          sb.append(' ');
-          sb.append(XML.escape(key));
-          sb.append('=');
-          sb.append('"');
-          sb.append(XML.escape(value));
-          sb.append('"');
-        }
-      }
-    } else {
-      i = 1;
-    }
-
-    // Emit content in body
-
-    length = ja.length();
-    if (i >= length) {
-      sb.append('/');
-      sb.append('>');
-    } else {
-      sb.append('>');
-      do {
-        object = ja.get(i);
-        i += 1;
-        if (object != null) {
-          if (object instanceof String) {
-            sb.append(XML.escape(object.toString()));
-          } else if (object instanceof JSONObject) {
-            sb.append(toString((JSONObject) object));
-          } else if (object instanceof JSONArray) {
-            sb.append(toString((JSONArray) object));
-          }
-        }
-      } while (i < length);
-      sb.append('<');
-      sb.append('/');
-      sb.append(tagName);
-      sb.append('>');
-    }
-    return sb.toString();
-  }
-
-  /**
-   * Reverse the JSONML transformation, making an XML text from a JSONObject. The JSONObject must
-   * contain a "tagName" property. If it has children, then it must have a "childNodes" property
-   * containing an array of objects. The other properties are attributes with string values.
-   * 
-   * @param jo A JSONObject.
-   * @return An XML string.
-   * @throws JSONException
-   */
-  public static String toString(JSONObject jo) throws JSONException {
-    StringBuffer sb = new StringBuffer();
-    int i;
-    JSONArray ja;
-    String key;
-    Iterator keys;
-    int length;
-    Object object;
-    String tagName;
-    String value;
-
-    // Emit <tagName
-
-    tagName = jo.optString("tagName");
-    if (tagName == null) {
-      return XML.escape(jo.toString());
-    }
-    XML.noSpace(tagName);
-    tagName = XML.escape(tagName);
-    sb.append('<');
-    sb.append(tagName);
-
-    // Emit the attributes
-
-    keys = jo.keys();
-    while (keys.hasNext()) {
-      key = keys.next().toString();
-      if (!"tagName".equals(key) && !"childNodes".equals(key)) {
-        XML.noSpace(key);
-        value = jo.optString(key);
-        if (value != null) {
-          sb.append(' ');
-          sb.append(XML.escape(key));
-          sb.append('=');
-          sb.append('"');
-          sb.append(XML.escape(value));
-          sb.append('"');
-        }
-      }
-    }
-
-    // Emit content in body
-
-    ja = jo.optJSONArray("childNodes");
-    if (ja == null) {
-      sb.append('/');
-      sb.append('>');
-    } else {
-      sb.append('>');
-      length = ja.length();
-      for (i = 0; i < length; i += 1) {
-        object = ja.get(i);
-        if (object != null) {
-          if (object instanceof String) {
-            sb.append(XML.escape(object.toString()));
-          } else if (object instanceof JSONObject) {
-            sb.append(toString((JSONObject) object));
-          } else if (object instanceof JSONArray) {
-            sb.append(toString((JSONArray) object));
-          } else {
-            sb.append(object.toString());
-          }
-        }
-      }
-      sb.append('<');
-      sb.append('/');
-      sb.append(tagName);
-      sb.append('>');
-    }
-    return sb.toString();
-  }
-}


[29/51] [abbrv] geode git commit: GEODE-2461: remove json4s-ast_2.10 as explicit dependency

Posted by ds...@apache.org.
GEODE-2461: remove json4s-ast_2.10 as explicit dependency


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/b5cbaed1
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/b5cbaed1
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/b5cbaed1

Branch: refs/heads/feature/GEM-1195
Commit: b5cbaed14ae11101f99fd9ff79c90c67fdcd737f
Parents: 1a36d36
Author: Kirk Lund <kl...@apache.org>
Authored: Mon Feb 27 15:55:54 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Feb 28 16:53:53 2017 -0800

----------------------------------------------------------------------
 geode-assembly/src/test/resources/expected_jars.txt | 1 -
 geode-web-api/build.gradle                          | 1 -
 gradle/dependency-versions.properties               | 1 -
 3 files changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b5cbaed1/geode-assembly/src/test/resources/expected_jars.txt
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/resources/expected_jars.txt b/geode-assembly/src/test/resources/expected_jars.txt
index a9a5a79..b7d1dc2 100644
--- a/geode-assembly/src/test/resources/expected_jars.txt
+++ b/geode-assembly/src/test/resources/expected_jars.txt
@@ -36,7 +36,6 @@ jgroups
 jline
 jna
 jopt-simple
-json4s-ast
 log4j-api
 log4j-core
 log4j-jcl

http://git-wip-us.apache.org/repos/asf/geode/blob/b5cbaed1/geode-web-api/build.gradle
----------------------------------------------------------------------
diff --git a/geode-web-api/build.gradle b/geode-web-api/build.gradle
index 8b22bd8..795812f 100755
--- a/geode-web-api/build.gradle
+++ b/geode-web-api/build.gradle
@@ -33,7 +33,6 @@ dependencies {
   compile('io.springfox:springfox-swagger-ui:' + project.'springfox.version') {
     exclude module: 'slf4j-api'
   }
-  compile 'org.json4s:json4s-ast_2.10:' + project.'json4s.version'
   compile 'org.springframework:spring-beans:' + project.'springframework.version'
   compile 'org.springframework.security:spring-security-core:' + project.'spring-security.version'
   compile 'org.springframework.security:spring-security-web:' + project.'spring-security.version'

http://git-wip-us.apache.org/repos/asf/geode/blob/b5cbaed1/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index d4a104e..aca65fa 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -59,7 +59,6 @@ jna.version = 4.0.0
 jopt-simple.version = 5.0.3
 json-path.version = 2.2.0
 json-path-assert.version = 2.2.0
-json4s.version = 3.2.4
 junit.version = 4.12
 junit-quickcheck.version = 0.7
 JUnitParams.version = 1.0.6


[51/51] [abbrv] geode git commit: added unit test

Posted by ds...@apache.org.
added unit test


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/f4687479
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/f4687479
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/f4687479

Branch: refs/heads/feature/GEM-1195
Commit: f46874799d28f91fed724c44f1623b1f1cfa1e57
Parents: d39f26c
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Fri Mar 3 16:00:25 2017 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Fri Mar 3 16:00:25 2017 -0800

----------------------------------------------------------------------
 .../internal/cache/ColocatedPRJUnitTest.java    | 45 ++++++++++++++++++++
 .../cache/PartitionedRegionTestHelper.java      |  9 +++-
 2 files changed, 52 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f4687479/geode-core/src/test/java/org/apache/geode/internal/cache/ColocatedPRJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ColocatedPRJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ColocatedPRJUnitTest.java
new file mode 100644
index 0000000..cceab0c
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ColocatedPRJUnitTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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 org.apache.geode.internal.cache;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.PartitionAttributes;
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class ColocatedPRJUnitTest {
+  @SuppressWarnings("rawtypes")
+  @Test
+  public void destroyColocatedPRCheckForLeak() {
+    PartitionedRegion parent = (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("PARENT");
+    List<PartitionedRegion> colocatedList = parent.getColocatedByList();
+    assertEquals(0, colocatedList.size());
+    PartitionAttributes PRatts = new PartitionAttributesFactory().setColocatedWith("/PARENT").create();
+    PartitionedRegion child = (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("CHILD", PRatts);
+    assertTrue(colocatedList.contains(child));
+    child.destroyRegion();
+    assertFalse(colocatedList.contains(child));
+  }
+}
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/f4687479/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java
index 42c48ac..f9cd8b5 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionTestHelper.java
@@ -49,9 +49,14 @@ public class PartitionedRegionTestHelper
    */
 
   public static Region createPartionedRegion(String regionname) throws RegionExistsException {
+    return createPartionedRegion(regionname, new PartitionAttributesFactory().create());
+  }
+  /**
+   * This method creates a partitioned region with the given PR attributes. The cache created is a
+   * loner, so this is only suitable for single VM tests.
+   */
+  public static Region createPartionedRegion(String regionname, PartitionAttributes prattribs) throws RegionExistsException {
     AttributesFactory attribFactory = new AttributesFactory();
-    PartitionAttributesFactory paf = new PartitionAttributesFactory();
-    PartitionAttributes prattribs = paf.create();
     attribFactory.setDataPolicy(DataPolicy.PARTITION);
     attribFactory.setPartitionAttributes(prattribs);
     RegionAttributes regionAttribs = attribFactory.create();


[38/51] [abbrv] geode git commit: Merge branch 'feature/GEODE-2562' into develop

Posted by ds...@apache.org.
Merge branch 'feature/GEODE-2562' into develop


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/45c150d8
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/45c150d8
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/45c150d8

Branch: refs/heads/feature/GEM-1195
Commit: 45c150d86c64e9c458881fc898c81629d97b268f
Parents: 319304e c0d43b3
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Mar 1 15:46:48 2017 -0800
Committer: Karen Miller <km...@pivotal.io>
Committed: Wed Mar 1 15:46:48 2017 -0800

----------------------------------------------------------------------
 geode-docs/getting_started/product_intro.html.md.erb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[40/51] [abbrv] geode git commit: Improved colocatedByList by getting rid of unneeded synchronization and making the field final.

Posted by ds...@apache.org.
Improved colocatedByList by getting rid of unneeded synchronization
and making the field final.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d6761a15
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d6761a15
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d6761a15

Branch: refs/heads/feature/GEM-1195
Commit: d6761a15be375be8a07c9af9a3a4034a6d658984
Parents: 5b78f5d
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Mar 1 16:46:36 2017 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Mar 1 16:46:36 2017 -0800

----------------------------------------------------------------------
 .../apache/geode/cache/query/internal/DefaultQuery.java |  4 ++--
 .../apache/geode/internal/cache/PartitionedRegion.java  | 12 ++++--------
 2 files changed, 6 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d6761a15/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java
index 8bfd4fa..a721091 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQuery.java
@@ -650,8 +650,8 @@ public class DefaultQuery implements Query {
             continue;
           }
           other = allPRs;
-          if ((((PartitionedRegion) eachPR).colocatedByList.contains(allPRs)
-              || ((PartitionedRegion) allPRs).colocatedByList.contains(eachPR))) {
+          if ((((PartitionedRegion) eachPR).getColocatedByList().contains(allPRs)
+              || ((PartitionedRegion) allPRs).getColocatedByList().contains(eachPR))) {
             colocated = true;
             break;
           }

http://git-wip-us.apache.org/repos/asf/geode/blob/d6761a15/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
index 7bc6e97..588bc33 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
@@ -600,7 +600,7 @@ public class PartitionedRegion extends LocalRegion
 
   private byte fixedPASet;
 
-  public List<PartitionedRegion> colocatedByList = new CopyOnWriteArrayList<PartitionedRegion>();
+  private final List<PartitionedRegion> colocatedByList = new CopyOnWriteArrayList<PartitionedRegion>();
 
   private final PartitionListener[] partitionListeners;
 
@@ -670,9 +670,7 @@ public class PartitionedRegion extends LocalRegion
     this.colocatedWithRegion = ColocationHelper.getColocatedRegion(this);
 
     if (colocatedWithRegion != null) {
-      synchronized (colocatedWithRegion.colocatedByList) {
-        colocatedWithRegion.colocatedByList.add(this);
-      }
+      colocatedWithRegion.getColocatedByList().add(this);
     }
 
     if (colocatedWithRegion != null && !internalRegionArgs.isUsedForParallelGatewaySenderQueue()) {
@@ -786,7 +784,7 @@ public class PartitionedRegion extends LocalRegion
     return parallelGatewaySenderIds;
   }
 
-  List<PartitionedRegion> getColocatedByList() {
+  public List<PartitionedRegion> getColocatedByList() {
     return this.colocatedByList;
   }
 
@@ -7912,9 +7910,7 @@ public class PartitionedRegion extends LocalRegion
       }
     }
     if (colocatedWithRegion != null) {
-      synchronized (colocatedWithRegion.colocatedByList) {
-        colocatedWithRegion.colocatedByList.remove(this);
-      }
+      colocatedWithRegion.getColocatedByList().remove(this);
     }
 
     RegionLogger.logDestroy(getName(), cache.getMyId(), null, op.isClose());


[46/51] [abbrv] geode git commit: GEODE-2267: Enhance server/locator startup rules to include workingDir - add missed checkin

Posted by ds...@apache.org.
GEODE-2267: Enhance server/locator startup rules to include workingDir - add missed checkin


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9766cf23
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9766cf23
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9766cf23

Branch: refs/heads/feature/GEM-1195
Commit: 9766cf2334a8f84c5b90fc29d8e73fd1c49858dc
Parents: a9f0d22
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Thu Mar 2 11:22:12 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Thu Mar 2 11:22:56 2017 -0800

----------------------------------------------------------------------
 .../geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/9766cf23/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
index c4bb152..9cfb5ec 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
@@ -64,7 +64,7 @@ public class PeerSecurityWithEmbeddedLocatorDUnitTest {
       ServerStarterRule serverStarter = new ServerStarterRule();
       serverStarter.before();
       LocatorServerStartupRule.serverStarter = serverStarter;
-      assertThatThrownBy(() -> serverStarter.startServer(locatorPort))
+      assertThatThrownBy(() -> serverStarter.startServer(server2Props, locatorPort))
           .isInstanceOf(GemFireSecurityException.class)
           .hasMessageContaining("Security check failed. Authentication error");
     });


[41/51] [abbrv] geode git commit: GEODE-2572: getCache method implemented for LuceneService

Posted by ds...@apache.org.
GEODE-2572: getCache method implemented for LuceneService

	* getCache method implemented for LuceneService
	* simple integration test to validate the result of LuceneService.getCache


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/ab565067
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/ab565067
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/ab565067

Branch: refs/heads/feature/GEM-1195
Commit: ab5650672077bd52109e2687ab9d91384a3fe12b
Parents: 8127659
Author: nabarunnag <na...@cs.wisc.edu>
Authored: Wed Mar 1 22:44:55 2017 -0800
Committer: nabarunnag <na...@cs.wisc.edu>
Committed: Wed Mar 1 22:44:55 2017 -0800

----------------------------------------------------------------------
 .../java/org/apache/geode/cache/lucene/LuceneService.java   | 9 +++++++++
 .../geode/cache/lucene/internal/LuceneServiceImpl.java      | 5 +++++
 .../lucene/internal/LuceneServiceImplIntegrationTest.java   | 9 +++++++++
 3 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/ab565067/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
index 5cfae59..704abcd 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
@@ -18,6 +18,7 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.geode.cache.Cache;
 import org.apache.lucene.analysis.Analyzer;
 
 import org.apache.geode.annotations.Experimental;
@@ -138,6 +139,14 @@ public interface LuceneService {
   public LuceneQueryFactory createLuceneQueryFactory();
 
   /**
+   * returns the cache to which the LuceneService belongs
+   *
+   * @return Cache
+   */
+  public Cache getCache();
+
+
+  /**
    * wait until the current entries in cache are indexed
    * 
    * @param indexName index name

http://git-wip-us.apache.org/repos/asf/geode/blob/ab565067/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index a1a6ef3..5c908f5 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -81,6 +81,11 @@ public class LuceneServiceImpl implements InternalLuceneService {
 
   }
 
+  @Override
+  public Cache getCache() {
+    return this.cache;
+  }
+
   public void init(final Cache cache) {
     if (cache == null) {
       throw new IllegalStateException(LocalizedStrings.CqService_CACHE_IS_NULL.toLocalizedString());

http://git-wip-us.apache.org/repos/asf/geode/blob/ab565067/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplIntegrationTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplIntegrationTest.java
index 9b382e6..80d9324 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplIntegrationTest.java
@@ -34,6 +34,7 @@ import org.junit.rules.ExpectedException;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 @Category(IntegrationTest.class)
 public class LuceneServiceImplIntegrationTest {
@@ -52,6 +53,14 @@ public class LuceneServiceImplIntegrationTest {
     assertNotNull(luceneService);
   }
 
+  @Test
+  public void getCacheShouldReturnTheCorrectCache() {
+    cache = getCache();
+    new LuceneServiceImpl().init(cache);
+    LuceneService service = LuceneServiceProvider.get(cache);
+    assertTrue(service.getCache().equals(cache));
+  }
+
   // lucene service will register query execution function on initialization
   @Test
   public void shouldRegisterQueryFunction() {


[09/51] [abbrv] geode git commit: GEODE-2142: cyclical dependency in gradle build

Posted by ds...@apache.org.
GEODE-2142: cyclical dependency in gradle build


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/cd58f1ff
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/cd58f1ff
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/cd58f1ff

Branch: refs/heads/feature/GEM-1195
Commit: cd58f1ffc5beca3b05c15c2dcd9ff609e6313008
Parents: eac0bb8
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Feb 17 15:50:57 2017 -0800
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Mon Feb 27 07:18:55 2017 -0800

----------------------------------------------------------------------
 geode-json/build.gradle | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/cd58f1ff/geode-json/build.gradle
----------------------------------------------------------------------
diff --git a/geode-json/build.gradle b/geode-json/build.gradle
index 5715685..8a1727e 100644
--- a/geode-json/build.gradle
+++ b/geode-json/build.gradle
@@ -16,7 +16,4 @@
  */
 
 dependencies {
-    compile project(':geode-core')
-    compile project(':geode-common')
-    testCompile files(project(':geode-core').sourceSets.test.output)
 }
\ No newline at end of file


[26/51] [abbrv] geode git commit: GEODE-880 Remove unused classes

Posted by ds...@apache.org.
GEODE-880 Remove unused classes

This closes #409


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/4fbc6412
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/4fbc6412
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/4fbc6412

Branch: refs/heads/feature/GEM-1195
Commit: 4fbc6412f7daf82586ce3b80a6c7aeb0d93a781e
Parents: bc32a76
Author: Anthony Baker <ab...@apache.org>
Authored: Mon Feb 27 22:04:46 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Feb 28 14:32:53 2017 -0800

----------------------------------------------------------------------
 .../org/apache/geode/internal/JavaExec.java     | 71 ---------------
 .../org/apache/geode/internal/LongBuffer.java   | 96 --------------------
 2 files changed, 167 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/4fbc6412/geode-core/src/test/java/org/apache/geode/internal/JavaExec.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/JavaExec.java b/geode-core/src/test/java/org/apache/geode/internal/JavaExec.java
deleted file mode 100644
index 7803d5d..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/JavaExec.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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 org.apache.geode.internal;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Used to exec a java main class in its own vm
- *
- *
- */
-public class JavaExec {
-  /**
-   * Creates a java process that executes the given main class and waits for the process to
-   * terminate.
-   * 
-   * @return a {@link ProcessOutputReader} that can be used to get the exit code and stdout+stderr
-   *         of the terminated process.
-   */
-  public static ProcessOutputReader fg(Class main) throws IOException {
-    return fg(main, null, null);
-  }
-
-  /**
-   * Creates a java process that executes the given main class and waits for the process to
-   * terminate.
-   * 
-   * @return a {@link ProcessOutputReader} that can be used to get the exit code and stdout+stderr
-   *         of the terminated process.
-   */
-  public static ProcessOutputReader fg(Class main, String[] vmArgs, String[] mainArgs)
-      throws IOException {
-    File javabindir = new File(System.getProperty("java.home"), "bin");
-    File javaexe = new File(javabindir, "java");
-
-    int bits = Integer.getInteger("sun.arch.data.model", 0).intValue();
-    String vmKindArg = (bits == 64) ? "-d64" : null;
-
-    ArrayList argList = new ArrayList();
-    argList.add(javaexe.getPath());
-    if (vmKindArg != null) {
-      argList.add(vmKindArg);
-    }
-    // argList.add("-Dgemfire.systemDirectory=" +
-    // GemFireConnectionFactory.getDefaultSystemDirectory());
-    argList.add("-Djava.class.path=" + System.getProperty("java.class.path"));
-    argList.add("-Djava.library.path=" + System.getProperty("java.library.path"));
-    if (vmArgs != null) {
-      argList.addAll(Arrays.asList(vmArgs));
-    }
-    argList.add(main.getName());
-    if (mainArgs != null) {
-      argList.addAll(Arrays.asList(mainArgs));
-    }
-    String[] cmd = (String[]) argList.toArray(new String[argList.size()]);
-    return new ProcessOutputReader(Runtime.getRuntime().exec(cmd));
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/4fbc6412/geode-core/src/test/java/org/apache/geode/internal/LongBuffer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/LongBuffer.java b/geode-core/src/test/java/org/apache/geode/internal/LongBuffer.java
deleted file mode 100644
index addd5ea..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/LongBuffer.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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 org.apache.geode.internal;
-
-public class LongBuffer {
-
-  private long data[]; // the array implementing the buffer
-  public int length; // number of valid elements in the buffer,
-  // data[0.. this.length-1 ] are the valid elements
-
-  /** construct a new instance of the specified capacity */
-  LongBuffer(int size) {
-    data = new long[size];
-    length = 0;
-  }
-
-  /** construct a new instance, installing the argument as the data array */
-  LongBuffer(long[] someIds) {
-    data = someIds;
-    length = someIds.length;
-  }
-
-  /** change the capacity to the specified size, without loosing elements */
-  private void changeSize(int newSize) {
-    if (newSize >= length) { // only change size if we won't loose data
-      long[] oldData = data;
-      int oldLength = length;
-      data = new long[newSize];
-      length = 0;
-      add(oldData, oldLength);
-    }
-  }
-
-
-  public synchronized void add(long id) {
-    if (length >= data.length) {
-      // if buffer is large, don't double to reduce out-of-mem problems
-      if (length > 10000)
-        changeSize(length + 2000);
-      else
-        changeSize(length * 2);
-    }
-    data[length++] = id;
-  }
-
-  /** add argIds[0..argLength] , growing as required */
-  public synchronized void add(long[] argIds, int argLength) {
-    if (length + argLength > data.length) {
-      long[] oldData = data;
-      data = new long[argLength + length];
-      System.arraycopy(oldData, 0, data, 0, oldData.length);
-    }
-    System.arraycopy(argIds, 0, data, length, argLength);
-    length += argLength;
-  }
-
-  /** add all of argIds, growing as required */
-  public synchronized void add(long[] argIds) {
-    add(argIds, argIds.length);
-  }
-
-  /** add all elements in the argument, growing as required */
-  public synchronized void add(LongBuffer argBuf) {
-    add(argBuf.data, argBuf.length);
-  }
-
-  public synchronized long get(int index) {
-    if (index >= length)
-      throw new IndexOutOfBoundsException(" index " + index + " length " + length);
-    return data[index];
-  }
-
-  public synchronized long getAndStore(int index, int newValue) {
-    if (index >= length)
-      throw new IndexOutOfBoundsException(" index " + index + " length " + length);
-    long result = data[index];
-    data[index] = newValue;
-    return result;
-  }
-
-  public synchronized void clear() {
-    length = 0;
-  }
-}


[28/51] [abbrv] geode git commit: GEODE-2547: Interest registration no longer causes a CacheLoader to be invoked

Posted by ds...@apache.org.
GEODE-2547: Interest registration no longer causes a CacheLoader to be invoked


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/1a36d36e
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/1a36d36e
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/1a36d36e

Branch: refs/heads/feature/GEM-1195
Commit: 1a36d36ec90d91094689cc3cb30c21be9b25276b
Parents: fb1fdf9
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Tue Feb 28 13:43:50 2017 -0800
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Tue Feb 28 15:55:38 2017 -0800

----------------------------------------------------------------------
 .../java/org/apache/geode/cache/Operation.java  | 16 ++++
 .../geode/internal/cache/DistributedRegion.java | 30 ++++--
 .../org/apache/geode/internal/cache/OpType.java |  2 +
 .../cache/tier/sockets/BaseCommand.java         | 18 ++--
 .../tier/sockets/InterestListDUnitTest.java     | 99 ++++++++++++++++++++
 5 files changed, 148 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/1a36d36e/geode-core/src/main/java/org/apache/geode/cache/Operation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/Operation.java b/geode-core/src/main/java/org/apache/geode/cache/Operation.java
index 9b2227b..d835b6c 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/Operation.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/Operation.java
@@ -49,6 +49,7 @@ public final class Operation implements java.io.Serializable {
   private static final byte OP_TYPE_CLEAR = OpType.CLEAR;
   private static final byte OP_TYPE_MARKER = OpType.MARKER;
   private static final byte OP_TYPE_UPDATE_VERSION = OpType.UPDATE_ENTRY_VERSION;
+  private static final byte OP_TYPE_GET_FOR_REGISTER_INTEREST = OpType.GET_FOR_REGISTER_INTEREST;
 
   private static final int OP_DETAILS_NONE = 0;
   private static final int OP_DETAILS_SEARCH = 1;
@@ -531,6 +532,14 @@ public final class Operation implements java.io.Serializable {
       false, // isRegion
       OP_TYPE_DESTROY, OP_DETAILS_REMOVEALL);
 
+  /**
+   * A 'get for register interest' operation.
+   */
+  public static final Operation GET_FOR_REGISTER_INTEREST =
+      new Operation("GET_FOR_REGISTER_INTEREST", false, // isLocal
+          false, // isRegion
+          OP_TYPE_GET_FOR_REGISTER_INTEREST, OP_DETAILS_NONE);
+
   /** The name of this mirror type. */
   private final transient String name;
 
@@ -636,6 +645,13 @@ public final class Operation implements java.io.Serializable {
   }
 
   /**
+   * Returns true if this operation is a get for register interest.
+   */
+  public boolean isGetForRegisterInterest() {
+    return this.opType == OP_TYPE_GET_FOR_REGISTER_INTEREST;
+  }
+
+  /**
    * Returns true if the operation invalidated an entry.
    */
   public boolean isInvalidate() {

http://git-wip-us.apache.org/repos/asf/geode/blob/1a36d36e/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
index cc6ccf7..b9cdfd7 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
@@ -2302,17 +2302,27 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
         if (requestingClient != null) {
           event.setContext(requestingClient);
         }
-        SearchLoadAndWriteProcessor processor = SearchLoadAndWriteProcessor.getProcessor();
-        try {
-          processor.initialize(this, key, aCallbackArgument);
-          // processor fills in event
-          processor.doSearchAndLoad(event, txState, localValue);
-          if (clientEvent != null && clientEvent.getVersionTag() == null) {
-            clientEvent.setVersionTag(event.getVersionTag());
+        // If this event is because of a register interest call, don't invoke the CacheLoader
+        boolean getForRegisterInterest = clientEvent != null && clientEvent.getOperation() != null
+            && clientEvent.getOperation().isGetForRegisterInterest();
+        if (!getForRegisterInterest) {
+          SearchLoadAndWriteProcessor processor = SearchLoadAndWriteProcessor.getProcessor();
+          try {
+            processor.initialize(this, key, aCallbackArgument);
+            // processor fills in event
+            processor.doSearchAndLoad(event, txState, localValue);
+            if (clientEvent != null && clientEvent.getVersionTag() == null) {
+              clientEvent.setVersionTag(event.getVersionTag());
+            }
+            lastModified = processor.getLastModified();
+          } finally {
+            processor.release();
+          }
+        } else {
+          if (logger.isDebugEnabled()) {
+            logger.debug("DistributedRegion.findObjectInSystem skipping loader for region="
+                + getFullPath() + "; key=" + key);
           }
-          lastModified = processor.getLastModified();
-        } finally {
-          processor.release();
         }
       }
       if (event.hasNewValue() && !isMemoryThresholdReachedForLoad()) {

http://git-wip-us.apache.org/repos/asf/geode/blob/1a36d36e/geode-core/src/main/java/org/apache/geode/internal/cache/OpType.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/OpType.java b/geode-core/src/main/java/org/apache/geode/internal/cache/OpType.java
index 7685988..ff36a57 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/OpType.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/OpType.java
@@ -49,6 +49,8 @@ public final class OpType {
 
   public static final byte UPDATE_ENTRY_VERSION = 11;
 
+  public static final byte GET_FOR_REGISTER_INTEREST = 12;
+
   public static final byte CLEAR = 16;
 
   public static final byte MARKER = 32;

http://git-wip-us.apache.org/repos/asf/geode/blob/1a36d36e/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java
index 5379605..d217672 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/BaseCommand.java
@@ -1074,7 +1074,7 @@ public abstract class BaseCommand implements Command {
 
     if (region != null) {
       if (region.containsKey(entryKey) || region.containsTombstone(entryKey)) {
-        VersionTagHolder versionHolder = new VersionTagHolder();
+        VersionTagHolder versionHolder = createVersionTagHolder();
         ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID();
         // From Get70.getValueAndIsObject()
         Object data = region.get(entryKey, null, true, true, true, id, versionHolder, true);
@@ -1161,7 +1161,7 @@ public abstract class BaseCommand implements Command {
       }
 
       for (Object key : region.keySet(true)) {
-        VersionTagHolder versionHolder = new VersionTagHolder();
+        VersionTagHolder versionHolder = createVersionTagHolder();
         if (keyPattern != null) {
           if (!(key instanceof String)) {
             // key is not a String, cannot apply regex to this entry
@@ -1263,12 +1263,10 @@ public abstract class BaseCommand implements Command {
   public static void appendNewRegisterInterestResponseChunkFromLocal(LocalRegion region,
       VersionedObjectList values, Object riKeys, Set keySet, ServerConnection servConn)
       throws IOException {
-    Object key = null;
-    VersionTagHolder versionHolder = null;
     ClientProxyMembershipID requestingClient = servConn == null ? null : servConn.getProxyID();
     for (Iterator it = keySet.iterator(); it.hasNext();) {
-      key = it.next();
-      versionHolder = new VersionTagHolder();
+      Object key = it.next();
+      VersionTagHolder versionHolder = createVersionTagHolder();
 
       Object value = region.get(key, null, true, true, true, requestingClient, versionHolder, true);
 
@@ -1454,7 +1452,7 @@ public abstract class BaseCommand implements Command {
       for (Iterator it = keyList.iterator(); it.hasNext();) {
         Object key = it.next();
         if (region.containsKey(key) || region.containsTombstone(key)) {
-          VersionTagHolder versionHolder = new VersionTagHolder();
+          VersionTagHolder versionHolder = createVersionTagHolder();
 
           ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID();
           data = region.get(key, null, true, true, true, id, versionHolder, true);
@@ -1475,6 +1473,12 @@ public abstract class BaseCommand implements Command {
     sendNewRegisterInterestResponseChunk(region, keyList, values, true, servConn);
   }
 
+  private static VersionTagHolder createVersionTagHolder() {
+    VersionTagHolder versionHolder = new VersionTagHolder();
+    versionHolder.setOperation(Operation.GET_FOR_REGISTER_INTEREST);
+    return versionHolder;
+  }
+
   /**
    * Append an interest response
    *

http://git-wip-us.apache.org/repos/asf/geode/blob/1a36d36e/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java
index e5fb5fc..d8164f1 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java
@@ -479,6 +479,80 @@ public class InterestListDUnitTest extends JUnit4DistributedTestCase {
     vm1.invoke(() -> InterestListDUnitTest.confirmNoCacheListenerInvalidates());
   }
 
+  @Test
+  public void testRegisterInterestSingleKeyWithDestroyOnReplicatedRegionWithCacheLoader() {
+    List keysToDestroy = new ArrayList();
+    keysToDestroy.add("0");
+    runRegisterInterestWithDestroyAndCacheLoaderTest(true, keysToDestroy, keysToDestroy);
+  }
+
+  @Test
+  public void testRegisterInterestSingleKeyWithDestroyOnPartitionedRegionWithCacheLoader() {
+    List keysToDestroy = new ArrayList();
+    keysToDestroy.add("0");
+    runRegisterInterestWithDestroyAndCacheLoaderTest(false, keysToDestroy, keysToDestroy);
+  }
+
+  @Test
+  public void testRegisterInterestListOfKeysWithDestroyOnReplicatedRegionWithCacheLoader() {
+    List keysToDestroy = new ArrayList();
+    for (int i = 0; i < 5; i++) {
+      keysToDestroy.add(String.valueOf(i));
+    }
+    runRegisterInterestWithDestroyAndCacheLoaderTest(true, keysToDestroy, keysToDestroy);
+  }
+
+  @Test
+  public void testRegisterInterestListOfKeysWithDestroyOnPartitionedRegionWithCacheLoader() {
+    List keysToDestroy = new ArrayList();
+    for (int i = 0; i < 5; i++) {
+      keysToDestroy.add(String.valueOf(i));
+    }
+    runRegisterInterestWithDestroyAndCacheLoaderTest(false, keysToDestroy, keysToDestroy);
+  }
+
+  @Test
+  public void testRegisterInterestAllKeysWithDestroyOnReplicatedRegionWithCacheLoader() {
+    List keysToDestroy = new ArrayList();
+    keysToDestroy.add("0");
+    runRegisterInterestWithDestroyAndCacheLoaderTest(true, keysToDestroy, "ALL_KEYS");
+  }
+
+  @Test
+  public void testRegisterInterestAllKeysWithDestroyOnPartitionedRegionWithCacheLoader() {
+    List keysToDestroy = new ArrayList();
+    keysToDestroy.add("0");
+    runRegisterInterestWithDestroyAndCacheLoaderTest(false, keysToDestroy, "ALL_KEYS");
+  }
+
+  private void runRegisterInterestWithDestroyAndCacheLoaderTest(boolean addReplicatedRegion,
+      List keysToDestroy, Object keyToRegister) {
+    // The server was already started with a replicated region. Bounce it if necessary
+    int port1 = PORT1;
+    if (!addReplicatedRegion) {
+      vm0.invoke(() -> closeCache());
+      port1 =
+          ((Integer) vm0.invoke(() -> InterestListDUnitTest.createServerCache(addReplicatedRegion)))
+              .intValue();
+    }
+    final int port = port1;
+
+    // Add a cache loader to the region
+    vm0.invoke(() -> addCacheLoader());
+
+    // Create client cache
+    vm1.invoke(() -> createClientCache(NetworkUtils.getServerHostName(vm0.getHost()), port));
+
+    // Destroy appropriate key(s)
+    vm1.invoke(() -> destroyKeys(keysToDestroy));
+
+    // Register interest in appropriate keys(s)
+    vm1.invoke(() -> registerKey(keyToRegister));
+
+    // Verify CacheLoader was not invoked
+    vm0.invoke(() -> verifyNoCacheLoaderLoads());
+  }
+
   private void createCache(Properties props) throws Exception {
     DistributedSystem ds = getSystem(props);
     cache = CacheFactory.create(ds);
@@ -905,6 +979,20 @@ public class InterestListDUnitTest extends JUnit4DistributedTestCase {
     }
   }
 
+  private static void destroyKeys(List keys) {
+    Region r = cache.getRegion(REGION_NAME);
+    for (Object key : keys) {
+      r.destroy(key);
+    }
+  }
+
+  private static void verifyNoCacheLoaderLoads() throws Exception {
+    Region region = cache.getRegion(REGION_NAME);
+    ReturnKeyCacheLoader cacheLoader =
+        (ReturnKeyCacheLoader) region.getAttributes().getCacheLoader();
+    assertEquals(0/* expected */, cacheLoader.getLoads()/* actual */);
+  }
+
   private static void validateEntriesK1andK2(final String vm) {
     WaitCriterion ev = new WaitCriterion() {
       @Override
@@ -1076,6 +1164,8 @@ public class InterestListDUnitTest extends JUnit4DistributedTestCase {
 
   private static class ReturnKeyCacheLoader implements CacheLoader {
 
+    private AtomicInteger loads = new AtomicInteger();
+
     @Override
     public void close() {
       // Do nothing
@@ -1083,7 +1173,16 @@ public class InterestListDUnitTest extends JUnit4DistributedTestCase {
 
     @Override
     public Object load(LoaderHelper helper) throws CacheLoaderException {
+      incrementLoads();
       return helper.getKey();
     }
+
+    private void incrementLoads() {
+      this.loads.incrementAndGet();
+    }
+
+    private int getLoads() {
+      return this.loads.get();
+    }
   }
 }


[44/51] [abbrv] geode git commit: GEODE-2571 CacheClosedException during LuceneQueryFunction should be handled with a retry

Posted by ds...@apache.org.
GEODE-2571 CacheClosedException during LuceneQueryFunction should be handled with a retry


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/6d263d57
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/6d263d57
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/6d263d57

Branch: refs/heads/feature/GEM-1195
Commit: 6d263d57a26226b59ef0bfb1e01205889d3d1409
Parents: de0dab3
Author: Jason Huynh <hu...@gmail.com>
Authored: Thu Mar 2 09:54:12 2017 -0800
Committer: Jason Huynh <hu...@gmail.com>
Committed: Thu Mar 2 10:22:51 2017 -0800

----------------------------------------------------------------------
 .../distributed/LuceneQueryFunction.java        | 48 ++++++++++++++------
 .../LuceneQueryFunctionJUnitTest.java           | 27 ++++++++++-
 2 files changed, 58 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6d263d57/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
index dd70480..e3b5297 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
@@ -19,6 +19,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
 import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
@@ -72,23 +73,11 @@ public class LuceneQueryFunction implements Function, InternalEntity {
       throw new IllegalArgumentException("Missing query provider");
     }
 
-    LuceneService service = LuceneServiceProvider.get(region.getCache());
-    LuceneIndexImpl index =
-        (LuceneIndexImpl) service.getIndex(searchContext.getIndexName(), region.getFullPath());
-    if (index == null) {
-      throw new InternalFunctionInvocationTargetException(
-          "Index for Region:" + region.getFullPath() + " was not found");
-    }
+    LuceneIndexImpl index = getLuceneIndex(region, searchContext);
     RepositoryManager repoManager = index.getRepositoryManager();
     LuceneIndexStats stats = index.getIndexStats();
 
-    Query query = null;
-    try {
-      query = queryProvider.getQuery(index);
-    } catch (LuceneQueryException e) {
-      logger.warn("", e);
-      throw new FunctionException(e);
-    }
+    Query query = getQuery(queryProvider, index);
 
     if (logger.isDebugEnabled()) {
       logger.debug("Executing lucene query: {}, on region {}", query, region.getFullPath());
@@ -123,12 +112,41 @@ public class LuceneQueryFunction implements Function, InternalEntity {
       }
       stats.incNumberOfQueryExecuted();
       resultSender.lastResult(mergedResult);
-    } catch (IOException | BucketNotFoundException e) {
+    } catch (IOException | BucketNotFoundException | CacheClosedException e) {
       logger.debug("Exception during lucene query function", e);
       throw new InternalFunctionInvocationTargetException(e);
     }
   }
 
+  private LuceneIndexImpl getLuceneIndex(final Region region,
+      final LuceneFunctionContext<IndexResultCollector> searchContext) {
+    LuceneService service = LuceneServiceProvider.get(region.getCache());
+    LuceneIndexImpl index = null;
+    try {
+      index =
+          (LuceneIndexImpl) service.getIndex(searchContext.getIndexName(), region.getFullPath());
+    } catch (CacheClosedException e) {
+      throw new InternalFunctionInvocationTargetException(
+          "Cache is closed when attempting to retrieve index:" + region.getFullPath(), e);
+    }
+    if (index == null) {
+      throw new InternalFunctionInvocationTargetException(
+          "Index for Region:" + region.getFullPath() + " was not found");
+    }
+    return index;
+  }
+
+  private Query getQuery(final LuceneQueryProvider queryProvider, final LuceneIndexImpl index) {
+    Query query = null;
+    try {
+      query = queryProvider.getQuery(index);
+    } catch (LuceneQueryException e) {
+      logger.warn("", e);
+      throw new FunctionException(e);
+    }
+    return query;
+  }
+
 
   @Override
   public String getId() {

http://git-wip-us.apache.org/repos/asf/geode/blob/6d263d57/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
index 6a9af9b..18621d5 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.FunctionException;
 import org.apache.geode.cache.execute.ResultSender;
@@ -38,6 +39,7 @@ import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
 import org.apache.geode.cache.lucene.internal.repository.IndexResultCollector;
 import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException;
 import org.apache.geode.internal.cache.execute.InternalRegionFunctionContext;
 import org.apache.geode.test.junit.categories.UnitTest;
 
@@ -208,15 +210,36 @@ public class LuceneQueryFunctionJUnitTest {
     function.execute(mockContext);
   }
 
-  @Test(expected = FunctionException.class)
+  @Test(expected = InternalFunctionInvocationTargetException.class)
   public void whenServiceReturnsNullIndexDuringQueryExecutionFunctionExceptionShouldBeThrown()
       throws Exception {
     when(mockContext.getDataSet()).thenReturn(mockRegion);
     when(mockContext.getArguments()).thenReturn(searchArgs);
-    LuceneQueryFunction function = new LuceneQueryFunction();
 
+    LuceneQueryFunction function = new LuceneQueryFunction();
     when(mockService.getIndex(eq("indexName"), eq(regionPath))).thenReturn(null);
+    function.execute(mockContext);
+  }
+
+  @Test(expected = InternalFunctionInvocationTargetException.class)
+  public void whenServiceThrowsCacheClosedDuringQueryExecutionFunctionExceptionShouldBeThrown()
+      throws Exception {
+    when(mockContext.getDataSet()).thenReturn(mockRegion);
+    when(mockContext.getArguments()).thenReturn(searchArgs);
 
+    LuceneQueryFunction function = new LuceneQueryFunction();
+    when(mockService.getIndex(eq("indexName"), eq(regionPath)))
+        .thenThrow(new CacheClosedException());
+    function.execute(mockContext);
+  }
+
+  @Test(expected = InternalFunctionInvocationTargetException.class)
+  public void whenCacheIsClosedDuringLuceneQueryExecutionInternalFunctionShouldBeThrownToTriggerFunctionServiceRetry()
+      throws Exception {
+    when(mockContext.getDataSet()).thenReturn(mockRegion);
+    when(mockContext.getArguments()).thenReturn(searchArgs);
+    LuceneQueryFunction function = new LuceneQueryFunction();
+    when(mockRepoManager.getRepositories(eq(mockContext))).thenThrow(new CacheClosedException());
     function.execute(mockContext);
   }
 


[33/51] [abbrv] geode git commit: GEODE-2561 Docs: error in gfsecurity.properties example (Geode User Guide)

Posted by ds...@apache.org.
GEODE-2561 Docs: error in gfsecurity.properties example (Geode User Guide)


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c3dbd742
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c3dbd742
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c3dbd742

Branch: refs/heads/feature/GEM-1195
Commit: c3dbd742cde95a2aa9266990d6c42f4ce359cea2
Parents: 826bdbf
Author: Dave Barnes <db...@pivotal.io>
Authored: Wed Mar 1 13:27:02 2017 -0800
Committer: Dave Barnes <db...@pivotal.io>
Committed: Wed Mar 1 13:27:02 2017 -0800

----------------------------------------------------------------------
 geode-docs/managing/security/ssl_example.html.md.erb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c3dbd742/geode-docs/managing/security/ssl_example.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/managing/security/ssl_example.html.md.erb b/geode-docs/managing/security/ssl_example.html.md.erb
index bb567ed..ef213dc 100644
--- a/geode-docs/managing/security/ssl_example.html.md.erb
+++ b/geode-docs/managing/security/ssl_example.html.md.erb
@@ -59,7 +59,7 @@ provider settings included with the JDK.
 ssl-keystore=/path/to/trusted.keystore
 ssl-keystore-password=password
 ssl-truststore=/path/to/trusted.keystore
-ssl-truststore-password=/path/to/trusted.truststore
+ssl-truststore-password=password
 security-username=xxxx
 security-userPassword=yyyy 
 ```


[42/51] [abbrv] geode git commit: GEODE-4160: upgrade mortbay-jetty-servlet-api dependency

Posted by ds...@apache.org.
GEODE-4160: upgrade mortbay-jetty-servlet-api dependency


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/479c0a1c
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/479c0a1c
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/479c0a1c

Branch: refs/heads/feature/GEM-1195
Commit: 479c0a1c467136c0bb8d152c5bfd4b4555be4c8a
Parents: ab56506
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Feb 28 17:28:33 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Thu Mar 2 09:32:47 2017 -0800

----------------------------------------------------------------------
 gradle/dependency-versions.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/479c0a1c/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index aca65fa..34e5d67 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -66,7 +66,7 @@ log4j.version = 2.7
 lucene.version = 6.4.1
 mockito-core.version = 1.10.19
 mockrunner.version = 1.1.2
-mortbay-jetty-servlet-api.version=2.5.20110712
+mortbay-jetty-servlet-api.version=3.0.20100224
 multithreadedtc.version = 1.01
 mx4j.version = 3.0.1
 mx4j-remote.version = 3.0.1


[34/51] [abbrv] geode git commit: Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/geode into develop

Posted by ds...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/geode into develop

* 'develop' of https://git-wip-us.apache.org/repos/asf/geode: (57 commits)
  GEODE-2551 Fix code issues found by AppChecker
  Revert "GEODE-1887: Now Size api goes through ServerProxy when cache is of type client and DataPolicy is Empty."
  GEODE-2538: Don't deserialize values on the server when getting results
  GEODE-2461: remove json4s-ast_2.10 as explicit dependency
  GEODE-2547: Interest registration no longer causes a CacheLoader to be invoked
  GEODE-2526: Enhance log statement to include ResourceTypeName
  GEODE-880 Remove unused classes
  GEODE-2460: update dependency versions
  GEODE-1995: Removed ReliableMessageQueue, ReliableMessageQueueFactory, ReliableMessageQueueFactoryImpl and it's usage in the code from GemfireCacheImpl and DistributedRegion.
  GEODE-2550 Improve README and BUILDING
  GEODE-2538: Don't invoke a cache loader when fetching values for a lucene query
  GEODE-2404: Added support for destroying lucene indexes
  GEODE-2545: NPE during lucene query execution when cache is closing or region is destroyed
  GEODE-2515: Disabling BaseLineAndCompareQueryPerfJUnitTest
  GEODE-2142: Removing JSON licence stuff from NOTICE files
  GEODE-2142: removing tests so run precheckin
  GEODE-2142: final compiling build
  GEODE-2142: cyclical dependency in gradle build
  GEODE-2142: spotless
  GEODE-2142: Refactoring of tests to work with new JSONObject class. Changing file export to use Base64 encoding.
  ...


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/635d3118
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/635d3118
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/635d3118

Branch: refs/heads/feature/GEM-1195
Commit: 635d3118177f6cae6b0497097e64bdb7a9aee800
Parents: c3dbd74 8b94e2e
Author: Dave Barnes <db...@pivotal.io>
Authored: Wed Mar 1 13:28:57 2017 -0800
Committer: Dave Barnes <db...@pivotal.io>
Committed: Wed Mar 1 13:28:57 2017 -0800

----------------------------------------------------------------------
 BUILDING.md                                     |   68 +-
 LICENSE                                         |  140 +-
 NOTICE                                          |    4 +-
 README.md                                       |  162 +-
 .../session/installer/InstallerJUnitTest.java   |   19 +-
 geode-assembly/build.gradle                     |    1 -
 geode-assembly/src/main/dist/LICENSE            |  137 -
 geode-assembly/src/main/dist/NOTICE             |  145 +-
 .../org/apache/geode/BundledJarsJUnitTest.java  |   27 +-
 ...erConfigurationServiceEndToEndDUnitTest.java |    8 -
 .../src/test/resources/expected_jars.txt        |    1 -
 geode-core/build.gradle                         |    7 +-
 .../java/org/apache/geode/DataSerializer.java   |   69 +
 .../java/org/apache/geode/cache/Operation.java  |   16 +
 .../internal/AsyncEventQueueImpl.java           |    9 +
 .../org/apache/geode/distributed/Locator.java   |    5 +-
 .../internal/DistributionAdvisor.java           |   22 +
 .../internal/membership/gms/Services.java       |   12 +-
 .../gms/locator/FindCoordinatorResponse.java    |    2 +-
 .../membership/gms/locator/GMSLocator.java      |   27 +-
 .../gms/mgr/GMSMembershipManager.java           |  183 +-
 .../org/apache/geode/internal/DSFIDFactory.java |    2 -
 .../geode/internal/DataSerializableFixedID.java |    4 +-
 .../org/apache/geode/internal/FileUtil.java     |  328 --
 .../geode/internal/cache/AbstractRegion.java    |    4 +-
 .../geode/internal/cache/BucketRegion.java      |    4 +-
 .../geode/internal/cache/DestroyOperation.java  |    6 -
 .../geode/internal/cache/DiskInitFile.java      |   60 +-
 .../geode/internal/cache/DiskStoreImpl.java     |  192 +-
 .../cache/DistributedCacheOperation.java        |   27 +-
 .../cache/DistributedPutAllOperation.java       |   27 -
 .../geode/internal/cache/DistributedRegion.java |  100 +-
 .../cache/DistributedRemoveAllOperation.java    |   15 -
 .../geode/internal/cache/GemFireCacheImpl.java  |   27 -
 .../internal/cache/InvalidateOperation.java     |    8 -
 .../org/apache/geode/internal/cache/OpType.java |    2 +
 .../org/apache/geode/internal/cache/Oplog.java  |   82 +-
 .../internal/cache/PersistentOplogSet.java      |   40 +-
 .../cache/ReliableDistributionData.java         |   41 -
 .../internal/cache/ReliableMessageQueue.java    |   69 -
 .../cache/ReliableMessageQueueFactory.java      |   41 -
 .../cache/ReliableMessageQueueFactoryImpl.java  |  246 --
 .../internal/cache/SendQueueOperation.java      |  190 --
 .../geode/internal/cache/TXCommitMessage.java   |   41 +-
 .../geode/internal/cache/TombstoneService.java  |   11 +-
 .../cache/UpdateEntryVersionOperation.java      |    6 -
 .../geode/internal/cache/UpdateOperation.java   |   13 -
 .../cache/partitioned/PRTombstoneMessage.java   |    2 +-
 .../cache/partitioned/RegionAdvisor.java        |   22 +
 .../cache/persistence/BackupManager.java        |   57 +-
 .../cache/persistence/RestoreScript.java        |    6 +-
 .../cache/tier/sockets/BaseCommand.java         |   18 +-
 .../cache/wan/serial/BatchDestroyOperation.java |    7 -
 .../geode/internal/i18n/LocalizedStrings.java   |   10 +-
 .../io/MainWithChildrenRollingFileHandler.java  |   29 +-
 .../geode/internal/logging/MergeLogFiles.java   |   29 +-
 .../geode/internal/process/ProcessUtils.java    |    2 +-
 .../internal/statistics/StatArchiveHandler.java |    6 +-
 .../internal/statistics/StatArchiveReader.java  |    4 +-
 .../geode/management/internal/cli/CliUtil.java  |    5 -
 .../internal/cli/json/GfJsonObject.java         |   36 -
 .../internal/cli/parser/ParserUtils.java        |    2 +-
 .../internal/cli/result/AbstractResultData.java |   57 +-
 .../internal/cli/result/ResultBuilder.java      |   30 -
 .../management/internal/cli/util/JsonUtil.java  |    2 +-
 .../client/ClientCacheFactoryJUnitTest.java     |   17 +-
 .../BaseLineAndCompareQueryPerfJUnitTest.java   |    5 +-
 .../geode/cache/query/QueryTestUtils.java       |   30 +-
 .../dunit/QueryIndexUsingXMLDUnitTest.java      |   31 +-
 .../query/dunit/SelectStarQueryDUnitTest.java   |    4 +-
 .../functional/IndexCreationJUnitTest.java      |   51 +-
 .../geode/cache30/ClientServerCCEDUnitTest.java |   59 +
 .../AbstractLauncherIntegrationTestCase.java    |   16 +-
 .../geode/distributed/LocatorDUnitTest.java     |   28 +-
 .../LocatorUDPSecurityDUnitTest.java            |    2 +-
 .../internal/DistributionManagerDUnitTest.java  |   78 +-
 .../internal/DataSerializableJUnitTest.java     |   64 +-
 .../geode/internal/FileUtilJUnitTest.java       |  101 -
 .../geode/internal/JarDeployerDUnitTest.java    |   28 +-
 .../internal/JarDeployerIntegrationTest.java    |    2 +-
 .../org/apache/geode/internal/JavaExec.java     |   71 -
 .../org/apache/geode/internal/LongBuffer.java   |   96 -
 .../geode/internal/PdxDeleteFieldDUnitTest.java |   30 +-
 .../geode/internal/PdxDeleteFieldJUnitTest.java |   32 +-
 .../geode/internal/PdxRenameDUnitTest.java      |   30 +-
 .../geode/internal/PdxRenameJUnitTest.java      |   20 +-
 .../geode/internal/cache/BackupDUnitTest.java   |  113 +-
 .../geode/internal/cache/BackupJUnitTest.java   |   58 +-
 .../internal/cache/ClearTXLockingDUnitTest.java |    3 +
 .../cache/DiskRegionAsyncRecoveryJUnitTest.java |   28 +-
 .../internal/cache/DiskRegionTestingBase.java   |   36 +-
 .../cache/IncrementalBackupDUnitTest.java       |  167 +-
 .../geode/internal/cache/OplogRVVJUnitTest.java |   42 +-
 .../cache/PartitionedRegionStatsJUnitTest.java  |   25 +-
 .../PersistentPartitionedRegionJUnitTest.java   |   25 +-
 ...tentColocatedPartitionedRegionDUnitTest.java |   55 +-
 .../PersistentPartitionedRegionTestBase.java    |   33 +-
 .../fixed/FixedPartitioningTestBase.java        |   40 +-
 .../persistence/BackupInspectorJUnitTest.java   |   18 +-
 .../PersistentReplicatedTestBase.java           |   26 +-
 .../RollingUpgrade2DUnitTest.java               |    6 +-
 .../rollingupgrade/RollingUpgradeDUnitTest.java |    7 +-
 .../tier/sockets/InterestListDUnitTest.java     |   99 +
 ...ildrenRollingFileHandlerIntegrationTest.java |   96 +
 .../logging/log4j/Log4J2PerformanceTest.java    |   27 +-
 .../log4j/LogWriterLoggerPerformanceTest.java   |   27 +-
 .../internal/net/SSLSocketIntegrationTest.java  |   49 +-
 .../DiskSpaceLimitIntegrationTest.java          |  245 +-
 .../StatArchiveHandlerIntegrationTest.java      |  243 ++
 ...veWithMissingResourceTypeRegressionTest.java |    3 +-
 ...eateAlterDestroyRegionCommandsDUnitTest.java |    6 +-
 .../commands/DiskStoreCommandsDUnitTest.java    |   10 +-
 ...laneousCommandsExportLogsPart1DUnitTest.java |   21 +-
 ...laneousCommandsExportLogsPart2DUnitTest.java |   22 +-
 ...laneousCommandsExportLogsPart3DUnitTest.java |   17 +-
 ...laneousCommandsExportLogsPart4DUnitTest.java |   21 +-
 .../cli/commands/QueueCommandsDUnitTest.java    |   10 +-
 .../cli/commands/UserCommandsDUnitTest.java     |   10 +-
 .../geode/pdx/PdxAttributesJUnitTest.java       |   19 +-
 .../geode/pdx/PdxSerializableJUnitTest.java     |   72 +-
 .../test/dunit/standalone/ProcessManager.java   |   18 +-
 .../org/apache/geode/util/test/TestUtil.java    |    8 +-
 geode-json/build.gradle                         |   20 +
 geode-json/src/main/java/org/json/CDL.java      |  272 --
 geode-json/src/main/java/org/json/Cookie.java   |  162 -
 .../src/main/java/org/json/CookieList.java      |   87 -
 geode-json/src/main/java/org/json/HTTP.java     |  185 --
 .../src/main/java/org/json/HTTPTokener.java     |   77 -
 geode-json/src/main/java/org/json/JSON.java     |  112 +
 .../src/main/java/org/json/JSONArray.java       | 1137 +++----
 .../src/main/java/org/json/JSONException.java   |   62 +-
 geode-json/src/main/java/org/json/JSONML.java   |  454 ---
 .../src/main/java/org/json/JSONObject.java      | 1915 ++++-------
 .../src/main/java/org/json/JSONStringer.java    |  492 ++-
 .../src/main/java/org/json/JSONTokener.java     |  852 +++--
 .../src/main/java/org/json/JSONWriter.java      |  321 --
 geode-json/src/main/java/org/json/XML.java      |  504 ---
 .../src/main/java/org/json/XMLTokener.java      |  362 ---
 geode-json/src/test/resources/sample-01.json    |  227 ++
 .../apache/geode/cache/lucene/LuceneQuery.java  |    5 -
 .../geode/cache/lucene/LuceneQueryFactory.java  |   11 -
 .../geode/cache/lucene/LuceneResultStruct.java  |    8 -
 .../geode/cache/lucene/LuceneService.java       |   22 +-
 .../internal/DestroyLuceneIndexMessage.java     |  109 +
 .../lucene/internal/InternalLuceneIndex.java    |    5 +
 .../lucene/internal/LuceneEventListener.java    |   36 +-
 .../internal/LuceneExceptionObserver.java       |   25 +
 .../LuceneIndexForPartitionedRegion.java        |  109 +-
 .../cache/lucene/internal/LuceneIndexImpl.java  |   16 +
 .../lucene/internal/LuceneQueryFactoryImpl.java |    8 +-
 .../cache/lucene/internal/LuceneQueryImpl.java  |   46 +-
 .../cache/lucene/internal/LuceneRawIndex.java   |    2 +
 .../lucene/internal/LuceneResultStructImpl.java |    5 -
 .../lucene/internal/LuceneServiceImpl.java      |   67 +-
 .../PageableLuceneQueryResultsImpl.java         |   23 +-
 .../lucene/internal/cli/LuceneCliStrings.java   |   28 +-
 .../cli/LuceneFunctionSerializable.java         |   36 +
 .../internal/cli/LuceneIndexCommands.java       |  113 +-
 .../lucene/internal/cli/LuceneIndexDetails.java |   16 +-
 .../lucene/internal/cli/LuceneIndexInfo.java    |   15 +-
 .../lucene/internal/cli/LuceneQueryInfo.java    |   15 +-
 .../functions/LuceneDestroyIndexFunction.java   |   57 +
 .../internal/distributed/LuceneFunction.java    |  137 -
 .../distributed/LuceneQueryFunction.java        |  142 +
 .../distributed/WaitUntilFlushedFunction.java   |   10 +-
 .../internal/distributed/package-info.java      |    4 +-
 .../repository/IndexRepositoryImpl.java         |    4 +-
 .../internal/results/LuceneGetPageFunction.java |   83 +
 .../internal/results/MapResultCollector.java    |   58 +
 .../lucene/internal/results/PageEntry.java      |   98 +
 .../lucene/internal/results/PageResults.java    |   60 +
 .../geode/cache/lucene/LuceneDUnitTest.java     |  122 +-
 .../lucene/LuceneIndexCreationDUnitTest.java    |  158 +-
 .../LuceneIndexCreationOnFixedPRDUnitTest.java  |   14 +-
 .../lucene/LuceneIndexDestroyDUnitTest.java     |  247 ++
 .../cache/lucene/LuceneQueriesAccessorBase.java |  211 ++
 .../geode/cache/lucene/LuceneQueriesBase.java   |  233 --
 .../lucene/LuceneQueriesClientDUnitTest.java    |   18 +-
 .../cache/lucene/LuceneQueriesDUnitTest.java    |  142 +
 .../lucene/LuceneQueriesIntegrationTest.java    |   41 +
 .../geode/cache/lucene/LuceneQueriesPRBase.java |  210 --
 .../LuceneQueriesPeerFixedPRDUnitTest.java      |   39 -
 .../lucene/LuceneQueriesPeerPRDUnitTest.java    |   41 -
 .../LuceneQueriesPeerPROverflowDUnitTest.java   |   46 -
 .../LuceneQueriesPeerPRPersistentDUnitTest.java |   41 -
 .../LuceneQueriesPeerPRRedundancyDUnitTest.java |  186 --
 .../geode/cache/lucene/PaginationDUnitTest.java |  210 ++
 .../geode/cache/lucene/RebalanceDUnitTest.java  |  197 ++
 .../RebalanceWithRedundancyDUnitTest.java       |  180 ++
 .../internal/LuceneEventListenerJUnitTest.java  |   26 +
 .../lucene/internal/LuceneIndexFactorySpy.java  |   80 +
 .../LuceneQueryFactoryImplJUnitTest.java        |    3 -
 .../internal/LuceneQueryImplJUnitTest.java      |   58 +-
 .../LuceneServiceImplIntegrationTest.java       |    6 +-
 ...PageableLuceneQueryResultsImplJUnitTest.java |   39 +-
 .../cli/LuceneIndexCommandsDUnitTest.java       |   50 +-
 .../cli/LuceneIndexCommandsJUnitTest.java       |   53 +
 .../LuceneDestroyIndexFunctionJUnitTest.java    |   93 +
 .../LuceneClusterConfigurationDUnitTest.java    |   99 +-
 .../LuceneFunctionContextJUnitTest.java         |   59 -
 .../distributed/LuceneFunctionJUnitTest.java    |  300 --
 .../LuceneQueryFunctionContextJUnitTest.java    |   59 +
 .../LuceneQueryFunctionJUnitTest.java           |  296 ++
 .../results/LuceneGetPageFunctionJUnitTest.java |   65 +
 .../internal/results/PageEntryJUnitTest.java    |   93 +
 .../internal/results/PageResultsJUnitTest.java  |   44 +
 .../cache/lucene/test/LuceneTestUtilities.java  |    7 +-
 geode-pulse/src/main/webapp/META-INF/NOTICE     |   10 +-
 geode-site/.gitignore                           |    1 -
 geode-site/website/.gitignore                   |    1 -
 geode-site/website/README.md                    |  100 -
 geode-site/website/Rules                        |   70 -
 geode-site/website/build.sh                     |   18 -
 .../website/content/bootstrap/bootstrap.min.css |    9 -
 geode-site/website/content/community/index.html |  272 --
 .../website/content/css/bootflat-extensions.css |  356 --
 .../website/content/css/bootflat-square.css     |   69 -
 geode-site/website/content/css/bootflat.css     | 1559 ---------
 .../website/content/css/font-awesome.min.css    |    4 -
 geode-site/website/content/css/geode-site.css   | 1612 ---------
 geode-site/website/content/docs/index.html      |   60 -
 geode-site/website/content/favicon.ico          |  Bin 20805 -> 0 bytes
 geode-site/website/content/font/FontAwesome.otf |  Bin 124988 -> 0 bytes
 .../content/font/fontawesome-webfont-eot.eot    |  Bin 76518 -> 0 bytes
 .../content/font/fontawesome-webfont-svg.svg    |  685 ----
 .../content/font/fontawesome-webfont-ttf.ttf    |  Bin 152796 -> 0 bytes
 .../content/font/fontawesome-webfont-woff.woff  |  Bin 90412 -> 0 bytes
 .../content/font/fontawesome-webfont.woff2      |  Bin 71896 -> 0 bytes
 .../fonts/font-awesome/fontawesome-webfont.eot  |  Bin 76204 -> 0 bytes
 .../fonts/font-awesome/fontawesome-webfont.svg  |  685 ----
 .../fonts/font-awesome/fontawesome-webfont.ttf  |  Bin 152364 -> 0 bytes
 .../fonts/font-awesome/fontawesome-webfont.woff |  Bin 90144 -> 0 bytes
 .../font-awesome/fontawesome-webfont.woff2      |  Bin 71760 -> 0 bytes
 geode-site/website/content/images/favicon.ico   |  Bin 1317 -> 0 bytes
 .../website/content/img/apache_geode_logo.png   |  Bin 23616 -> 0 bytes
 .../content/img/apache_geode_logo_white.png     |  Bin 22695 -> 0 bytes
 .../img/apache_geode_logo_white_small.png       |  Bin 52948 -> 0 bytes
 geode-site/website/content/img/asf_logo.png     |  Bin 152842 -> 0 bytes
 .../website/content/img/check_flat/default.png  |  Bin 25851 -> 0 bytes
 geode-site/website/content/img/github.png       |  Bin 8936 -> 0 bytes
 geode-site/website/content/index.html           |  171 -
 geode-site/website/content/javascripts/all.js   | 1085 -------
 geode-site/website/content/javascripts/book.js  |  953 ------
 .../website/content/javascripts/bookbinder.js   |  145 -
 .../content/javascripts/waypoints/context.js    |  316 --
 .../content/javascripts/waypoints/group.js      |  121 -
 .../javascripts/waypoints/noframeworkAdapter.js |  229 --
 .../content/javascripts/waypoints/sticky.js     |   79 -
 .../content/javascripts/waypoints/waypoint.js   |  176 -
 geode-site/website/content/js/bootstrap.min.js  |    8 -
 geode-site/website/content/js/head.js           |  708 ----
 geode-site/website/content/js/html5shiv.js      |    8 -
 .../website/content/js/jquery-1.10.1.min.js     |    6 -
 geode-site/website/content/js/jquery.icheck.js  |  397 ---
 geode-site/website/content/js/respond.min.js    |    6 -
 geode-site/website/content/js/usergrid-site.js  |   66 -
 geode-site/website/content/releases/index.html  |  190 --
 .../website/content/schema/cache/cache-1.0.xsd  | 1469 ---------
 .../website/content/schema/cache/lucene-1.0.xsd |   58 -
 geode-site/website/content/stylesheets/all.css  | 1590 ---------
 geode-site/website/content/stylesheets/base     | 1869 -----------
 .../website/content/stylesheets/book-styles     |    3 -
 .../website/content/stylesheets/layout-styles   |    0
 .../content/stylesheets/print-book-styles       |    0
 .../content/stylesheets/print-layout-styles     |    0
 .../website/content/stylesheets/print.css       |   38 -
 geode-site/website/content/subnavs/geode-subnav | 3052 ------------------
 geode-site/website/layouts/community.html       |    1 -
 geode-site/website/layouts/default.html         |   12 -
 geode-site/website/layouts/docs.html            |    1 -
 geode-site/website/layouts/footer.html          |   81 -
 geode-site/website/layouts/header.html          |  260 --
 geode-site/website/layouts/releases.html        |    1 -
 geode-site/website/lib/default.rb               |   60 -
 geode-site/website/lib/helpers_.rb              |   16 -
 geode-site/website/lib/pandoc.template          |    4 -
 geode-site/website/nanoc.yaml                   |   96 -
 geode-site/website/run.sh                       |   18 -
 geode-site/website/utilities/map-markers.rb     |   75 -
 geode-site/website/utilities/markers.txt        |  440 ---
 geode-site/website/utilities/snapshot-apigee.rb |   88 -
 .../geode/internal/cache/wan/WANTestBase.java   |   97 +-
 geode-web-api/build.gradle                      |    5 -
 geode-web-api/src/main/webapp/META-INF/NOTICE   |   10 +-
 geode-web/src/main/webapp/META-INF/NOTICE       |    6 +-
 gradle/dependency-versions.properties           |   44 +-
 gradle/rat.gradle                               |   22 -
 gradle/test.gradle                              |    1 -
 288 files changed, 8593 insertions(+), 28853 deletions(-)
----------------------------------------------------------------------



[36/51] [abbrv] geode git commit: GEODE-2562 CTR Revise docs Main Features section

Posted by ds...@apache.org.
GEODE-2562 CTR  Revise docs Main Features section

- Remove instances of GemFire
- Simplify some language
- Add a paragraph about Geode Native (clients in other languages)


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/319304e2
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/319304e2
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/319304e2

Branch: refs/heads/feature/GEM-1195
Commit: 319304e28fa33f685ccab51d7574fc8696cee50b
Parents: 635d311
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Mar 1 14:21:42 2017 -0800
Committer: Karen Miller <km...@pivotal.io>
Committed: Wed Mar 1 14:28:25 2017 -0800

----------------------------------------------------------------------
 .../source/subnavs/geode-subnav.erb             |  2 +-
 .../getting_started/product_intro.html.md.erb   | 46 ++++++++++++--------
 2 files changed, 30 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/319304e2/geode-book/master_middleman/source/subnavs/geode-subnav.erb
----------------------------------------------------------------------
diff --git a/geode-book/master_middleman/source/subnavs/geode-subnav.erb b/geode-book/master_middleman/source/subnavs/geode-subnav.erb
index 3711fff..5f03ee6 100644
--- a/geode-book/master_middleman/source/subnavs/geode-subnav.erb
+++ b/geode-book/master_middleman/source/subnavs/geode-subnav.erb
@@ -30,7 +30,7 @@ limitations under the License.
                         <a href="/docs/guide/11/getting_started/geode_overview.html">About Apache Geode</a>
                     </li>
                     <li>
-                        <a href="/docs/guide/11/getting_started/product_intro.html">Main Features of Apache Geode</a>
+                        <a href="/docs/guide/11/getting_started/product_intro.html">Main Features</a>
                     </li>
                     <li class="has_submenu">
                         <a href="/docs/guide/11/prereq_and_install.html">Prerequisites and Installation Instructions</a>

http://git-wip-us.apache.org/repos/asf/geode/blob/319304e2/geode-docs/getting_started/product_intro.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/getting_started/product_intro.html.md.erb b/geode-docs/getting_started/product_intro.html.md.erb
index 471bd42..103b2dd 100644
--- a/geode-docs/getting_started/product_intro.html.md.erb
+++ b/geode-docs/getting_started/product_intro.html.md.erb
@@ -1,5 +1,5 @@
 ---
-title:  Main Features of Apache Geode
+title:  Main Features
 ---
 
 <!--
@@ -19,7 +19,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 -->
 
-This section summarizes the main features and key functionality of Apache Geode.
+This section summarizes main features and key functionality.
 
 -   [High Read-and-Write Throughput](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_CF0E3E5C4F884374B8F2F536DD2A375C)
 -   [Low and Predictable Latency](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_9C5D669B583646F1B817284EB494DDA7)
@@ -33,38 +33,39 @@ This section summarizes the main features and key functionality of Apache Geode.
 -   [Client/Server Security](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_577F601BC9854AA6B53CD3440F9B9A6A)
 -   [Multisite Data Distribution](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_091A306900D7402CAE5A46B5F9BFD612)
 -   [Continuous Querying](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_FF4C3B6E26104C4D93186F6FFE22B321)
+-   [Heterogeneous Data Sharing](product_intro.html#mainfeatures_heterogeneousdatasharing)
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_CF0E3E5C4F884374B8F2F536DD2A375C" class="no-quick-link"></a>High Read-and-Write Throughput
 
-Geode uses concurrent main-memory data structures and a highly optimized distribution infrastructure to provide read-and-write throughput. Applications can make copies of data dynamically in memory through synchronous or asynchronous replication for high read throughput or partition the data across many Geode system members to achieve high read-and-write throughput. Data partitioning doubles the aggregate throughput if the data access is fairly balanced across the entire data set. Linear increase in throughput is limited only by the backbone network capacity.
+Read-and-write throughput is provided by concurrent main-memory data structures and a highly optimized distribution infrastructure. Applications can make copies of data dynamically in memory through synchronous or asynchronous replication for high read throughput or partition the data across many system members to achieve high read-and-write throughput. Data partitioning doubles the aggregate throughput if the data access is fairly balanced across the entire data set. Linear increase in throughput is limited only by the backbone network capacity.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_9C5D669B583646F1B817284EB494DDA7" class="no-quick-link"></a>Low and Predictable Latency
 
-Geode's optimized caching layer minimizes context switches between threads and processes. It manages data in highly concurrent structures to minimize contention points. Communication to peer members is synchronous if the receivers can keep up, which keeps the latency for data distribution to a minimum. Servers manage object graphs in serialized form to reduce the strain on the garbage collector.
+The optimized caching layer minimizes context switches between threads and processes. It manages data in highly concurrent structures to minimize contention points. Communication to peer members is synchronous if the receivers can keep up, which keeps the latency for data distribution to a minimum. Servers manage object graphs in serialized form to reduce the strain on the garbage collector.
 
-Geode partitions subscription management (interest registration and continuous queries) across server data stores, ensuring that a subscription is processed only once for all interested clients. The resulting improvements in CPU use and bandwidth utilization improve throughput and reduce latency for client subscriptions.
+Subscription management (interest registration and continuous queries) is partitioned across server data stores, ensuring that a subscription is processed only once for all interested clients. The resulting improvements in CPU use and bandwidth utilization improve throughput and reduce latency for client subscriptions.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_EF7A73D35D1241289C9CA19EDDEBE959" class="no-quick-link"></a>High Scalability
 
-Geode achieves scalability through dynamic partitioning of data across many members and spreading the data load uniformly across the servers. For "hot" data, you can configure the system to expand dynamically to create more copies of the data. You can also provision application behavior to run in a distributed manner in close proximity to the data it needs.
+Scalability is achieved through dynamic partitioning of data across many members and spreading the data load uniformly across the servers. For "hot" data, you can configure the system to expand dynamically to create more copies of the data. You can also provision application behavior to run in a distributed manner in close proximity to the data it needs.
 
 If you need to support high and unpredictable bursts of concurrent client load, you can increase the number of servers managing the data and distribute the data and behavior across them to provide uniform and predictable response times. Clients are continuously load balanced to the server farm based on continuous feedback from the servers on their load conditions. With data partitioned and replicated across servers, clients can dynamically move to different servers to uniformly load the servers and deliver the best response times.
 
-You can also improve scalability by implementing asynchronous "write behind" of data changes to external data stores, like a database. Geode avoids a bottleneck by queuing all updates in order and redundantly. You can also conflate updates and propagate them in batch to the database.
+You can also improve scalability by implementing asynchronous "write behind" of data changes to external data stores, like a database. This avoids a bottleneck by queuing all updates in order and redundantly. You can also conflate updates and propagate them in batch to the database.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_CEB4ABFF83054AF6A47EA2FA09C240B1" class="no-quick-link"></a>Continuous Availability
 
-In addition to guaranteed consistent copies of data in memory, applications can persist data to disk on one or more Geode members synchronously or asynchronously by using Geode's "shared nothing disk architecture." All asynchronous events (store-forward events) are redundantly managed in at least two members such that if one server fails, the redundant one takes over. All clients connect to logical servers, and the client fails over automatically to alternate servers in a group during failures or when servers become unresponsive.
+In addition to guaranteed consistent copies of data in memory, applications can persist data to disk on one or more members synchronously or asynchronously by using a "shared nothing disk architecture." All asynchronous events (store-forward events) are redundantly managed in at least two members such that if one server fails, the redundant one takes over. All clients connect to logical servers, and the client fails over automatically to alternate servers in a group during failures or when servers become unresponsive.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_86D2B8CC346349F3913209AF87648A02" class="no-quick-link"></a>Reliable Event Notifications
 
 Publish/subscribe systems offer a data-distribution service where new events are published into the system and routed to all interested subscribers in a reliable manner. Traditional messaging platforms focus on message delivery, but often the receiving applications need access to related data before they can process the event. This requires them to access a standard database when the event is delivered, limiting the subscriber by the speed of the database.
 
-Geode offers data and events through a single system. Data is managed as objects in one or more distributed data regions, similar to tables in a database. Applications simply insert, update, or delete objects in data regions, and the platform delivers the object changes to the subscribers. The subscriber receiving the event has direct access to the related data in local memory or can fetch the data from one of the other members through a single hop.
+Data and events are offered through a single system. Data is managed as objects in one or more distributed data regions, similar to tables in a database. Applications simply insert, update, or delete objects in data regions, and the platform delivers the object changes to the subscribers. The subscriber receiving the event has direct access to the related data in local memory or can fetch the data from one of the other members through a single hop.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_A65B5F0DE8BF4AA6AFF16E3A75D4E0AD" class="no-quick-link"></a>Parallelized Application Behavior on Data Stores
 
-You can execute application business logic in parallel on the Geode members. Geode's data-aware function-execution service permits execution of arbitrary, data-dependent application functions on the members where the data is partitioned for locality of reference and scale.
+You can execute application business logic in parallel on members. The data-aware function-execution service permits execution of arbitrary, data-dependent application functions on the members where the data is partitioned for locality of reference and scale.
 
 By colocating the relevant data and parallelizing the calculation, you increase overall throughput. The calculation latency is inversely proportional to the number of members on which it can be parallelized.
 
@@ -72,9 +73,9 @@ The fundamental premise is to route the function transparently to the applicatio
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_97CABBFF553647F6BBBC40AA7AF6D4C7" class="no-quick-link"></a>Shared-Nothing Disk Persistence
 
-Each Geode system member manages data on disk files independent of other members. Failures in disks or cache failures in one member do not affect the ability of another cache instance to operate safely on its disk files. This "shared nothing" persistence architecture allows applications to be configured such that different classes of data are persisted on different members across the system, dramatically increasing the overall throughput of the application even when disk persistence is configured for application objects.
+Each distributed system member manages data on disk files independent of other members. Failures in disks or cache failures in one member do not affect the ability of another cache instance to operate safely on its disk files. This "shared nothing" persistence architecture allows applications to be configured such that different classes of data are persisted on different members across the system, dramatically increasing the overall throughput of the application even when disk persistence is configured for application objects.
 
-Unlike a traditional database system, Geode does not manage data and transaction logs in separate files. All data updates are appended to files that are similar to transactional logs of traditional databases. You can avoid disk-seek times if the disk is not concurrently used by other processes, and the only cost incurred is the rotational latency.
+Unlike a traditional database system, separate files are not used to manage data and transaction logs. All data updates are appended to files that are similar to transactional logs of traditional databases. You can avoid disk-seek times if the disk is not concurrently used by other processes, and the only cost incurred is the rotational latency.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_FCB2640F1BED4692A93F9300A41CE70D" class="no-quick-link"></a>Reduced Cost of Ownership
 
@@ -86,16 +87,27 @@ Clients can send individual data requests directly to the server holding the dat
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_577F601BC9854AA6B53CD3440F9B9A6A" class="no-quick-link"></a>Client/Server Security
 
-Geode supports running multiple, distinct users in client applications. This feature accommodates installations in which Geode clients are embedded in application servers and each application server supports data requests from many users. Each user may be authorized to access a small subset of data on the servers, as in a customer application where each customer can access only their own orders and shipments. Each user in the client connects to the server with its own set of credentials and has its own access authorization to the server cache.
-
-Client/server communication has increased security against replay attacks. The server sends the client a unique, random identifier with each response to be used in the next client request. Because of the identifier, even a repeated client operation call is sent as a unique request to the server.
+There may be multiple, distinct users in client applications. This feature accommodates installations in which clients are embedded in application servers and each application server supports data requests from many users. Each user may be authorized to access a small subset of data on the servers, as in a customer application where each customer can access only their own orders and shipments. Each user in the client connects to the server with its own set of credentials and has its own access authorization to the server cache.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_091A306900D7402CAE5A46B5F9BFD612" class="no-quick-link"></a>Multisite Data Distribution
 
-Scalability problems can result from data sites being spread out geographically across a wide-area network (WAN). GemFire offers a model to address these topologies, ranging from a single peer-to-peer cluster to reliable communications between data centers across the WAN. This model allows distributed systems to scale out in an unbounded and loosely coupled fashion without loss of performance, reliability or data consistency.
+Scalability problems can result from data sites being spread out geographically across a wide-area network (WAN). Models address these topologies, ranging from a single peer-to-peer cluster to reliable communications between data centers across the WAN. This model allows distributed systems to scale out in an unbounded and loosely coupled fashion without loss of performance, reliability or data consistency.
 
-At the core of this architecture is the gateway sender configuration used for distributing region events to a remote site. You can deploy gateway sender instances in parallel, which enables GemFire to increase the throughput for distributing region events across the WAN. You can also configure gateway sender queues for persistence and high availability to avoid data loss in the case of a member failure.
+At the core of this architecture is the gateway sender configuration used for distributing region events to a remote site. You can deploy gateway sender instances in parallel, which enables an increase in throughput for distributing region events across the WAN. You can also configure gateway sender queues for persistence and high availability to avoid data loss in the case of a member failure.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_FF4C3B6E26104C4D93186F6FFE22B321" class="no-quick-link"></a>Continuous Querying
 
 In messaging systems like Java Message Service, clients subscribe to topics and queues. Any message delivered to a topic is sent to the subscriber. Geode allows continuous querying by having applications express complex interest using Object Query Language.
+
+## <a id="mainfeatures_heterogeneousdatasharing" class="no-quick-link"></a>Heterogeneous Data Sharing
+
+C#, C++ and Java applications can share application business objects 
+without going through a transformation layer such as SOAP or XML.
+The server side behavior, though implemented in Java,
+provides a unique native cache for C++ and .NET applications.
+Application objects can be managed in the C++ process heap and 
+distributed to other processes using a common \u201con-the-wire\u201d representation
+for objects.
+A C++ serialized object can be directly deserialized as an equivalent Java 
+or C# object.
+A change to a business object in one language can trigger reliable notifications in applications written in the other supported languages.


[32/51] [abbrv] geode git commit: GEODE-2551 Fix code issues found by AppChecker

Posted by ds...@apache.org.
GEODE-2551 Fix code issues found by AppChecker

This closes #408


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/8b94e2ec
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/8b94e2ec
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/8b94e2ec

Branch: refs/heads/feature/GEM-1195
Commit: 8b94e2ec2dc1192e96fc822b4b3a49561a76b2dc
Parents: 8a2983f
Author: Anthony Baker <ab...@apache.org>
Authored: Sun Feb 26 13:20:34 2017 -0800
Committer: Anthony Baker <ab...@apache.org>
Committed: Wed Mar 1 12:49:14 2017 -0800

----------------------------------------------------------------------
 .../apache/geode/management/internal/cli/parser/ParserUtils.java | 2 +-
 .../org/apache/geode/management/internal/cli/util/JsonUtil.java  | 2 +-
 .../apache/geode/cache/query/dunit/SelectStarQueryDUnitTest.java | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/8b94e2ec/geode-core/src/main/java/org/apache/geode/management/internal/cli/parser/ParserUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/parser/ParserUtils.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/parser/ParserUtils.java
index 9faccb6..80f1286 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/parser/ParserUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/parser/ParserUtils.java
@@ -93,7 +93,7 @@ public class ParserUtils {
 
       // Remove quotes from the beginning and end of split strings
       for (int i = 0; i < split.length; i++) {
-        if ((split[i].endsWith("\"") && split[i].endsWith("\""))
+        if ((split[i].startsWith("\"") && split[i].endsWith("\""))
             || (split[i].startsWith("\'") && split[i].endsWith("\'"))) {
           split[i] = split[i].substring(1, split[i].length() - 1);
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/8b94e2ec/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JsonUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JsonUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JsonUtil.java
index 510575b..166b375 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JsonUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/JsonUtil.java
@@ -385,7 +385,7 @@ public class JsonUtil {
       return value;
     } else if (klass.isAssignableFrom(Long.class) || klass.isAssignableFrom(long.class)) {
       return value;
-    } else if (klass.isAssignableFrom(Float.class) || klass.isAssignableFrom(Float.class)) {
+    } else if (klass.isAssignableFrom(Float.class) || klass.isAssignableFrom(float.class)) {
       return value;
     } else if (klass.isAssignableFrom(Double.class) || klass.isAssignableFrom(double.class)) {
       return value;

http://git-wip-us.apache.org/repos/asf/geode/blob/8b94e2ec/geode-core/src/test/java/org/apache/geode/cache/query/dunit/SelectStarQueryDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/dunit/SelectStarQueryDUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/dunit/SelectStarQueryDUnitTest.java
index 525aa2f..c650258 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/dunit/SelectStarQueryDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/dunit/SelectStarQueryDUnitTest.java
@@ -1381,7 +1381,7 @@ public class SelectStarQueryDUnitTest extends JUnit4CacheTestCase {
                         + obj.getClass());
                   }
                 }
-              } else if (rs instanceof PortfolioPdx || rs instanceof PortfolioPdx) {
+              } else if (rs instanceof PortfolioPdx) {
               } else {
                 fail("Result objects for remote client query: " + queries[i]
                     + " should be instance of PortfolioPdx and not " + rs.getClass());
@@ -1441,7 +1441,7 @@ public class SelectStarQueryDUnitTest extends JUnit4CacheTestCase {
                         + obj.getClass());
                   }
                 }
-              } else if (rs instanceof PortfolioPdx || rs instanceof PortfolioPdx) {
+              } else if (rs instanceof PortfolioPdx) {
               } else {
                 fail("Result objects for remote client query: " + queries[i]
                     + " should be instance of PortfolioPdx and not " + rs.getClass());


[23/51] [abbrv] geode git commit: GEODE-2550 Improve README and BUILDING

Posted by ds...@apache.org.
GEODE-2550 Improve README and BUILDING

This closes #407


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/b5fd6b50
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/b5fd6b50
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/b5fd6b50

Branch: refs/heads/feature/GEM-1195
Commit: b5fd6b50b18ce13cb53ef72f9fe5f363cb566ba5
Parents: 712d87f
Author: Anthony Baker <ab...@apache.org>
Authored: Sat Feb 25 08:09:48 2017 -0800
Committer: Anthony Baker <ab...@apache.org>
Committed: Mon Feb 27 20:29:55 2017 -0800

----------------------------------------------------------------------
 BUILDING.md |  68 ++++++-----------------
 README.md   | 162 +++++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 144 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b5fd6b50/BUILDING.md
----------------------------------------------------------------------
diff --git a/BUILDING.md b/BUILDING.md
index 0c7bf4d..308ef8a 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -1,64 +1,30 @@
 # Building this Release from Source
 
-Build instructions differ slightly for Unix and Windows platforms.
 All platforms require a Java installation, with JDK 1.8 or more recent version.
 
-## Build from Source on Unix
+Set the JAVA\_HOME environment variable.  For example:
 
-1. Set the JAVA\_HOME environment variable.  For example:
+| Platform | Command |
+| :---: | --- |
+|  Unix    | ``export JAVA_HOME=/usr/java/jdk1.8.0_121``            |
+|  OSX     | ``export JAVA_HOME=`/usr/libexec/java_home -v 1.8``    |
+|  Windows | ``set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_121"`` |
 
-    ```     
-    JAVA_HOME=/usr/java/jdk1.8.0_60
-    export JAVA_HOME
-    ```
-2. Download the project source from the Releases page at [Apache Geode] (http://geode.apache.org), and unpack the source code.
-3. Within the directory containing the unpacked source code, build without the tests:
-    
-    ```
-    $ ./gradlew build -Dskip.tests=true
-    ```
-Or, build with the tests:
-   
-    ```
-    $ ./gradlew build
-    ```
-The built binaries will be in `geode-assembly/build/distributions/`,
-or the `gfsh` script can be found in 
-`geode-assembly/build/install/apache-geode/bin/`.
-4. Verify the installation by invoking `gfsh` to print version information and exit:
-   
-    ```
-    $ gfsh version
-    v1.1.0
-    ```
+Download the project source from the Releases page at [Apache Geode]
+(http://geode.apache.org/releases/), and unpack the source code.
 
-## Build from Source on Windows
+Within the directory containing the unpacked source code, run the gradle build:
 
-1. Set the JAVA\_HOME environment variable.  For example:
+    $ ./gradlew build
 
-    ```
-    $ set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_60"
-    ```
-2. Install Gradle, version 2.12 or a more recent version.
-3. Download the project source from the Releases page at [Apache Geode] (http://geode.apache.org), and unpack the source code.
-4. Within the folder containing the unpacked source code, build without the tests:
+Once the build completes, the project files will be installed at
+`geode-assembly/build/install/apache-geode`. The distribution archives will be
+created in `geode-assembly/build/distributions/`.
 
-    ```
-    $ gradle build -Dskip.test=true
-    ```
-Or, build with the tests:
+Verify the installation by invoking the `gfsh` shell command to print version
+information:
 
-    ```
-    $ gradle build
-    ```
-The built binaries will be in `geode-assembly\build\distributions\`,
-or the `gfsh.bat` script can be found in 
-`geode-assembly\build\install\apache-geode\bin\`.
-4. Verify the installation by invoking `gfsh` to print version information and exit:
-   
-    ```
-    $ gfsh.bat version
+    $ ./geode-assembly/build/install/apache-geode/bin/gfsh version
     v1.1.0
-    ```
-
 
+Note: on Windows invoke the `gfsh.bat` script to print the version string.

http://git-wip-us.apache.org/repos/asf/geode/blob/b5fd6b50/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 645f420..0909364 100644
--- a/README.md
+++ b/README.md
@@ -1,73 +1,152 @@
 [<img src="https://geode.apache.org/img/apache_geode_logo.png" align="center"/>](http://geode.apache.org)
 
-[![Build Status](https://travis-ci.org/apache/geode.svg?branch=develop)](https://travis-ci.org/apache/geode) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.geode/geode-core/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.geode%22)
+[![Build Status](https://travis-ci.org/apache/geode.svg?branch=develop)](https://travis-ci.org/apache/geode) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.geode/geode-core/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.geode%22) [![homebrew](https://img.shields.io/homebrew/v/apache-geode.svg)](http://brewformulas.org/ApacheGeode) [![Docker Pulls](https://img.shields.io/docker/pulls/apachegeode/geode.svg)](https://hub.docker.com/r/apachegeode/geode/)
+
 
 ## Contents
-1. [Overview](#overview)  
+1. [Overview](#overview)
+2. [How to Get Apache Geode](#obtaining)
 2. [Main Concepts and Components](#concepts)
 3. [Location of Directions for Building from Source](#building)
 4. [Geode in 5 minutes](#started)
 5. [Application Development](#development)
 6. [Documentation](http://geode.apache.org/docs/)
 7. [Wiki](https://cwiki.apache.org/confluence/display/GEODE/Index)
-                                                                                                                       
 
-## <a name="overview"></a>Overview
-[Apache Geode](http://geode.apache.org/) is a data management platform that provides real-time, consistent access to data-intensive applications throughout widely distributed cloud architectures.
 
-Apache Geode pools memory, CPU, network resources, and optionally local disk across multiple processes to manage application objects and behavior. It uses dynamic replication and data partitioning techniques to implement high availability, improved performance, scalability, and fault tolerance. In addition to being a distributed data container, Apache Geode is an in-memory data management system that provides reliable asynchronous event notifications and guaranteed message delivery.
+## <a name="overview"></a>Overview
 
-Apache Geode is a mature, robust technology originally developed by GemStone Systems in Beaverton, Oregon. Commercially available as GemFire\u2122, the technology was first deployed in the financial sector as the transactional, low-latency data engine used in Wall Street trading platforms.  Today Apache Geode is used by over 600 enterprise customers for high-scale business applications that must meet low latency and 24x7 availability requirements. An example deployment includes [China National Railways](http://pivotal.io/big-data/case-study/scaling-online-sales-for-the-largest-railway-in-the-world-china-railway-corporation) that uses Geode to run railway ticketing for the entire country of China with a 10 node cluster that manages 2 terabytes of "hot data" in memory, and 10 backup nodes for high availability and elastic scale.
+[Apache Geode](http://geode.apache.org/) is
+a data management platform that provides real-time, consistent access to
+data-intensive applications throughout widely distributed cloud architectures.
+
+Apache Geode pools memory, CPU, network resources, and optionally local disk
+across multiple processes to manage application objects and behavior. It uses
+dynamic replication and data partitioning techniques to implement high
+availability, improved performance, scalability, and fault tolerance. In
+addition to being a distributed data container, Apache Geode is an in-memory
+data management system that provides reliable asynchronous event notifications
+and guaranteed message delivery.
+
+Apache Geode is a mature, robust technology originally developed by GemStone
+Systems. Commercially available as GemFire\u2122, it was first deployed in the
+financial sector as the transactional, low-latency data engine used in Wall
+Street trading platforms.  Today Apache Geode technology is used by hundreds of
+enterprise customers for high-scale business applications that must meet low
+latency and 24x7 availability requirements.
+
+## <a name="obtaining"></a>How to Get Apache Geode
+
+You can download Apache Geode from the
+[website](http://geode.apache.org/releases/), run a Docker
+[image](https://hub.docker.com/r/apachegeode/geode/), or install with
+[homebrew](http://brewformulas.org/ApacheGeode) on OSX. Application developers
+can load dependencies from [Maven
+Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.geode%22).
+
+Maven
+```
+<dependencies>
+    <dependency>
+        <groupId>org.apache.geode</groupId>
+        <artifactId>geode-core</artifactId>
+        <version>$VERSION</version>
+    </dependency>
+</dependencies>
+```
+
+Gradle
+```
+dependencies {
+  compile "org.apache.geode:geode-core:$VERSION"
+}
+```
 
 ## <a name="concepts"></a>Main Concepts and Components
 
-_Caches_ are an abstraction that describe a node in an Apache Geode distributed system.
+_Caches_ are an abstraction that describe a node in an Apache Geode distributed
+system.
 
-Within each cache, you define data _regions_. Data regions are analogous to tables in a relational database and manage data in a distributed fashion as name/value pairs. A _replicated_ region stores identical copies of the data on each cache member of a distributed system. A _partitioned_ region spreads the data among cache members. After the system is configured, client applications can access the distributed data in regions without knowledge of the underlying system architecture. You can define listeners to receive notifications when data has changed, and you can define expiration criteria to delete obsolete data in a region.
+Within each cache, you define data _regions_. Data regions are analogous to
+tables in a relational database and manage data in a distributed fashion as
+name/value pairs. A _replicated_ region stores identical copies of the data on
+each cache member of a distributed system. A _partitioned_ region spreads the
+data among cache members. After the system is configured, client applications
+can access the distributed data in regions without knowledge of the underlying
+system architecture. You can define listeners to receive notifications when
+data has changed, and you can define expiration criteria to delete obsolete
+data in a region.
 
-_Locators_ provide clients with both discovery and server load balancing services. Clients are configured with locator information, and the locators maintain a dynamic list of member servers. The locators provide clients with connection information to a server. 
+_Locators_ provide clients with both discovery and server load balancing
+services. Clients are configured with locator information, and the locators
+maintain a dynamic list of member servers. The locators provide clients with
+connection information to a server.
 
 Apache Geode includes the following features:
 
-* Combines redundancy, replication, and a "shared nothing" persistence architecture to deliver fail-safe reliability and performance.
-* Horizontally scalable to thousands of cache members, with multiple cache topologies to meet different enterprise needs. The cache can be distributed across multiple computers.
+* Combines redundancy, replication, and a "shared nothing" persistence
+  architecture to deliver fail-safe reliability and performance.
+* Horizontally scalable to thousands of cache members, with multiple cache
+  topologies to meet different enterprise needs. The cache can be
+  distributed across multiple computers.
 * Asynchronous and synchronous cache update propagation.
-* Delta propagation distributes only the difference between old and new versions of an object (delta) instead of the entire object, resulting in significant distribution cost savings.
-* Reliable asynchronous event notifications and guaranteed message delivery through optimized, low latency distribution layer.
-* Applications run 4 to 40 times faster with no additional hardware.
-* Data awareness and real-time business intelligence. If data changes as you retrieve it, you see the changes immediately.
-* Integration with Spring Framework to speed and simplify the development of scalable, transactional enterprise applications.
+* Delta propagation distributes only the difference between old and new
+  versions of an object (delta) instead of the entire object, resulting in
+  significant distribution cost savings.
+* Reliable asynchronous event notifications and guaranteed message delivery
+  through optimized, low latency distribution layer.
+* Data awareness and real-time business intelligence. If data changes as
+  you retrieve it, you see the changes immediately.
+* Integration with Spring Framework to speed and simplify the development
+  of scalable, transactional enterprise applications.
 * JTA compliant transaction support.
-* Cluster-wide configurations that can be persisted and exported to other clusters.
+* Cluster-wide configurations that can be persisted and exported to other
+  clusters.
 * Remote cluster management through HTTP.
 * REST APIs for REST-enabled application development.
-* Rolling upgrades may be possible, but they will be subject to any limitations imposed by new features.
+* Rolling upgrades may be possible, but they will be subject to any
+  limitations imposed by new features.
 
 ## <a name="building"></a>Building this Release from Source
 
-Directions to build Apache Geode from source are in the source distribution, file `BUILDING.md`.
+See [BUILDING.md](https://github.com/apache/geode/blob/develop/BUILDING.md) for
+instructions on how to build the project.
 
 ## <a name="started"></a>Geode in 5 minutes
 
-With a JDK version 1.8 or a more recent version installed,
+Geode requires installation of JDK version 1.8.  After installing Apache Geode,
 start a locator and server:
 
     $ gfsh
-    gfsh> start locator --name=locator
-    gfsh> start server --name=server
+    gfsh> start locator
+    gfsh> start server
 
 Create a region:
 
-    gfsh> create region --name=region --type=REPLICATE
+    gfsh> create region --name=hello --type=REPLICATE
+
+Write a client application (this example uses a [Gradle](https://gradle.org)
+build script):
+
+_build.gradle_
 
-Write a client application:
+    apply plugin: 'java'
+    apply plugin: 'application'
 
-_HelloWorld.java_
+    mainClassName = 'HelloWorld'
+
+    repositories { mavenCentral() }
+    dependencies {
+      compile 'org.apache.geode:geode-core:1.1.0'
+      runtime 'org.slf4j:slf4j-log4j12:1.7.24'
+    }
+
+_src/main/java/HelloWorld.java_
 
     import java.util.Map;
     import org.apache.geode.cache.Region;
     import org.apache.geode.cache.client.*;
-    
+
     public class HelloWorld {
       public static void main(String[] args) throws Exception {
         ClientCache cache = new ClientCacheFactory()
@@ -75,11 +154,11 @@ _HelloWorld.java_
           .create();
         Region<String, String> region = cache
           .<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
-          .create("region");
-    
+          .create("hello");
+
         region.put("1", "Hello");
         region.put("2", "World");
-    
+
         for (Map.Entry<String, String>  entry : region.entrySet()) {
           System.out.format("key = %s, value = %s\n", entry.getKey(), entry.getValue());
         }
@@ -87,16 +166,30 @@ _HelloWorld.java_
       }
     }
 
-Compile and run `HelloWorld.java`.  The classpath should include `geode-dependencies.jar`.
+Build and run the `HelloWorld` example:
+
+    $ gradle run
+
+The application will connect to the running cluster, create a local cache, put
+some data in the cache, and print the cached data to the console:
 
-    javac -cp /some/path/geode/geode-assembly/build/install/apache-geode/lib/geode-dependencies.jar HelloWorld.java
-    java -cp .:/some/path/geode/geode-assembly/build/install/apache-geode/lib/geode-dependencies.jar HelloWorld
+    key = 1, value = Hello
+    key = 2, value = World
+
+Finally, shutdown the Geode server and locator:
+
+    $ gfsh> shutdown --include-locators=true
+
+For more information see the [Geode
+Examples](https://github.com/apache/geode-examples) repository or the
+[documentation](http://geode.apache.org/docs/).
 
 ## <a name="development"></a>Application Development
 
 Apache Geode applications can be written in these client technologies:
 
-* Java [client](http://geode.apache.org/docs/guide/topologies_and_comm/cs_configuration/chapter_overview.html) or [peer](http://geode.apache.org/docs/guide/topologies_and_comm/p2p_configuration/chapter_overview.html)
+* Java [client](http://geode.apache.org/docs/guide/topologies_and_comm/cs_configuration/chapter_overview.html)
+  or [peer](http://geode.apache.org/docs/guide/topologies_and_comm/p2p_configuration/chapter_overview.html)
 * [REST](http://geode.apache.org/docs/guide/rest_apps/chapter_overview.html)
 * [Memcached](https://cwiki.apache.org/confluence/display/GEODE/Moving+from+memcached+to+gemcached)
 * [Redis](https://cwiki.apache.org/confluence/display/GEODE/Geode+Redis+Adapter)
@@ -106,4 +199,3 @@ The following libraries are available external to the Apache Geode project:
 * [Spring Data GemFire](http://projects.spring.io/spring-data-gemfire/)
 * [Spring Cache](http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html)
 * [Python](https://github.com/gemfire/py-gemfire-rest)
-


[49/51] [abbrv] geode git commit: GEODE-2560: Missing disk files (.crf) during backup/restore throws exception

Posted by ds...@apache.org.
GEODE-2560: Missing disk files (.crf) during backup/restore throws exception


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/21a9b5e2
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/21a9b5e2
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/21a9b5e2

Branch: refs/heads/feature/GEM-1195
Commit: 21a9b5e2c60ddc909ebc28ebfa3b6aeb33b6ee12
Parents: c0633c8
Author: Kevin J. Duling <kd...@pivotal.io>
Authored: Wed Mar 1 09:49:18 2017 -0800
Committer: Kevin J. Duling <kd...@pivotal.io>
Committed: Fri Mar 3 10:21:17 2017 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/geode/internal/cache/Oplog.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/21a9b5e2/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java b/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
index f5aec51..8b0bba5 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/Oplog.java
@@ -5804,14 +5804,18 @@ public final class Oplog implements CompactableOplog, Flushable {
   }
 
   public void copyTo(File targetDir) throws IOException {
-    if (this.crf.f != null) { // fixes bug 43951
+    if (this.crf.f != null && this.crf.f.exists()) {
       FileUtils.copyFileToDirectory(this.crf.f, targetDir);
     }
-    FileUtils.copyFileToDirectory(this.drf.f, targetDir);
+    if (this.drf.f.exists()) {
+      FileUtils.copyFileToDirectory(this.drf.f, targetDir);
+    }
 
     // this krf existence check fixes 45089
     if (getParent().getDiskInitFile().hasKrf(this.oplogId)) {
-      FileUtils.copyFileToDirectory(this.getKrfFile(), targetDir);
+      if (this.getKrfFile().exists()) {
+        FileUtils.copyFileToDirectory(this.getKrfFile(), targetDir);
+      }
     }
   }
 


[10/51] [abbrv] geode git commit: GEODE-2142: spotless

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/test/java/org/json/ParsingTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/ParsingTest.java b/geode-json/src/test/java/org/json/ParsingTest.java
index 4a0837a..a49aba7 100755
--- a/geode-json/src/test/java/org/json/ParsingTest.java
+++ b/geode-json/src/test/java/org/json/ParsingTest.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -25,270 +23,269 @@ import static org.junit.Assert.fail;
 
 public class ParsingTest {
 
-    @Test
-    public void testParsingNoObjects() {
-        try {
-            new JSONTokener("").nextValue();
-            fail();
-        } catch (JSONException ignored) {
-        }
+  @Test
+  public void testParsingNoObjects() {
+    try {
+      new JSONTokener("").nextValue();
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testParsingLiterals() throws JSONException {
-        assertParsed(Boolean.TRUE, "true");
-        assertParsed(Boolean.FALSE, "false");
-        assertParsed(JSONObject.NULL, "null");
-        assertParsed(JSONObject.NULL, "NULL");
-        assertParsed(Boolean.FALSE, "False");
-        assertParsed(Boolean.TRUE, "truE");
-    }
-
-    @Test
-    public void testParsingQuotedStrings() throws JSONException {
-        assertParsed("abc", "\"abc\"");
-        assertParsed("123", "\"123\"");
-        assertParsed("foo\nbar", "\"foo\\nbar\"");
-        assertParsed("foo bar", "\"foo\\u0020bar\"");
-        assertParsed("\"{}[]/\\:,=;#", "\"\\\"{}[]/\\\\:,=;#\"");
-    }
-
-    @Test
-    public void testParsingSingleQuotedStrings() throws JSONException {
-        assertParsed("abc", "'abc'");
-        assertParsed("123", "'123'");
-        assertParsed("foo\nbar", "'foo\\nbar'");
-        assertParsed("foo bar", "'foo\\u0020bar'");
-        assertParsed("\"{}[]/\\:,=;#", "'\\\"{}[]/\\\\:,=;#'");
-    }
-
-    @Test
-    public void testParsingUnquotedStrings() throws JSONException {
-        assertParsed("abc", "abc");
-        assertParsed("123abc", "123abc");
-        assertParsed("123e0x", "123e0x");
-        assertParsed("123e", "123e");
-        assertParsed("123ee21", "123ee21");
-        assertParsed("0xFFFFFFFFFFFFFFFFF", "0xFFFFFFFFFFFFFFFFF");
-    }
-
-    /**
-     * Unfortunately the original implementation attempts to figure out what
-     * Java number type best suits an input value.
-     */
-    @Test
-    public void testParsingNumbersThatAreBestRepresentedAsLongs() throws JSONException {
-        assertParsed(9223372036854775807L, "9223372036854775807");
-        assertParsed(9223372036854775806L, "9223372036854775806");
-        assertParsed(-9223372036854775808L, "-9223372036854775808");
-        assertParsed(-9223372036854775807L, "-9223372036854775807");
-    }
-
-    @Test
-    public void testParsingNumbersThatAreBestRepresentedAsIntegers() throws JSONException {
-        assertParsed(0, "0");
-        assertParsed(5, "5");
-        assertParsed(-2147483648, "-2147483648");
-        assertParsed(2147483647, "2147483647");
-    }
-
-    @Test
-    public void testParsingNegativeZero() throws JSONException {
-        assertParsed(0, "-0");
-    }
-
-    @Test
-    public void testParsingIntegersWithAdditionalPrecisionYieldDoubles() throws JSONException {
-        assertParsed(1d, "1.00");
-        assertParsed(1d, "1.0");
-        assertParsed(0d, "0.0");
-        assertParsed(-0d, "-0.0");
-    }
-
-    @Test
-    public void testParsingNumbersThatAreBestRepresentedAsDoubles() throws JSONException {
-        assertParsed(9.223372036854776E18, "9223372036854775808");
-        assertParsed(-9.223372036854776E18, "-9223372036854775809");
-        assertParsed(1.7976931348623157E308, "1.7976931348623157e308");
-        assertParsed(2.2250738585072014E-308, "2.2250738585072014E-308");
-        assertParsed(4.9E-324, "4.9E-324");
-        assertParsed(4.9E-324, "4.9e-324");
-    }
-
-    @Test
-    public void testParsingOctalNumbers() throws JSONException {
-        assertParsed(5, "05");
-        assertParsed(8, "010");
-        assertParsed(1046, "02026");
-    }
-
-    @Test
-    public void testParsingHexNumbers() throws JSONException {
-        assertParsed(5, "0x5");
-        assertParsed(16, "0x10");
-        assertParsed(8230, "0x2026");
-        assertParsed(180150010, "0xABCDEFA");
-        assertParsed(2077093803, "0x7BCDEFAB");
+  }
+
+  @Test
+  public void testParsingLiterals() throws JSONException {
+    assertParsed(Boolean.TRUE, "true");
+    assertParsed(Boolean.FALSE, "false");
+    assertParsed(JSONObject.NULL, "null");
+    assertParsed(JSONObject.NULL, "NULL");
+    assertParsed(Boolean.FALSE, "False");
+    assertParsed(Boolean.TRUE, "truE");
+  }
+
+  @Test
+  public void testParsingQuotedStrings() throws JSONException {
+    assertParsed("abc", "\"abc\"");
+    assertParsed("123", "\"123\"");
+    assertParsed("foo\nbar", "\"foo\\nbar\"");
+    assertParsed("foo bar", "\"foo\\u0020bar\"");
+    assertParsed("\"{}[]/\\:,=;#", "\"\\\"{}[]/\\\\:,=;#\"");
+  }
+
+  @Test
+  public void testParsingSingleQuotedStrings() throws JSONException {
+    assertParsed("abc", "'abc'");
+    assertParsed("123", "'123'");
+    assertParsed("foo\nbar", "'foo\\nbar'");
+    assertParsed("foo bar", "'foo\\u0020bar'");
+    assertParsed("\"{}[]/\\:,=;#", "'\\\"{}[]/\\\\:,=;#'");
+  }
+
+  @Test
+  public void testParsingUnquotedStrings() throws JSONException {
+    assertParsed("abc", "abc");
+    assertParsed("123abc", "123abc");
+    assertParsed("123e0x", "123e0x");
+    assertParsed("123e", "123e");
+    assertParsed("123ee21", "123ee21");
+    assertParsed("0xFFFFFFFFFFFFFFFFF", "0xFFFFFFFFFFFFFFFFF");
+  }
+
+  /**
+   * Unfortunately the original implementation attempts to figure out what Java number type best
+   * suits an input value.
+   */
+  @Test
+  public void testParsingNumbersThatAreBestRepresentedAsLongs() throws JSONException {
+    assertParsed(9223372036854775807L, "9223372036854775807");
+    assertParsed(9223372036854775806L, "9223372036854775806");
+    assertParsed(-9223372036854775808L, "-9223372036854775808");
+    assertParsed(-9223372036854775807L, "-9223372036854775807");
+  }
+
+  @Test
+  public void testParsingNumbersThatAreBestRepresentedAsIntegers() throws JSONException {
+    assertParsed(0, "0");
+    assertParsed(5, "5");
+    assertParsed(-2147483648, "-2147483648");
+    assertParsed(2147483647, "2147483647");
+  }
+
+  @Test
+  public void testParsingNegativeZero() throws JSONException {
+    assertParsed(0, "-0");
+  }
+
+  @Test
+  public void testParsingIntegersWithAdditionalPrecisionYieldDoubles() throws JSONException {
+    assertParsed(1d, "1.00");
+    assertParsed(1d, "1.0");
+    assertParsed(0d, "0.0");
+    assertParsed(-0d, "-0.0");
+  }
+
+  @Test
+  public void testParsingNumbersThatAreBestRepresentedAsDoubles() throws JSONException {
+    assertParsed(9.223372036854776E18, "9223372036854775808");
+    assertParsed(-9.223372036854776E18, "-9223372036854775809");
+    assertParsed(1.7976931348623157E308, "1.7976931348623157e308");
+    assertParsed(2.2250738585072014E-308, "2.2250738585072014E-308");
+    assertParsed(4.9E-324, "4.9E-324");
+    assertParsed(4.9E-324, "4.9e-324");
+  }
+
+  @Test
+  public void testParsingOctalNumbers() throws JSONException {
+    assertParsed(5, "05");
+    assertParsed(8, "010");
+    assertParsed(1046, "02026");
+  }
+
+  @Test
+  public void testParsingHexNumbers() throws JSONException {
+    assertParsed(5, "0x5");
+    assertParsed(16, "0x10");
+    assertParsed(8230, "0x2026");
+    assertParsed(180150010, "0xABCDEFA");
+    assertParsed(2077093803, "0x7BCDEFAB");
+  }
+
+  @Test
+  public void testParsingLargeHexValues() throws JSONException {
+    assertParsed(Integer.MAX_VALUE, "0x7FFFFFFF");
+    String message = "Hex values are parsed as Strings if their signed "
+        + "value is greater than Integer.MAX_VALUE.";
+    assertParsed(message, 0x80000000L, "0x80000000");
+  }
+
+  @Test
+  public void test64BitHexValues() throws JSONException {
+    // note that this is different from the same test in the original Android
+    // this is due to the fact that Long.parseLong doesn't correctly handle
+    // the value -1 expressed as unsigned hex if you use the normal JDK. Presumably
+    // the Android equivalent program does this better.
+    assertParsed("Large hex longs shouldn't yield ints or strings", 0xFFFFFFFFFFFFFFFL,
+        "0xFFFFFFFFFFFFFFF");
+  }
+
+  @Test
+  public void testParsingWithCommentsAndWhitespace() throws JSONException {
+    assertParsed("baz", "  // foo bar \n baz");
+    assertParsed("baz", "  // foo bar \r baz");
+    assertParsed("baz", "  // foo bar \r\n baz");
+    assertParsed("baz", "  # foo bar \n baz");
+    assertParsed("baz", "  # foo bar \r baz");
+    assertParsed("baz", "  # foo bar \r\n baz");
+    assertParsed(5, "  /* foo bar \n baz */ 5");
+    assertParsed(5, "  /* foo bar \n baz */ 5 // quux");
+    assertParsed(5, "  5   ");
+    assertParsed(5, "  5  \r\n\t ");
+    assertParsed(5, "\r\n\t   5 ");
+  }
+
+  @Test
+  public void testParsingArrays() throws JSONException {
+    assertParsed(array(), "[]");
+    assertParsed(array(5, 6, true), "[5,6,true]");
+    assertParsed(array(5, 6, array()), "[5,6,[]]");
+    assertParsed(array(5, 6, 7), "[5;6;7]");
+    assertParsed(array(5, 6, 7), "[5  , 6 \t; \r\n 7\n]");
+    assertParsed(array(5, 6, 7, null), "[5,6,7,]");
+    assertParsed(array(null, null), "[,]");
+    assertParsed(array(5, null, null, null, 5), "[5,,,,5]");
+    assertParsed(array(null, 5), "[,5]");
+    assertParsed(array(null, null, null), "[,,]");
+    assertParsed(array(null, null, null, 5), "[,,,5]");
+  }
+
+  @Test
+  public void testParsingObjects() throws JSONException {
+    assertParsed(object("foo", 5), "{\"foo\": 5}");
+    assertParsed(object("foo", 5), "{foo: 5}");
+    assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\": 5, \"bar\": \"baz\"}");
+    assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\": 5; \"bar\": \"baz\"}");
+    assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\"= 5; \"bar\"= \"baz\"}");
+    assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\"=> 5; \"bar\"=> \"baz\"}");
+    assertParsed(object("foo", object(), "bar", array()), "{\"foo\"=> {}; \"bar\"=> []}");
+    assertParsed(object("foo", object("foo", array(5, 6))), "{\"foo\": {\"foo\": [5, 6]}}");
+    assertParsed(object("foo", object("foo", array(5, 6))), "{\"foo\":\n\t{\t \"foo\":[5,\r6]}}");
+  }
+
+  @Test
+  public void testSyntaxProblemUnterminatedObject() {
+    assertParseFail("{");
+    assertParseFail("{\"foo\"");
+    assertParseFail("{\"foo\":");
+    assertParseFail("{\"foo\":bar");
+    assertParseFail("{\"foo\":bar,");
+    assertParseFail("{\"foo\":bar,\"baz\"");
+    assertParseFail("{\"foo\":bar,\"baz\":");
+    assertParseFail("{\"foo\":bar,\"baz\":true");
+    assertParseFail("{\"foo\":bar,\"baz\":true,");
+  }
+
+  @Test
+  public void testSyntaxProblemEmptyString() {
+    assertParseFail("");
+  }
+
+  @Test
+  public void testSyntaxProblemUnterminatedArray() {
+    assertParseFail("[");
+    assertParseFail("[,");
+    assertParseFail("[,,");
+    assertParseFail("[true");
+    assertParseFail("[true,");
+    assertParseFail("[true,,");
+  }
+
+  @Test
+  public void testSyntaxProblemMalformedObject() {
+    assertParseFail("{:}");
+    assertParseFail("{\"key\":}");
+    assertParseFail("{:true}");
+    assertParseFail("{\"key\":true:}");
+    assertParseFail("{null:true}");
+    assertParseFail("{true:true}");
+    assertParseFail("{0xFF:true}");
+  }
+
+  private void assertParseFail(String malformedJson) {
+    try {
+      new JSONTokener(malformedJson).nextValue();
+      fail("Successfully parsed: \"" + malformedJson + "\"");
+    } catch (JSONException ignored) {
+    } catch (StackOverflowError e) {
+      fail("Stack overflowed on input: \"" + malformedJson + "\"");
     }
+  }
 
-    @Test
-    public void testParsingLargeHexValues() throws JSONException {
-        assertParsed(Integer.MAX_VALUE, "0x7FFFFFFF");
-        String message = "Hex values are parsed as Strings if their signed " +
-                "value is greater than Integer.MAX_VALUE.";
-        assertParsed(message, 0x80000000L, "0x80000000");
-    }
-
-    @Test
-    public void test64BitHexValues() throws JSONException {
-        // note that this is different from the same test in the original Android
-        // this is due to the fact that Long.parseLong doesn't correctly handle
-        // the value -1 expressed as unsigned hex if you use the normal JDK. Presumably
-        // the Android equivalent program does this better.
-        assertParsed("Large hex longs shouldn't yield ints or strings",
-                0xFFFFFFFFFFFFFFFL, "0xFFFFFFFFFFFFFFF");
-    }
+  private JSONArray array(Object... elements) {
+    return new JSONArray(Arrays.asList(elements));
+  }
 
-    @Test
-    public void testParsingWithCommentsAndWhitespace() throws JSONException {
-        assertParsed("baz", "  // foo bar \n baz");
-        assertParsed("baz", "  // foo bar \r baz");
-        assertParsed("baz", "  // foo bar \r\n baz");
-        assertParsed("baz", "  # foo bar \n baz");
-        assertParsed("baz", "  # foo bar \r baz");
-        assertParsed("baz", "  # foo bar \r\n baz");
-        assertParsed(5, "  /* foo bar \n baz */ 5");
-        assertParsed(5, "  /* foo bar \n baz */ 5 // quux");
-        assertParsed(5, "  5   ");
-        assertParsed(5, "  5  \r\n\t ");
-        assertParsed(5, "\r\n\t   5 ");
+  private JSONObject object(Object... keyValuePairs) throws JSONException {
+    JSONObject result = new JSONObject();
+    for (int i = 0; i < keyValuePairs.length; i += 2) {
+      result.put((String) keyValuePairs[i], keyValuePairs[i + 1]);
     }
-
-    @Test
-    public void testParsingArrays() throws JSONException {
-        assertParsed(array(), "[]");
-        assertParsed(array(5, 6, true), "[5,6,true]");
-        assertParsed(array(5, 6, array()), "[5,6,[]]");
-        assertParsed(array(5, 6, 7), "[5;6;7]");
-        assertParsed(array(5, 6, 7), "[5  , 6 \t; \r\n 7\n]");
-        assertParsed(array(5, 6, 7, null), "[5,6,7,]");
-        assertParsed(array(null, null), "[,]");
-        assertParsed(array(5, null, null, null, 5), "[5,,,,5]");
-        assertParsed(array(null, 5), "[,5]");
-        assertParsed(array(null, null, null), "[,,]");
-        assertParsed(array(null, null, null, 5), "[,,,5]");
-    }
-
-    @Test
-    public void testParsingObjects() throws JSONException {
-        assertParsed(object("foo", 5), "{\"foo\": 5}");
-        assertParsed(object("foo", 5), "{foo: 5}");
-        assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\": 5, \"bar\": \"baz\"}");
-        assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\": 5; \"bar\": \"baz\"}");
-        assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\"= 5; \"bar\"= \"baz\"}");
-        assertParsed(object("foo", 5, "bar", "baz"), "{\"foo\"=> 5; \"bar\"=> \"baz\"}");
-        assertParsed(object("foo", object(), "bar", array()), "{\"foo\"=> {}; \"bar\"=> []}");
-        assertParsed(object("foo", object("foo", array(5, 6))), "{\"foo\": {\"foo\": [5, 6]}}");
-        assertParsed(object("foo", object("foo", array(5, 6))), "{\"foo\":\n\t{\t \"foo\":[5,\r6]}}");
-    }
-
-    @Test
-    public void testSyntaxProblemUnterminatedObject() {
-        assertParseFail("{");
-        assertParseFail("{\"foo\"");
-        assertParseFail("{\"foo\":");
-        assertParseFail("{\"foo\":bar");
-        assertParseFail("{\"foo\":bar,");
-        assertParseFail("{\"foo\":bar,\"baz\"");
-        assertParseFail("{\"foo\":bar,\"baz\":");
-        assertParseFail("{\"foo\":bar,\"baz\":true");
-        assertParseFail("{\"foo\":bar,\"baz\":true,");
-    }
-
-    @Test
-    public void testSyntaxProblemEmptyString() {
-        assertParseFail("");
-    }
-
-    @Test
-    public void testSyntaxProblemUnterminatedArray() {
-        assertParseFail("[");
-        assertParseFail("[,");
-        assertParseFail("[,,");
-        assertParseFail("[true");
-        assertParseFail("[true,");
-        assertParseFail("[true,,");
-    }
-
-    @Test
-    public void testSyntaxProblemMalformedObject() {
-        assertParseFail("{:}");
-        assertParseFail("{\"key\":}");
-        assertParseFail("{:true}");
-        assertParseFail("{\"key\":true:}");
-        assertParseFail("{null:true}");
-        assertParseFail("{true:true}");
-        assertParseFail("{0xFF:true}");
-    }
-
-    private void assertParseFail(String malformedJson) {
-        try {
-            new JSONTokener(malformedJson).nextValue();
-            fail("Successfully parsed: \"" + malformedJson + "\"");
-        } catch (JSONException ignored) {
-        } catch (StackOverflowError e) {
-            fail("Stack overflowed on input: \"" + malformedJson + "\"");
-        }
-    }
-
-    private JSONArray array(Object... elements) {
-        return new JSONArray(Arrays.asList(elements));
-    }
-
-    private JSONObject object(Object... keyValuePairs) throws JSONException {
-        JSONObject result = new JSONObject();
-        for (int i = 0; i < keyValuePairs.length; i += 2) {
-            result.put((String) keyValuePairs[i], keyValuePairs[i + 1]);
-        }
-        return result;
-    }
-
-    private void assertParsed(String message, Object expected, String json) throws JSONException {
-        Object actual = new JSONTokener(json).nextValue();
-        actual = canonicalize(actual);
-        expected = canonicalize(expected);
-        assertEquals("For input \"" + json + "\" " + message, expected, actual);
-    }
-
-    private void assertParsed(Object expected, String json) throws JSONException {
-        assertParsed("", expected, json);
-    }
-
-    /**
-     * Since they don't implement equals or hashCode properly, this recursively
-     * replaces JSONObjects with an equivalent HashMap, and JSONArrays with the
-     * equivalent ArrayList.
-     */
-    private Object canonicalize(Object input) throws JSONException {
-        if (input instanceof JSONArray) {
-            JSONArray array = (JSONArray) input;
-            List<Object> result = new ArrayList<Object>();
-            for (int i = 0; i < array.length(); i++) {
-                result.add(canonicalize(array.opt(i)));
-            }
-            return result;
-        } else if (input instanceof JSONObject) {
-            JSONObject object = (JSONObject) input;
-            Map<String, Object> result = new HashMap<String, Object>();
-            for (Iterator<?> i = object.keys(); i.hasNext(); ) {
-                String key = (String) i.next();
-                result.put(key, canonicalize(object.get(key)));
-            }
-            return result;
-        } else if (input == null || input.equals(JSONObject.NULL)) {
-            return JSONObject.NULL;
-        } else {
-            return input;
-        }
+    return result;
+  }
+
+  private void assertParsed(String message, Object expected, String json) throws JSONException {
+    Object actual = new JSONTokener(json).nextValue();
+    actual = canonicalize(actual);
+    expected = canonicalize(expected);
+    assertEquals("For input \"" + json + "\" " + message, expected, actual);
+  }
+
+  private void assertParsed(Object expected, String json) throws JSONException {
+    assertParsed("", expected, json);
+  }
+
+  /**
+   * Since they don't implement equals or hashCode properly, this recursively replaces JSONObjects
+   * with an equivalent HashMap, and JSONArrays with the equivalent ArrayList.
+   */
+  private Object canonicalize(Object input) throws JSONException {
+    if (input instanceof JSONArray) {
+      JSONArray array = (JSONArray) input;
+      List<Object> result = new ArrayList<Object>();
+      for (int i = 0; i < array.length(); i++) {
+        result.add(canonicalize(array.opt(i)));
+      }
+      return result;
+    } else if (input instanceof JSONObject) {
+      JSONObject object = (JSONObject) input;
+      Map<String, Object> result = new HashMap<String, Object>();
+      for (Iterator<?> i = object.keys(); i.hasNext();) {
+        String key = (String) i.next();
+        result.put(key, canonicalize(object.get(key)));
+      }
+      return result;
+    } else if (input == null || input.equals(JSONObject.NULL)) {
+      return JSONObject.NULL;
+    } else {
+      return input;
     }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/test/java/org/json/SelfUseTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/SelfUseTest.java b/geode-json/src/test/java/org/json/SelfUseTest.java
index 0b9fb2c..78ee678 100755
--- a/geode-json/src/test/java/org/json/SelfUseTest.java
+++ b/geode-json/src/test/java/org/json/SelfUseTest.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -21,256 +19,255 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 
 /**
- * These tests checks self use calls. For the most part we doesn't attempt to
- * cover self-use, except in those cases where our clean room implementation
- * does it.
+ * These tests checks self use calls. For the most part we doesn't attempt to cover self-use, except
+ * in those cases where our clean room implementation does it.
  * <p>
- * <p>This black box test was written without inspecting the non-free org.json
- * sourcecode.
+ * <p>
+ * This black box test was written without inspecting the non-free org.json sourcecode.
  */
 public class SelfUseTest {
 
-    private int objectPutCalls = 0;
-    private int objectGetCalls = 0;
-    private int objectOptCalls = 0;
-    private int objectOptTypeCalls = 0;
-    private int arrayPutCalls = 0;
-    private int arrayGetCalls = 0;
-    private int arrayOptCalls = 0;
-    private int arrayOptTypeCalls = 0;
-    private int tokenerNextCalls = 0;
-    private int tokenerNextValueCalls = 0;
-
-    private final JSONObject object = new JSONObject() {
-        @Override
-        public JSONObject put(String name, Object value) throws JSONException {
-            objectPutCalls++;
-            return super.put(name, value);
-        }
-
-        @Override
-        public Object get(String name) throws JSONException {
-            objectGetCalls++;
-            return super.get(name);
-        }
-
-        @Override
-        public Object opt(String name) {
-            objectOptCalls++;
-            return super.opt(name);
-        }
-
-        @Override
-        public boolean optBoolean(String key, boolean defaultValue) {
-            objectOptTypeCalls++;
-            return super.optBoolean(key, defaultValue);
-        }
-
-        @Override
-        public double optDouble(String key, double defaultValue) {
-            objectOptTypeCalls++;
-            return super.optDouble(key, defaultValue);
-        }
-
-        @Override
-        public int optInt(String key, int defaultValue) {
-            objectOptTypeCalls++;
-            return super.optInt(key, defaultValue);
-        }
-
-        @Override
-        public long optLong(String key, long defaultValue) {
-            objectOptTypeCalls++;
-            return super.optLong(key, defaultValue);
-        }
-
-        @Override
-        public String optString(String key, String defaultValue) {
-            objectOptTypeCalls++;
-            return super.optString(key, defaultValue);
-        }
-    };
-
-    private final JSONArray array = new JSONArray() {
-        @Override
-        public JSONArray put(int index, Object value) throws JSONException {
-            arrayPutCalls++;
-            return super.put(index, value);
-        }
-
-        @Override
-        public Object get(int index) throws JSONException {
-            arrayGetCalls++;
-            return super.get(index);
-        }
-
-        @Override
-        public Object opt(int index) {
-            arrayOptCalls++;
-            return super.opt(index);
-        }
-
-        @Override
-        public boolean optBoolean(int index, boolean fallback) {
-            arrayOptTypeCalls++;
-            return super.optBoolean(index, fallback);
-        }
-
-        @Override
-        public double optDouble(int index, double fallback) {
-            arrayOptTypeCalls++;
-            return super.optDouble(index, fallback);
-        }
-
-        @Override
-        public long optLong(int index, long fallback) {
-            arrayOptTypeCalls++;
-            return super.optLong(index, fallback);
-        }
-
-        @Override
-        public String optString(int index, String fallback) {
-            arrayOptTypeCalls++;
-            return super.optString(index, fallback);
-        }
-
-        @Override
-        public int optInt(int index, int fallback) {
-            arrayOptTypeCalls++;
-            return super.optInt(index, fallback);
-        }
-    };
-
-    private final JSONTokener tokener = new JSONTokener("{\"foo\": [true]}") {
-        @Override
-        public char next() {
-            tokenerNextCalls++;
-            return super.next();
-        }
-
-        @Override
-        public Object nextValue() throws JSONException {
-            tokenerNextValueCalls++;
-            return super.nextValue();
-        }
-    };
-
-
-    @Test
-    public void testObjectPut() throws JSONException {
-        object.putOpt("foo", "bar");
-        assertEquals(1, objectPutCalls);
+  private int objectPutCalls = 0;
+  private int objectGetCalls = 0;
+  private int objectOptCalls = 0;
+  private int objectOptTypeCalls = 0;
+  private int arrayPutCalls = 0;
+  private int arrayGetCalls = 0;
+  private int arrayOptCalls = 0;
+  private int arrayOptTypeCalls = 0;
+  private int tokenerNextCalls = 0;
+  private int tokenerNextValueCalls = 0;
+
+  private final JSONObject object = new JSONObject() {
+    @Override
+    public JSONObject put(String name, Object value) throws JSONException {
+      objectPutCalls++;
+      return super.put(name, value);
+    }
+
+    @Override
+    public Object get(String name) throws JSONException {
+      objectGetCalls++;
+      return super.get(name);
+    }
+
+    @Override
+    public Object opt(String name) {
+      objectOptCalls++;
+      return super.opt(name);
+    }
+
+    @Override
+    public boolean optBoolean(String key, boolean defaultValue) {
+      objectOptTypeCalls++;
+      return super.optBoolean(key, defaultValue);
+    }
+
+    @Override
+    public double optDouble(String key, double defaultValue) {
+      objectOptTypeCalls++;
+      return super.optDouble(key, defaultValue);
+    }
+
+    @Override
+    public int optInt(String key, int defaultValue) {
+      objectOptTypeCalls++;
+      return super.optInt(key, defaultValue);
+    }
+
+    @Override
+    public long optLong(String key, long defaultValue) {
+      objectOptTypeCalls++;
+      return super.optLong(key, defaultValue);
     }
 
-    @Test
-    public void testObjectAccumulate() throws JSONException {
-        object.accumulate("foo", "bar");
-        assertEquals(1, objectPutCalls);
+    @Override
+    public String optString(String key, String defaultValue) {
+      objectOptTypeCalls++;
+      return super.optString(key, defaultValue);
     }
+  };
 
-    @Test
-    public void testObjectGetBoolean() throws JSONException {
-        object.put("foo", "true");
-        object.getBoolean("foo");
-        assertEquals(1, objectGetCalls);
+  private final JSONArray array = new JSONArray() {
+    @Override
+    public JSONArray put(int index, Object value) throws JSONException {
+      arrayPutCalls++;
+      return super.put(index, value);
     }
 
-    @Test
-    public void testObjectOptType() throws JSONException {
-        object.optBoolean("foo");
-        assertEquals(1, objectOptCalls);
-        assertEquals(1, objectOptTypeCalls);
-        object.optDouble("foo");
-        assertEquals(2, objectOptCalls);
-        assertEquals(2, objectOptTypeCalls);
-        object.optInt("foo");
-        assertEquals(3, objectOptCalls);
-        assertEquals(3, objectOptTypeCalls);
-        object.optLong("foo");
-        assertEquals(4, objectOptCalls);
-        assertEquals(4, objectOptTypeCalls);
-        object.optString("foo");
-        assertEquals(5, objectOptCalls);
-        assertEquals(5, objectOptTypeCalls);
+    @Override
+    public Object get(int index) throws JSONException {
+      arrayGetCalls++;
+      return super.get(index);
     }
 
-    @Test
-    public void testToJSONArray() throws JSONException {
-        object.put("foo", 5);
-        object.put("bar", 10);
-        array.put("foo");
-        array.put("baz");
-        array.put("bar");
-        object.toJSONArray(array);
-        assertEquals(3, arrayOptCalls);
-        assertEquals(0, arrayOptTypeCalls);
-        assertEquals(3, objectOptCalls);
-        assertEquals(0, objectOptTypeCalls);
+    @Override
+    public Object opt(int index) {
+      arrayOptCalls++;
+      return super.opt(index);
     }
 
-    @Test
-    public void testPutAtIndex() throws JSONException {
-        array.put(10, false);
-        assertEquals(1, arrayPutCalls);
+    @Override
+    public boolean optBoolean(int index, boolean fallback) {
+      arrayOptTypeCalls++;
+      return super.optBoolean(index, fallback);
     }
 
-    @Test
-    public void testIsNull() {
-        array.isNull(5);
-        assertEquals(1, arrayOptCalls);
+    @Override
+    public double optDouble(int index, double fallback) {
+      arrayOptTypeCalls++;
+      return super.optDouble(index, fallback);
     }
 
-    @Test
-    public void testArrayGetType() throws JSONException {
-        array.put(true);
-        array.getBoolean(0);
-        assertEquals(1, arrayGetCalls);
+    @Override
+    public long optLong(int index, long fallback) {
+      arrayOptTypeCalls++;
+      return super.optLong(index, fallback);
     }
 
-    @Test
-    public void testArrayOptType() throws JSONException {
-        array.optBoolean(3);
-        assertEquals(1, arrayOptCalls);
-        assertEquals(1, arrayOptTypeCalls);
-        array.optDouble(3);
-        assertEquals(2, arrayOptCalls);
-        assertEquals(2, arrayOptTypeCalls);
-        array.optInt(3);
-        assertEquals(3, arrayOptCalls);
-        assertEquals(3, arrayOptTypeCalls);
-        array.optLong(3);
-        assertEquals(4, arrayOptCalls);
-        assertEquals(4, arrayOptTypeCalls);
-        array.optString(3);
-        assertEquals(5, arrayOptCalls);
-        assertEquals(5, arrayOptTypeCalls);
+    @Override
+    public String optString(int index, String fallback) {
+      arrayOptTypeCalls++;
+      return super.optString(index, fallback);
     }
 
-    @Test
-    public void testToJSONObject() throws JSONException {
-        array.put("foo");
-        array.put("baz");
-        array.put("bar");
-        JSONArray values = new JSONArray();
-        values.put(5.5d);
-        values.put(11d);
-        values.put(30);
-        values.toJSONObject(array);
-        assertEquals(3, arrayOptCalls);
-        assertEquals(0, arrayOptTypeCalls);
+    @Override
+    public int optInt(int index, int fallback) {
+      arrayOptTypeCalls++;
+      return super.optInt(index, fallback);
     }
+  };
 
-    @Test
-    public void testNextExpecting() throws JSONException {
-        tokener.next('{');
-        assertEquals(1, tokenerNextCalls);
-        tokener.next('\"');
-        assertEquals(2, tokenerNextCalls);
+  private final JSONTokener tokener = new JSONTokener("{\"foo\": [true]}") {
+    @Override
+    public char next() {
+      tokenerNextCalls++;
+      return super.next();
     }
 
-    @Test
-    public void testNextValue() throws JSONException {
-        tokener.nextValue();
-        assertEquals(4, tokenerNextValueCalls);
+    @Override
+    public Object nextValue() throws JSONException {
+      tokenerNextValueCalls++;
+      return super.nextValue();
     }
+  };
+
+
+  @Test
+  public void testObjectPut() throws JSONException {
+    object.putOpt("foo", "bar");
+    assertEquals(1, objectPutCalls);
+  }
+
+  @Test
+  public void testObjectAccumulate() throws JSONException {
+    object.accumulate("foo", "bar");
+    assertEquals(1, objectPutCalls);
+  }
+
+  @Test
+  public void testObjectGetBoolean() throws JSONException {
+    object.put("foo", "true");
+    object.getBoolean("foo");
+    assertEquals(1, objectGetCalls);
+  }
+
+  @Test
+  public void testObjectOptType() throws JSONException {
+    object.optBoolean("foo");
+    assertEquals(1, objectOptCalls);
+    assertEquals(1, objectOptTypeCalls);
+    object.optDouble("foo");
+    assertEquals(2, objectOptCalls);
+    assertEquals(2, objectOptTypeCalls);
+    object.optInt("foo");
+    assertEquals(3, objectOptCalls);
+    assertEquals(3, objectOptTypeCalls);
+    object.optLong("foo");
+    assertEquals(4, objectOptCalls);
+    assertEquals(4, objectOptTypeCalls);
+    object.optString("foo");
+    assertEquals(5, objectOptCalls);
+    assertEquals(5, objectOptTypeCalls);
+  }
+
+  @Test
+  public void testToJSONArray() throws JSONException {
+    object.put("foo", 5);
+    object.put("bar", 10);
+    array.put("foo");
+    array.put("baz");
+    array.put("bar");
+    object.toJSONArray(array);
+    assertEquals(3, arrayOptCalls);
+    assertEquals(0, arrayOptTypeCalls);
+    assertEquals(3, objectOptCalls);
+    assertEquals(0, objectOptTypeCalls);
+  }
+
+  @Test
+  public void testPutAtIndex() throws JSONException {
+    array.put(10, false);
+    assertEquals(1, arrayPutCalls);
+  }
+
+  @Test
+  public void testIsNull() {
+    array.isNull(5);
+    assertEquals(1, arrayOptCalls);
+  }
+
+  @Test
+  public void testArrayGetType() throws JSONException {
+    array.put(true);
+    array.getBoolean(0);
+    assertEquals(1, arrayGetCalls);
+  }
+
+  @Test
+  public void testArrayOptType() throws JSONException {
+    array.optBoolean(3);
+    assertEquals(1, arrayOptCalls);
+    assertEquals(1, arrayOptTypeCalls);
+    array.optDouble(3);
+    assertEquals(2, arrayOptCalls);
+    assertEquals(2, arrayOptTypeCalls);
+    array.optInt(3);
+    assertEquals(3, arrayOptCalls);
+    assertEquals(3, arrayOptTypeCalls);
+    array.optLong(3);
+    assertEquals(4, arrayOptCalls);
+    assertEquals(4, arrayOptTypeCalls);
+    array.optString(3);
+    assertEquals(5, arrayOptCalls);
+    assertEquals(5, arrayOptTypeCalls);
+  }
+
+  @Test
+  public void testToJSONObject() throws JSONException {
+    array.put("foo");
+    array.put("baz");
+    array.put("bar");
+    JSONArray values = new JSONArray();
+    values.put(5.5d);
+    values.put(11d);
+    values.put(30);
+    values.toJSONObject(array);
+    assertEquals(3, arrayOptCalls);
+    assertEquals(0, arrayOptTypeCalls);
+  }
+
+  @Test
+  public void testNextExpecting() throws JSONException {
+    tokener.next('{');
+    assertEquals(1, tokenerNextCalls);
+    tokener.next('\"');
+    assertEquals(2, tokenerNextCalls);
+  }
+
+  @Test
+  public void testNextValue() throws JSONException {
+    tokener.nextValue();
+    assertEquals(4, tokenerNextValueCalls);
+  }
 }


[45/51] [abbrv] geode git commit: GEODE-2267: Enhance server/locator startup rules to include workingDir

Posted by ds...@apache.org.
GEODE-2267: Enhance server/locator startup rules to include workingDir


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/a9f0d227
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/a9f0d227
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/a9f0d227

Branch: refs/heads/feature/GEM-1195
Commit: a9f0d2272193fdcb43ffaa5b0f06e805ad4effa5
Parents: 6d263d5
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Wed Mar 1 15:12:11 2017 -0800
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Thu Mar 2 10:33:24 2017 -0800

----------------------------------------------------------------------
 geode-assembly/build.gradle                     |  2 +-
 .../management/internal/AgentUtilJUnitTest.java | 14 +---
 .../web/RestSecurityIntegrationTest.java        |  3 +-
 .../web/RestSecurityPostProcessorTest.java      |  3 +-
 .../rest/internal/web/RestServersJUnitTest.java |  3 +-
 .../internal/web/SwaggerVerificationTest.java   | 13 +++-
 .../geode/tools/pulse/PulseDataExportTest.java  |  2 +-
 .../geode/distributed/DistributedSystem.java    | 14 ++--
 .../cli/commands/DeployCommandsDUnitTest.java   |  5 +-
 .../CacheServerMBeanShiroJUnitTest.java         |  8 ++-
 .../security/CacheServerStartupRule.java        |  9 +--
 .../security/DeployCommandsSecurityTest.java    | 11 ++-
 .../security/GfshCommandsPostProcessorTest.java |  3 +-
 .../security/GfshCommandsSecurityTest.java      |  3 +-
 .../security/JavaRmiServerNameTest.java         | 11 ++-
 .../security/PeerAuthenticatorDUnitTest.java    |  5 +-
 ...eerSecurityWithEmbeddedLocatorDUnitTest.java |  8 ++-
 .../apache/geode/test/dunit/rules/Locator.java  |  6 +-
 .../dunit/rules/LocatorServerStartupRule.java   | 66 ++++++------------
 .../test/dunit/rules/LocatorStarterRule.java    | 69 +++++++++++++------
 .../apache/geode/test/dunit/rules/Member.java   |  6 +-
 .../apache/geode/test/dunit/rules/Server.java   |  6 +-
 .../test/dunit/rules/ServerStarterRule.java     | 70 ++++++++++++--------
 .../commands/QueryNamesOverHttpDUnitTest.java   | 25 ++++---
 24 files changed, 204 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index 1c95927..cce5245 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -96,7 +96,7 @@ test {
 }
 
 tasks.withType(Test){
-  environment 'GEODE_HOME', "$buildDir/install/${distributions.main.baseName}/lib"
+  environment 'GEODE_HOME', "$buildDir/install/${distributions.main.baseName}"
 }
 
 task defaultDistributionConfig(type: JavaExec, dependsOn: classes) {

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java
index 3a29e8a..fe1f777 100644
--- a/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/AgentUtilJUnitTest.java
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.management.internal;
 
+import static org.junit.Assert.assertNotNull;
+
 import org.apache.geode.internal.GemFireVersion;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.junit.Before;
@@ -22,11 +24,7 @@ import org.junit.Test;
 import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
-import static org.junit.Assert.assertNotNull;
-
-import java.io.File;
 import java.io.IOException;
-import java.nio.file.Path;
 
 @Category(IntegrationTest.class)
 public class AgentUtilJUnitTest {
@@ -39,14 +37,6 @@ public class AgentUtilJUnitTest {
 
   @Before
   public void setUp() throws IOException {
-    // GEODE-958: We need to set gemfire.home to tell AgentUtil where to find wars in case the env
-    // variable GEMFIRE is not set
-    Path installDir = new File(".").getAbsoluteFile().toPath().resolve("build").resolve("install")
-        .resolve("apache-geode");
-    System.out.println("Current dir is " + new File(".").getCanonicalPath());
-    System.out.println("Setting gemfire.home to " + installDir);
-    System.setProperty("gemfire.home", installDir.toString());
-
     version = GemFireVersion.getGemFireVersion();
     agentUtil = new AgentUtil(version);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
index f0b6bb3..75a3c2c 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
@@ -58,11 +58,12 @@ public class RestSecurityIntegrationTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
+  public static ServerStarterRule serverStarter = new ServerStarterRule();
   private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
 
   @BeforeClass
   public static void before() throws Exception {
+    serverStarter.startServer(properties);
     serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
index 160f634..933f7b2 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
@@ -65,11 +65,12 @@ public class RestSecurityPostProcessorTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
+  public static ServerStarterRule serverStarter = new ServerStarterRule();
   private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
 
   @BeforeClass
   public static void before() throws Exception {
+    serverStarter.startServer(properties);
     Region region =
         serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("customers");
     region.put("1", new Customer(1L, "John", "Doe", "555555555"));

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java
index 10ce515..d97bede 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestServersJUnitTest.java
@@ -43,11 +43,12 @@ public class RestServersJUnitTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
+  public static ServerStarterRule serverStarter = new ServerStarterRule();
   private static GeodeRestClient restClient;
 
   @BeforeClass
   public static void before() throws Exception {
+    serverStarter.startServer(properties);
     restClient = new GeodeRestClient("localhost", defaultPort);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java
index c7d0e73..43960a8 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/SwaggerVerificationTest.java
@@ -24,12 +24,13 @@ import static org.junit.Assert.assertThat;
 
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.RestAPITest;
 import org.apache.http.HttpResponse;
 import org.json.JSONObject;
+import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -50,11 +51,17 @@ public class SwaggerVerificationTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
-  private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
+  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  private GeodeRestClient restClient;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    serverStarter.startServer(properties);
+  }
 
   @Test
   public void isSwaggerRunning() throws Exception {
+    GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
     // Check the UI
     HttpResponse response = restClient.doGetRequest("/geode/swagger-ui.html");
     assertThat(GeodeRestClient.getCode(response), is(200));

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
index b547290..fa98ce6 100644
--- a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
@@ -77,7 +77,7 @@ public class PulseDataExportTest {
         .addIgnoredException("Failed to properly release resources held by the HTTP service:");
     IgnoredException.addIgnoredException("!STOPPED");
 
-    locator = lsRule.startLocatorVMWithPulse(0, new Properties());
+    locator = lsRule.startLocatorVM(0, new Properties());
 
     gfshConnector.connect(locator);
     assertThat(gfshConnector.isConnected()).isTrue();

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
index 20c948f..29ebf06 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
@@ -15,6 +15,8 @@
 
 package org.apache.geode.distributed;
 
+import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCKETS;
+
 import org.apache.geode.CancelCriterion;
 import org.apache.geode.LogWriter;
 import org.apache.geode.StatisticsFactory;
@@ -30,17 +32,19 @@ import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.tcp.ConnectionTable;
 import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.security.GemFireSecurityException;
 
 import java.io.File;
 import java.net.InetAddress;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
 /**
  * A "connection" to a GemFire distributed system. A <code>DistributedSystem</code> is created by
  * invoking the {@link #connect} method with a configuration as described
@@ -685,7 +689,7 @@ public abstract class DistributedSystem implements StatisticsFactory {
   }
 
   private static URL getFileURL(String fileName) {
-    File file = new File(fileName);
+    File file = new File(fileName).getAbsoluteFile();
 
     if (file.exists()) {
       try {

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
index 05f2c0c..5568743 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
@@ -395,8 +395,9 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
       Properties properties = new Properties();
       properties.setProperty("name", "Manager");
       properties.setProperty("groups", groupName);
-      ServerStarterRule serverStarterRule = new ServerStarterRule(properties);
-      serverStarterRule.startServer(locatorPort);
+      ServerStarterRule serverStarterRule = new ServerStarterRule();
+      serverStarterRule.before();
+      serverStarterRule.startServer(properties, locatorPort);
     });
 
     // Create a JAR file

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java
index 3183aaf..3167931 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanShiroJUnitTest.java
@@ -26,6 +26,7 @@ import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
@@ -46,7 +47,12 @@ public class CacheServerMBeanShiroJUnitTest {
   private CacheServerMXBean bean;
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
+  public static ServerStarterRule serverStarter = new ServerStarterRule();
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    serverStarter.startServer(properties);
+  }
 
   @Rule
   public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
index ea72cfa..30e1df8 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
@@ -33,7 +33,8 @@ import java.util.Properties;
  */
 public class CacheServerStartupRule extends ExternalResource implements Serializable {
 
-  private ServerStarterRule serverStarter = null;
+  private ServerStarterRule serverStarter = new ServerStarterRule();
+  private Properties properties = new Properties();
 
   public static CacheServerStartupRule withDefaultSecurityJson(int jmxManagerPort) {
     return new CacheServerStartupRule(jmxManagerPort,
@@ -41,7 +42,7 @@ public class CacheServerStartupRule extends ExternalResource implements Serializ
   }
 
   public CacheServerStartupRule(int jmxManagerPort, String jsonFile) {
-    Properties properties = new Properties();
+    properties = new Properties();
     if (jmxManagerPort > 0) {
       properties.put(JMX_MANAGER_PORT, String.valueOf(jmxManagerPort));
     }
@@ -49,12 +50,12 @@ public class CacheServerStartupRule extends ExternalResource implements Serializ
       properties.put(SECURITY_MANAGER, TestSecurityManager.class.getName());
       properties.put(TestSecurityManager.SECURITY_JSON, jsonFile);
     }
-    serverStarter = new ServerStarterRule(properties);
   }
 
   @Before
   public void before() throws Throwable {
-    serverStarter.startServer();
+    serverStarter.before();
+    serverStarter.startServer(properties);
     serverStarter.cache.createRegionFactory().create("region1");
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
index e89bd62..88cbfe9 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
@@ -47,12 +47,7 @@ public class DeployCommandsSecurityTest {
   private MemberMXBean bean;
 
   @ClassRule
-  public static ServerStarterRule serverRule = new ServerStarterRule(new Properties() {
-    {
-      setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
-      setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
-    }
-  });
+  public static ServerStarterRule serverRule = new ServerStarterRule();
 
   @ClassRule
   public static TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -61,6 +56,10 @@ public class DeployCommandsSecurityTest {
 
   @BeforeClass
   public static void beforeClass() throws Exception {
+    Properties properties = new Properties();
+    properties.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
+    properties.setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
+    serverRule.startServer(properties);
     File zipFile = temporaryFolder.newFile(zipFileName);
     deployCommand = "deploy --jar=" + zipFile.getAbsolutePath();
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
index 0980c18..6468195 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
@@ -53,13 +53,14 @@ public class GfshCommandsPostProcessorTest {
 
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
+  public static ServerStarterRule serverStarter = new ServerStarterRule();
   @Rule
   public GfshShellConnectionRule gfshConnection =
       new GfshShellConnectionRule(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
 
   @BeforeClass
   public static void beforeClass() throws Exception {
+    serverStarter.startServer(properties);
     serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("region1");
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index 2d32905..d1750c3 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -78,10 +78,11 @@ public class GfshCommandsSecurityTest {
       new GfshShellConnectionRule(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
+  public static ServerStarterRule serverStarter = new ServerStarterRule();
 
   @BeforeClass
   public static void beforeClass() throws Exception {
+    serverStarter.startServer(properties);
     serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("region1");
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/management/internal/security/JavaRmiServerNameTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/JavaRmiServerNameTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/JavaRmiServerNameTest.java
index 2ae6140..070e905 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/JavaRmiServerNameTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/JavaRmiServerNameTest.java
@@ -23,6 +23,7 @@ import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.junit.After;
+import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -34,7 +35,6 @@ public class JavaRmiServerNameTest {
 
   private static final String JMX_HOST = "myHostname";
 
-  private static int jmxManagerPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
   static Properties properties = new Properties() {
     {
       setProperty(JMX_MANAGER_PORT,
@@ -44,7 +44,14 @@ public class JavaRmiServerNameTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
+  public static ServerStarterRule serverStarter = new ServerStarterRule();
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    serverStarter.startServer(properties);
+  }
+
+
 
   // https://issues.apache.org/jira/browse/GEODE-1548
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
index 52afab4..dd913c2 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
@@ -60,9 +60,10 @@ public class PeerAuthenticatorDUnitTest {
     VM server2 = getHost(0).getVM(2);
 
     server2.invoke(() -> {
-      ServerStarterRule serverStarter = new ServerStarterRule(server2Props);
+      ServerStarterRule serverStarter = new ServerStarterRule();
+      serverStarter.before();
       LocatorServerStartupRule.serverStarter = serverStarter;
-      assertThatThrownBy(() -> serverStarter.startServer(locatorPort))
+      assertThatThrownBy(() -> serverStarter.startServer(server2Props, locatorPort))
           .isInstanceOf(GemFireSecurityException.class).hasMessageContaining("Invalid user name");
 
     });

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
index e87a285..c4bb152 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PeerSecurityWithEmbeddedLocatorDUnitTest.java
@@ -61,7 +61,8 @@ public class PeerSecurityWithEmbeddedLocatorDUnitTest {
 
     VM server2 = getHost(0).getVM(2);
     server2.invoke(() -> {
-      ServerStarterRule serverStarter = new ServerStarterRule(server2Props);
+      ServerStarterRule serverStarter = new ServerStarterRule();
+      serverStarter.before();
       LocatorServerStartupRule.serverStarter = serverStarter;
       assertThatThrownBy(() -> serverStarter.startServer(locatorPort))
           .isInstanceOf(GemFireSecurityException.class)
@@ -92,9 +93,10 @@ public class PeerSecurityWithEmbeddedLocatorDUnitTest {
 
     VM server2 = getHost(0).getVM(2);
     server2.invoke(() -> {
-      ServerStarterRule serverStarter = new ServerStarterRule(server2Props);
+      ServerStarterRule serverStarter = new ServerStarterRule();
+      serverStarter.before();
       LocatorServerStartupRule.serverStarter = serverStarter;
-      assertThatThrownBy(() -> serverStarter.startServer(locatorPort))
+      assertThatThrownBy(() -> serverStarter.startServer(server2Props, locatorPort))
           .isInstanceOf(GemFireSecurityException.class).hasMessageContaining("Invalid user name");
     });
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
index fe26e83..b1004b9 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
@@ -16,13 +16,11 @@
 
 package org.apache.geode.test.dunit.rules;
 
-import org.apache.geode.test.dunit.VM;
-
 import java.io.File;
 
 public class Locator extends Member {
 
-  public Locator(VM vm, int port, File workingDir, String name) {
-    super(vm, port, workingDir, name);
+  public Locator(int port, File workingDir, String name) {
+    super(port, workingDir, name);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index 6844720..39c13d0 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -76,6 +76,10 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     temporaryFolder.delete();
   }
 
+  public Locator startLocatorVM(int index) throws IOException {
+    return startLocatorVM(index, new Properties());
+  }
+
   /**
    * Starts a locator instance with the given configuration properties inside
    * {@code getHost(0).getVM(index)}.
@@ -86,49 +90,19 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     String name = "locator-" + index;
     locatorProperties.setProperty(NAME, name);
     File workingDir = createWorkingDirForMember(name);
-
-    VM locatorVM = getHost(0).getVM(index);
-    int locatorPort = locatorVM.invoke(() -> {
-      System.setProperty("user.dir", workingDir.getCanonicalPath());
-      locatorStarter = new LocatorStarterRule(locatorProperties);
-      locatorStarter.startLocator();
-      return locatorStarter.locator.getPort();
-    });
-    Locator locator = new Locator(locatorVM, locatorPort, workingDir, name);
-    members[index] = locator;
-    return locator;
-  }
-
-  public Locator startLocatorVMWithPulse(int index, Properties locatorProperties)
-      throws IOException {
-    String name = "locator-" + index;
-    locatorProperties.setProperty(NAME, name);
-    File workingDir = createWorkingDirForMember(name);
-
-    // Setting gemfire.home to this value allows locators started by the rule to run Pulse
-    String geodeInstallDir = new File(".").getAbsoluteFile().getParentFile().getParentFile()
-        .toPath().resolve("geode-assembly").resolve("build").resolve("install")
-        .resolve("apache-geode").toString();
-
-    System.out.println("Current dir is " + new File(".").getCanonicalPath());
-    System.out.println("Setting gemfire.home to " + geodeInstallDir);
-
     VM locatorVM = getHost(0).getVM(index);
-    int locatorPort = locatorVM.invoke(() -> {
-      System.setProperty("user.dir", workingDir.getCanonicalPath());
-      System.setProperty("gemfire.home", geodeInstallDir);
-      locatorStarter = new LocatorStarterRule(locatorProperties);
-      locatorStarter.startLocator();
-      return locatorStarter.locator.getPort();
+    Locator locator = locatorVM.invoke(() -> {
+      locatorStarter = new LocatorStarterRule(workingDir);
+      locatorStarter.before();
+      return locatorStarter.startLocator(locatorProperties);
     });
-    Locator locator = new Locator(locatorVM, locatorPort, workingDir, name);
+    locator.setVM(locatorVM);
     members[index] = locator;
     return locator;
   }
 
-
-  public Locator startLocatorVM(int index) throws IOException {
-    return startLocatorVM(index, new Properties());
+  public Server startServerVM(int index) throws IOException {
+    return startServerVM(index, new Properties(), -1);
   }
 
   /**
@@ -137,7 +111,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    * @return VM node vm
    */
   public Server startServerVM(int index, Properties properties) throws IOException {
-    return startServerVM(index, properties, 0);
+    return startServerVM(index, properties, -1);
   }
 
   public Server startServerVM(int index, int locatorPort) throws IOException {
@@ -149,18 +123,18 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    */
   public Server startServerVM(int index, Properties properties, int locatorPort)
       throws IOException {
+
     String name = "server-" + index;
     properties.setProperty(NAME, name);
-    File workingDir = createWorkingDirForMember(name);
 
+    File workingDir = createWorkingDirForMember(name);
     VM serverVM = getHost(0).getVM(index);
-    int port = serverVM.invoke(() -> {
-      System.setProperty("user.dir", workingDir.getCanonicalPath());
-      serverStarter = new ServerStarterRule(properties);
-      serverStarter.startServer(locatorPort);
-      return serverStarter.server.getPort();
+    Server server = serverVM.invoke(() -> {
+      serverStarter = new ServerStarterRule(workingDir);
+      serverStarter.before();
+      return serverStarter.startServer(properties, locatorPort);
     });
-    Server server = new Server(serverVM, port, workingDir, name);
+    server.setVM(serverVM);
     members[index] = server;
     return server;
   }
@@ -188,7 +162,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   }
 
   private File createWorkingDirForMember(String dirName) throws IOException {
-    File workingDir = new File(temporaryFolder.getRoot(), dirName);
+    File workingDir = new File(temporaryFolder.getRoot(), dirName).getAbsoluteFile();
     if (!workingDir.exists()) {
       temporaryFolder.newFolder(dirName);
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
index c3e493e..84c660c 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
@@ -18,15 +18,20 @@ package org.apache.geode.test.dunit.rules;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.junit.Assert.assertTrue;
 
-import org.awaitility.Awaitility;
+import org.apache.commons.io.FileUtils;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.InternalLocator;
+import org.awaitility.Awaitility;
 import org.junit.rules.ExternalResource;
 
+import java.io.File;
 import java.io.Serializable;
+import java.nio.file.Files;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
@@ -46,21 +51,55 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
 
   public InternalLocator locator;
 
-  private Properties properties;
+  private File workingDir;
+  private String oldUserDir;
 
   public LocatorStarterRule() {}
 
-  public LocatorStarterRule(Properties properties) {
-    this.properties = properties;
+  public LocatorStarterRule(File workingDir) {
+    this.workingDir = workingDir.getAbsoluteFile();
+  }
+
+  @Override
+  protected void before() throws Exception {
+    oldUserDir = System.getProperty("user.dir");
+    if (workingDir == null) {
+      workingDir = Files.createTempDirectory("locator").toAbsolutePath().toFile();
+    }
+    System.setProperty("user.dir", workingDir.toString());
+  }
+
+  @Override
+  protected void after() {
+    if (locator != null) {
+      locator.stop();
+    }
+    FileUtils.deleteQuietly(workingDir);
+    if (oldUserDir == null) {
+      System.clearProperty("user.dir");
+    } else {
+      System.setProperty("user.dir", oldUserDir);
+    }
   }
 
-  public void startLocator() throws Exception {
+
+  public org.apache.geode.test.dunit.rules.Locator startLocator() throws Exception {
+    return startLocator(new Properties());
+  }
+
+  public org.apache.geode.test.dunit.rules.Locator startLocator(Properties properties)
+      throws Exception {
     if (properties == null)
       properties = new Properties();
-    startLocator(properties);
-  }
+    if (!properties.containsKey(NAME)) {
+      properties.setProperty(NAME, "locator");
+    }
+
+    String name = properties.getProperty(NAME);
+    if (!properties.containsKey(LOG_FILE)) {
+      properties.setProperty(LOG_FILE, new File(name + ".log").getAbsolutePath());
+    }
 
-  public void startLocator(Properties properties) throws Exception {
     if (!properties.containsKey(MCAST_PORT)) {
       properties.setProperty(MCAST_PORT, "0");
     }
@@ -83,18 +122,6 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
       Awaitility.await().atMost(65, TimeUnit.SECONDS)
           .until(() -> assertTrue(locator.isSharedConfigurationRunning()));
     }
-  }
-
-  @Override
-  protected void before() throws Throwable {
-    if (properties != null)
-      startLocator(properties);
-  }
-
-  @Override
-  protected void after() {
-    if (locator != null) {
-      locator.stop();
-    }
+    return new org.apache.geode.test.dunit.rules.Locator(locatorPort, workingDir, name);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
index 7cc1eea..5f46da2 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
@@ -31,7 +31,7 @@ public abstract class Member implements Serializable {
   private File workingDir;
   private String name;
 
-  public Member(VM vm, int port, File workingDir, String name) {
+  public Member(int port, File workingDir, String name) {
     this.vm = vm;
     this.port = port;
     this.workingDir = workingDir;
@@ -47,6 +47,10 @@ public abstract class Member implements Serializable {
     return vm;
   }
 
+  public void setVM(VM vm) {
+    this.vm = vm;
+  }
+
   public int getPort() {
     return port;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
index 4aa2c69..83093c4 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
@@ -16,12 +16,10 @@
 
 package org.apache.geode.test.dunit.rules;
 
-import org.apache.geode.test.dunit.VM;
-
 import java.io.File;
 
 public class Server extends Member {
-  public Server(VM vm, int port, File workingDir, String name) {
-    super(vm, port, workingDir, name);
+  public Server(int port, File workingDir, String name) {
+    super(port, workingDir, name);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
index b5ddee6..df37579 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
@@ -19,16 +19,20 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.junit.rules.ExternalResource;
 
+import java.io.File;
 import java.io.Serializable;
+import java.nio.file.Files;
 import java.util.Properties;
 
 
@@ -51,7 +55,8 @@ public class ServerStarterRule extends ExternalResource implements Serializable
   public Cache cache;
   public CacheServer server;
 
-  private Properties properties;
+  private File workingDir;
+  private String oldUserDir;
 
   /**
    * Default constructor, if used, the rule won't start the server for you, you will need to
@@ -59,44 +64,58 @@ public class ServerStarterRule extends ExternalResource implements Serializable
    */
   public ServerStarterRule() {}
 
-  public ServerStarterRule(Properties properties) {
-    this.properties = properties;
+  public ServerStarterRule(File workingDir) {
+    this.workingDir = workingDir;
   }
 
-  public void startServer() throws Exception {
-    startServer(0, false);
+  public void before() throws Exception {
+    oldUserDir = System.getProperty("user.dir");
+    if (workingDir == null) {
+      workingDir = Files.createTempDirectory("server").toAbsolutePath().toFile();
+    }
+    System.setProperty("user.dir", workingDir.toString());
+  }
+
+  public Server startServer() throws Exception {
+    return startServer(new Properties(), -1, false);
   }
 
-  public void startServer(int locatorPort) throws Exception {
-    startServer(locatorPort, false);
+  public Server startServer(int locatorPort) throws Exception {
+    return startServer(new Properties(), locatorPort, false);
   }
 
-  public void startServer(int locatorPort, boolean pdxPersistent) throws Exception {
-    startServer(properties, locatorPort, pdxPersistent);
+  public Server startServer(int locatorPort, boolean pdxPersistent) throws Exception {
+    return startServer(new Properties(), locatorPort, pdxPersistent);
   }
 
-  public void startServer(Properties properties) throws Exception {
-    startServer(properties, 0, false);
+  public Server startServer(Properties properties) throws Exception {
+    return startServer(properties, -1, false);
   }
 
-  public void startServer(Properties properties, int locatorPort) throws Exception {
-    startServer(properties, locatorPort, false);
+  public Server startServer(Properties properties, int locatorPort) throws Exception {
+    return startServer(properties, locatorPort, false);
   }
 
-  public void startServer(Properties properties, int locatorPort, boolean pdxPersistent)
+  public Server startServer(Properties properties, int locatorPort, boolean pdxPersistent)
       throws Exception {
     if (properties == null) {
       properties = new Properties();
     }
+    if (!properties.containsKey(NAME)) {
+      properties.setProperty(NAME, "server");
+    }
+    String name = properties.getProperty(NAME);
+    if (!properties.containsKey(LOG_FILE)) {
+      properties.setProperty(LOG_FILE, new File(name + ".log").getAbsolutePath().toString());
+    }
+
     if (locatorPort > 0) {
       properties.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
     }
     if (!properties.containsKey(MCAST_PORT)) {
       properties.setProperty(MCAST_PORT, "0");
     }
-    if (!properties.containsKey(NAME)) {
-      properties.setProperty(NAME, this.getClass().getName());
-    }
+
     if (!properties.containsKey(LOCATORS)) {
       properties.setProperty(LOCATORS, "");
     }
@@ -116,16 +135,7 @@ public class ServerStarterRule extends ExternalResource implements Serializable
     server = cache.addCacheServer();
     server.setPort(0);
     server.start();
-  }
-
-  /**
-   * if you use this class as a rule, the default startServer will be called in the before. You need
-   * to make sure your properties to start the server with has the locator information it needs to
-   * connect to, otherwise, this server won't connect to any locator
-   */
-  protected void before() throws Throwable {
-    if (properties != null)
-      startServer();
+    return new Server(server.getPort(), workingDir, name);
   }
 
   @Override
@@ -141,5 +151,11 @@ public class ServerStarterRule extends ExternalResource implements Serializable
       server.stop();
       server = null;
     }
+    FileUtils.deleteQuietly(workingDir);
+    if (oldUserDir == null) {
+      System.clearProperty("user.dir");
+    } else {
+      System.setProperty("user.dir", oldUserDir);
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/a9f0d227/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
index 1a19e5e..4ec9c0d 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/QueryNamesOverHttpDUnitTest.java
@@ -29,6 +29,7 @@ import org.apache.geode.management.internal.web.http.HttpMethod;
 import org.apache.geode.management.internal.web.shell.RestHttpOperationInvoker;
 import org.apache.geode.test.dunit.rules.LocatorStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -43,22 +44,24 @@ import javax.management.QueryExp;
 
 @Category(IntegrationTest.class)
 public class QueryNamesOverHttpDUnitTest {
-
-
   protected static int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
   protected static int jmxPort = ports[0];
   protected static int httpPort = ports[1];
 
-  private static Properties locatorProps = new Properties() {
-    {
-      setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-      setProperty(HTTP_SERVICE_PORT, httpPort + "");
-      setProperty(JMX_MANAGER_PORT, jmxPort + "");
-    }
-  };
-
   @Rule
-  public LocatorStarterRule locatorRule = new LocatorStarterRule(locatorProps);
+  public LocatorStarterRule locatorRule = new LocatorStarterRule();
+
+  @Before
+  public void before() throws Exception {
+    Properties locatorProps = new Properties() {
+      {
+        setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+        setProperty(HTTP_SERVICE_PORT, httpPort + "");
+        setProperty(JMX_MANAGER_PORT, jmxPort + "");
+      }
+    };
+    locatorRule.startLocator(locatorProps);
+  }
 
 
   @Test


[15/51] [abbrv] geode git commit: GEODE-2142: spotless

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/main/java/org/json/JSONObject.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONObject.java b/geode-json/src/main/java/org/json/JSONObject.java
index ce15d1b..07a024c 100755
--- a/geode-json/src/main/java/org/json/JSONObject.java
+++ b/geode-json/src/main/java/org/json/JSONObject.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -29,55 +27,53 @@ import java.util.TreeMap;
 // Note: this class was written without inspecting the non-free org.json sourcecode.
 
 /**
- * A modifiable set of name/value mappings. Names are unique, non-null strings.
- * Values may be any mix of {@link JSONObject JSONObjects}, {@link JSONArray
- * JSONArrays}, Strings, Booleans, Integers, Longs, Doubles or {@link #NULL}.
- * Values may not be {@code null}, {@link Double#isNaN() NaNs}, {@link
- * Double#isInfinite() infinities}, or of any type not listed here.
+ * A modifiable set of name/value mappings. Names are unique, non-null strings. Values may be any
+ * mix of {@link JSONObject JSONObjects}, {@link JSONArray JSONArrays}, Strings, Booleans, Integers,
+ * Longs, Doubles or {@link #NULL}. Values may not be {@code null}, {@link Double#isNaN() NaNs},
+ * {@link Double#isInfinite() infinities}, or of any type not listed here.
  *
- * <p>This class can coerce values to another type when requested.
+ * <p>
+ * This class can coerce values to another type when requested.
  * <ul>
- * <li>When the requested type is a boolean, strings will be coerced using a
- * case-insensitive comparison to "true" and "false".
- * <li>When the requested type is a double, other {@link Number} types will
- * be coerced using {@link Number#doubleValue() doubleValue}. Strings
- * that can be coerced using {@link Double#valueOf(String)} will be.
- * <li>When the requested type is an int, other {@link Number} types will
- * be coerced using {@link Number#intValue() intValue}. Strings
- * that can be coerced using {@link Double#valueOf(String)} will be,
- * and then cast to int.
- * <li><a name="lossy">When the requested type is a long, other {@link Number} types will
- * be coerced using {@link Number#longValue() longValue}. Strings
- * that can be coerced using {@link Double#valueOf(String)} will be,
- * and then cast to long. This two-step conversion is lossy for very
- * large values. For example, the string "9223372036854775806" yields the
- * long 9223372036854775807.</a>
- * <li>When the requested type is a String, other non-null values will be
- * coerced using {@link String#valueOf(Object)}. Although null cannot be
- * coerced, the sentinel value {@link JSONObject#NULL} is coerced to the
- * string "null".
+ * <li>When the requested type is a boolean, strings will be coerced using a case-insensitive
+ * comparison to "true" and "false".
+ * <li>When the requested type is a double, other {@link Number} types will be coerced using
+ * {@link Number#doubleValue() doubleValue}. Strings that can be coerced using
+ * {@link Double#valueOf(String)} will be.
+ * <li>When the requested type is an int, other {@link Number} types will be coerced using
+ * {@link Number#intValue() intValue}. Strings that can be coerced using
+ * {@link Double#valueOf(String)} will be, and then cast to int.
+ * <li><a name="lossy">When the requested type is a long, other {@link Number} types will be coerced
+ * using {@link Number#longValue() longValue}. Strings that can be coerced using
+ * {@link Double#valueOf(String)} will be, and then cast to long. This two-step conversion is lossy
+ * for very large values. For example, the string "9223372036854775806" yields the long
+ * 9223372036854775807.</a>
+ * <li>When the requested type is a String, other non-null values will be coerced using
+ * {@link String#valueOf(Object)}. Although null cannot be coerced, the sentinel value
+ * {@link JSONObject#NULL} is coerced to the string "null".
  * </ul>
  *
- * <p>This class can look up both mandatory and optional values:
+ * <p>
+ * This class can look up both mandatory and optional values:
  * <ul>
- * <li>Use <code>get<i>Type</i>()</code> to retrieve a mandatory value. This
- * fails with a {@code JSONException} if the requested name has no value
- * or if the value cannot be coerced to the requested type.
- * <li>Use <code>opt<i>Type</i>()</code> to retrieve an optional value. This
- * returns a system- or user-supplied default if the requested name has no
- * value or if the value cannot be coerced to the requested type.
+ * <li>Use <code>get<i>Type</i>()</code> to retrieve a mandatory value. This fails with a
+ * {@code JSONException} if the requested name has no value or if the value cannot be coerced to the
+ * requested type.
+ * <li>Use <code>opt<i>Type</i>()</code> to retrieve an optional value. This returns a system- or
+ * user-supplied default if the requested name has no value or if the value cannot be coerced to the
+ * requested type.
  * </ul>
  *
- * <p><strong>Warning:</strong> this class represents null in two incompatible
- * ways: the standard Java {@code null} reference, and the sentinel value {@link
- * JSONObject#NULL}. In particular, calling {@code put(name, null)} removes the
- * named entry from the object but {@code put(name, JSONObject.NULL)} stores an
- * entry whose value is {@code JSONObject.NULL}.
+ * <p>
+ * <strong>Warning:</strong> this class represents null in two incompatible ways: the standard Java
+ * {@code null} reference, and the sentinel value {@link JSONObject#NULL}. In particular, calling
+ * {@code put(name, null)} removes the named entry from the object but
+ * {@code put(name, JSONObject.NULL)} stores an entry whose value is {@code JSONObject.NULL}.
  *
- * <p>Instances of this class are not thread safe. Although this class is
- * nonfinal, it was not designed for inheritance and should not be subclassed.
- * In particular, self-use by overrideable methods is not specified. See
- * <i>Effective Java</i> Item 17, "Design and Document or inheritance or else
+ * <p>
+ * Instances of this class are not thread safe. Although this class is nonfinal, it was not designed
+ * for inheritance and should not be subclassed. In particular, self-use by overrideable methods is
+ * not specified. See <i>Effective Java</i> Item 17, "Design and Document or inheritance or else
  * prohibit it" for further information.
  */
 public class JSONObject {
@@ -88,8 +84,8 @@ public class JSONObject {
   public static ThreadLocal<Boolean> cyclicDepChkEnabled = new ThreadLocal();
 
   /**
-   * A sentinel value used to explicitly define a name with no value. Unlike
-   * {@code null}, names with this value:
+   * A sentinel value used to explicitly define a name with no value. Unlike {@code null}, names
+   * with this value:
    * <ul>
    * <li>show up in the {@link #names} array
    * <li>show up in the {@link #keys} iterator
@@ -98,9 +94,9 @@ public class JSONObject {
    * <li>are included in the encoded JSON string.
    * </ul>
    *
-   * <p>This value violates the general contract of {@link Object#equals} by
-   * returning true when compared to {@code null}. Its {@link #toString}
-   * method returns "null".
+   * <p>
+   * This value violates the general contract of {@link Object#equals} by returning true when
+   * compared to {@code null}. Its {@link #toString} method returns "null".
    */
   public static final Object NULL = new Object() {
     @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@@ -131,21 +127,21 @@ public class JSONObject {
   }
 
   /**
-   * Creates a new {@code JSONObject} by copying all name/value mappings from
-   * the given map.
+   * Creates a new {@code JSONObject} by copying all name/value mappings from the given map.
+   * 
    * @param copyFrom a map whose keys are of type {@link String} and whose values are of supported
-   * types.
+   *        types.
    * @throws NullPointerException if any of the map's keys are null.
    */
-    /* (accept a raw type for API compatibility) */
+  /* (accept a raw type for API compatibility) */
   public JSONObject(Map copyFrom) {
     this();
     Map<?, ?> contentsTyped = (Map<?, ?>) copyFrom;
     for (Map.Entry<?, ?> entry : contentsTyped.entrySet()) {
-            /*
-             * Deviate from the original by checking that keys are non-null and
-             * of the proper type. (We still defer validating the values).
-             */
+      /*
+       * Deviate from the original by checking that keys are non-null and of the proper type. (We
+       * still defer validating the values).
+       */
       String key = (String) entry.getKey();
       if (key == null) {
         throw new NullPointerException("key == null");
@@ -155,16 +151,16 @@ public class JSONObject {
   }
 
   /**
-   * Creates a new {@code JSONObject} with name/value mappings from the next
-   * object in the tokener.
+   * Creates a new {@code JSONObject} with name/value mappings from the next object in the tokener.
+   * 
    * @param readFrom a tokener whose nextValue() method will yield a {@code JSONObject}.
    * @throws JSONException if the parse fails or doesn't yield a {@code JSONObject}.
    */
   public JSONObject(JSONTokener readFrom) throws JSONException {
-        /*
-         * Getting the parser to populate this could get tricky. Instead, just
-         * parse to temporary JSONObject and then steal the data from that.
-         */
+    /*
+     * Getting the parser to populate this could get tricky. Instead, just parse to temporary
+     * JSONObject and then steal the data from that.
+     */
     Object object = readFrom.nextValue();
     if (object instanceof JSONObject) {
       this.nameValuePairs = ((JSONObject) object).nameValuePairs;
@@ -174,8 +170,8 @@ public class JSONObject {
   }
 
   /**
-   * Creates a new {@code JSONObject} with name/value mappings from the JSON
-   * string.
+   * Creates a new {@code JSONObject} with name/value mappings from the JSON string.
+   * 
    * @param json a JSON-encoded string containing an object.
    * @throws JSONException if the parse fails or doesn't yield a {@code JSONObject}.
    */
@@ -184,9 +180,9 @@ public class JSONObject {
   }
 
   /**
-   * Creates a new {@code JSONObject} by copying mappings for the listed names
-   * from the given object. Names that aren't present in {@code copyFrom} will
-   * be skipped.
+   * Creates a new {@code JSONObject} by copying mappings for the listed names from the given
+   * object. Names that aren't present in {@code copyFrom} will be skipped.
+   * 
    * @param copyFrom The source object.
    * @param names The names of the fields to copy.
    * @throws JSONException On internal errors. Shouldn't happen.
@@ -203,6 +199,7 @@ public class JSONObject {
 
   /**
    * Creates a json object from a bean
+   * 
    * @param bean the bean to create the json object from
    * @throws JSONException If there is an exception while reading the bean
    */
@@ -269,6 +266,7 @@ public class JSONObject {
 
   /**
    * Returns the number of name/value mappings in this object.
+   * 
    * @return the length of this.
    */
   public int length() {
@@ -276,8 +274,9 @@ public class JSONObject {
   }
 
   /**
-   * Maps {@code name} to {@code value}, clobbering any existing name/value
-   * mapping with the same name.
+   * Maps {@code name} to {@code value}, clobbering any existing name/value mapping with the same
+   * name.
+   * 
    * @param name The name of the value to insert.
    * @param value The value to insert.
    * @return this object.
@@ -289,11 +288,12 @@ public class JSONObject {
   }
 
   /**
-   * Maps {@code name} to {@code value}, clobbering any existing name/value
-   * mapping with the same name.
+   * Maps {@code name} to {@code value}, clobbering any existing name/value mapping with the same
+   * name.
+   * 
    * @param name The name for the new value.
-   * @param value a finite value. May not be {@link Double#isNaN() NaNs} or {@link
-   * Double#isInfinite() infinities}.
+   * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}.
    * @return this object.
    * @throws JSONException if value is NaN or infinite.
    */
@@ -303,8 +303,9 @@ public class JSONObject {
   }
 
   /**
-   * Maps {@code name} to {@code value}, clobbering any existing name/value
-   * mapping with the same name.
+   * Maps {@code name} to {@code value}, clobbering any existing name/value mapping with the same
+   * name.
+   * 
    * @param name The name for the new value.
    * @param value The new value.
    * @return this object.
@@ -316,8 +317,9 @@ public class JSONObject {
   }
 
   /**
-   * Maps {@code name} to {@code value}, clobbering any existing name/value
-   * mapping with the same name.
+   * Maps {@code name} to {@code value}, clobbering any existing name/value mapping with the same
+   * name.
+   * 
    * @param name The name of the new value.
    * @param value The new value to insert.
    * @return this object.
@@ -329,13 +331,13 @@ public class JSONObject {
   }
 
   /**
-   * Maps {@code name} to {@code value}, clobbering any existing name/value
-   * mapping with the same name. If the value is {@code null}, any existing
-   * mapping for {@code name} is removed.
+   * Maps {@code name} to {@code value}, clobbering any existing name/value mapping with the same
+   * name. If the value is {@code null}, any existing mapping for {@code name} is removed.
+   * 
    * @param name The name of the new value.
    * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, Integer, Long, Double,
-   * {@link #NULL}, or {@code null}. May not be {@link Double#isNaN() NaNs} or {@link
-   * Double#isInfinite() infinities}.
+   *        {@link #NULL}, or {@code null}. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}.
    * @return this object.
    * @throws JSONException if the value is an invalid double (infinite or NaN).
    */
@@ -353,8 +355,9 @@ public class JSONObject {
   }
 
   /**
-   * Equivalent to {@code put(name, value)} when both parameters are non-null;
-   * does nothing otherwise.
+   * Equivalent to {@code put(name, value)} when both parameters are non-null; does nothing
+   * otherwise.
+   * 
    * @param name The name of the value to insert.
    * @param value The value to insert.
    * @return this object.
@@ -368,22 +371,21 @@ public class JSONObject {
   }
 
   /**
-   * Appends {@code value} to the array already mapped to {@code name}. If
-   * this object has no mapping for {@code name}, this inserts a new mapping.
-   * If the mapping exists but its value is not an array, the existing
-   * and new values are inserted in order into a new array which is itself
-   * mapped to {@code name}. In aggregate, this allows values to be added to a
-   * mapping one at a time.
+   * Appends {@code value} to the array already mapped to {@code name}. If this object has no
+   * mapping for {@code name}, this inserts a new mapping. If the mapping exists but its value is
+   * not an array, the existing and new values are inserted in order into a new array which is
+   * itself mapped to {@code name}. In aggregate, this allows values to be added to a mapping one at
+   * a time.
    *
-   * Note that {@code append(String, Object)} provides better semantics.
-   * In particular, the mapping for {@code name} will <b>always</b> be a
-   * {@link JSONArray}. Using {@code accumulate} will result in either a
-   * {@link JSONArray} or a mapping whose type is the type of {@code value}
+   * Note that {@code append(String, Object)} provides better semantics. In particular, the mapping
+   * for {@code name} will <b>always</b> be a {@link JSONArray}. Using {@code accumulate} will
+   * result in either a {@link JSONArray} or a mapping whose type is the type of {@code value}
    * depending on the number of calls to it.
+   * 
    * @param name The name of the field to change.
    * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, Integer, Long, Double,
-   * {@link #NULL} or null. May not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
-   * infinities}.
+   *        {@link #NULL} or null. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}.
    * @return this object after mutation.
    * @throws JSONException If the object being added is an invalid number.
    */
@@ -408,15 +410,15 @@ public class JSONObject {
   }
 
   /**
-   * Appends values to the array mapped to {@code name}. A new {@link JSONArray}
-   * mapping for {@code name} will be inserted if no mapping exists. If the existing
-   * mapping for {@code name} is not a {@link JSONArray}, a {@link JSONException}
-   * will be thrown.
+   * Appends values to the array mapped to {@code name}. A new {@link JSONArray} mapping for
+   * {@code name} will be inserted if no mapping exists. If the existing mapping for {@code name} is
+   * not a {@link JSONArray}, a {@link JSONException} will be thrown.
+   * 
    * @param name The name of the array to which the value should be appended.
    * @param value The value to append.
    * @return this object.
    * @throws JSONException if {@code name} is {@code null} or if the mapping for {@code name} is
-   * non-null and is not a {@link JSONArray}.
+   *         non-null and is not a {@link JSONArray}.
    */
   public JSONObject append(String name, Object value) throws JSONException {
     Object current = nameValuePairs.get(checkName(name));
@@ -446,6 +448,7 @@ public class JSONObject {
 
   /**
    * Removes the named mapping if it exists; does nothing otherwise.
+   * 
    * @param name The name of the mapping to remove.
    * @return the value previously mapped by {@code name}, or null if there was no such mapping.
    */
@@ -454,8 +457,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns true if this object has no mapping for {@code name} or if it has
-   * a mapping whose value is {@link #NULL}.
+   * Returns true if this object has no mapping for {@code name} or if it has a mapping whose value
+   * is {@link #NULL}.
+   * 
    * @param name The name of the value to check on.
    * @return true if the field doesn't exist or is null.
    */
@@ -465,8 +469,8 @@ public class JSONObject {
   }
 
   /**
-   * Returns true if this object has a mapping for {@code name}. The mapping
-   * may be {@link #NULL}.
+   * Returns true if this object has a mapping for {@code name}. The mapping may be {@link #NULL}.
+   * 
    * @param name The name of the value to check on.
    * @return true if this object has a field named {@code name}
    */
@@ -476,6 +480,7 @@ public class JSONObject {
 
   /**
    * Returns the value mapped by {@code name}, or throws if no such mapping exists.
+   * 
    * @param name The name of the value to get.
    * @return The value.
    * @throws JSONException if no such mapping exists.
@@ -489,8 +494,8 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name}, or null if no such mapping
-   * exists.
+   * Returns the value mapped by {@code name}, or null if no such mapping exists.
+   * 
    * @param name The name of the value to get.
    * @return The value.
    */
@@ -499,8 +504,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a boolean or
-   * can be coerced to a boolean, or throws otherwise.
+   * Returns the value mapped by {@code name} if it exists and is a boolean or can be coerced to a
+   * boolean, or throws otherwise.
+   * 
    * @param name The name of the field we want.
    * @return The selected value if it exists.
    * @throws JSONException if the mapping doesn't exist or cannot be coerced to a boolean.
@@ -515,8 +521,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a boolean or
-   * can be coerced to a boolean, or false otherwise.
+   * Returns the value mapped by {@code name} if it exists and is a boolean or can be coerced to a
+   * boolean, or false otherwise.
+   * 
    * @param name The name of the field we want.
    * @return The selected value if it exists.
    */
@@ -525,8 +532,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a boolean or
-   * can be coerced to a boolean, or {@code fallback} otherwise.
+   * Returns the value mapped by {@code name} if it exists and is a boolean or can be coerced to a
+   * boolean, or {@code fallback} otherwise.
+   * 
    * @param name The name of the field we want.
    * @param fallback The value to return if the field isn't there.
    * @return The selected value or the fallback.
@@ -538,8 +546,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a double or
-   * can be coerced to a double, or throws otherwise.
+   * Returns the value mapped by {@code name} if it exists and is a double or can be coerced to a
+   * double, or throws otherwise.
+   * 
    * @param name The name of the field we want.
    * @return The selected value if it exists.
    * @throws JSONException if the mapping doesn't exist or cannot be coerced to a double.
@@ -554,8 +563,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a double or
-   * can be coerced to a double, or {@code NaN} otherwise.
+   * Returns the value mapped by {@code name} if it exists and is a double or can be coerced to a
+   * double, or {@code NaN} otherwise.
+   * 
    * @param name The name of the field we want.
    * @return The selected value if it exists.
    */
@@ -564,8 +574,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a double or
-   * can be coerced to a double, or {@code fallback} otherwise.
+   * Returns the value mapped by {@code name} if it exists and is a double or can be coerced to a
+   * double, or {@code fallback} otherwise.
+   * 
    * @param name The name of the field we want.
    * @param fallback The value to return if the field isn't there.
    * @return The selected value or the fallback.
@@ -577,8 +588,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is an int or
-   * can be coerced to an int, or throws otherwise.
+   * Returns the value mapped by {@code name} if it exists and is an int or can be coerced to an
+   * int, or throws otherwise.
+   * 
    * @param name The name of the field we want.
    * @return The selected value if it exists.
    * @throws JSONException if the mapping doesn't exist or cannot be coerced to an int.
@@ -593,8 +605,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is an int or
-   * can be coerced to an int, or 0 otherwise.
+   * Returns the value mapped by {@code name} if it exists and is an int or can be coerced to an
+   * int, or 0 otherwise.
+   * 
    * @param name The name of the field we want.
    * @return The selected value if it exists.
    */
@@ -603,8 +616,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is an int or
-   * can be coerced to an int, or {@code fallback} otherwise.
+   * Returns the value mapped by {@code name} if it exists and is an int or can be coerced to an
+   * int, or {@code fallback} otherwise.
+   * 
    * @param name The name of the field we want.
    * @param fallback The value to return if the field isn't there.
    * @return The selected value or the fallback.
@@ -616,12 +630,11 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a long or
-   * can be coerced to a long, or throws otherwise.
-   * Note that JSON represents numbers as doubles,
+   * Returns the value mapped by {@code name} if it exists and is a long or can be coerced to a
+   * long, or throws otherwise. Note that JSON represents numbers as doubles,
    *
-   * so this is <a href="#lossy">lossy</a>; use strings to transfer numbers
-   * via JSON without loss.
+   * so this is <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON without loss.
+   * 
    * @param name The name of the field that we want.
    * @return The value of the field.
    * @throws JSONException if the mapping doesn't exist or cannot be coerced to a long.
@@ -636,9 +649,10 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a long or
-   * can be coerced to a long, or 0 otherwise. Note that JSON represents numbers as doubles,
-   * so this is <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON.
+   * Returns the value mapped by {@code name} if it exists and is a long or can be coerced to a
+   * long, or 0 otherwise. Note that JSON represents numbers as doubles, so this is
+   * <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON.
+   * 
    * @param name The name of the field we want.
    * @return The selected value.
    */
@@ -647,10 +661,10 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists and is a long or
-   * can be coerced to a long, or {@code fallback} otherwise. Note that JSON represents
-   * numbers as doubles, so this is <a href="#lossy">lossy</a>; use strings to transfer
-   * numbers via JSON.
+   * Returns the value mapped by {@code name} if it exists and is a long or can be coerced to a
+   * long, or {@code fallback} otherwise. Note that JSON represents numbers as doubles, so this is
+   * <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON.
+   * 
    * @param name The name of the field we want.
    * @param fallback The value to return if the field isn't there.
    * @return The selected value or the fallback.
@@ -662,8 +676,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists, coercing it if
-   * necessary, or throws if no such mapping exists.
+   * Returns the value mapped by {@code name} if it exists, coercing it if necessary, or throws if
+   * no such mapping exists.
+   * 
    * @param name The name of the field we want.
    * @return The value of the field.
    * @throws JSONException if no such mapping exists.
@@ -678,8 +693,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists, coercing it if
-   * necessary, or the empty string if no such mapping exists.
+   * Returns the value mapped by {@code name} if it exists, coercing it if necessary, or the empty
+   * string if no such mapping exists.
+   * 
    * @param name The name of the field we want.
    * @return The value of the field.
    */
@@ -688,8 +704,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns the value mapped by {@code name} if it exists, coercing it if
-   * necessary, or {@code fallback} if no such mapping exists.
+   * Returns the value mapped by {@code name} if it exists, coercing it if necessary, or
+   * {@code fallback} if no such mapping exists.
+   * 
    * @param name The name of the field that we want.
    * @param fallback The value to return if the field doesn't exist.
    * @return The value of the field or fallback.
@@ -703,6 +720,7 @@ public class JSONObject {
   /**
    * Returns the value mapped by {@code name} if it exists and is a {@code
    * JSONArray}, or throws otherwise.
+   * 
    * @param name The field we want to get.
    * @return The value of the field (if it is a JSONArray.
    * @throws JSONException if the mapping doesn't exist or is not a {@code JSONArray}.
@@ -719,6 +737,7 @@ public class JSONObject {
   /**
    * Returns the value mapped by {@code name} if it exists and is a {@code
    * JSONArray}, or null otherwise.
+   * 
    * @param name The name of the field we want.
    * @return The value of the specified field (assuming it is a JSNOArray
    */
@@ -730,6 +749,7 @@ public class JSONObject {
   /**
    * Returns the value mapped by {@code name} if it exists and is a {@code
    * JSONObject}, or throws otherwise.
+   * 
    * @param name The name of the field that we want.
    * @return a specified field value (if it is a JSONObject)
    * @throws JSONException if the mapping doesn't exist or is not a {@code JSONObject}.
@@ -746,6 +766,7 @@ public class JSONObject {
   /**
    * Returns the value mapped by {@code name} if it exists and is a {@code
    * JSONObject}, or null otherwise.
+   * 
    * @param name The name of the value we want.
    * @return The specified value.
    */
@@ -755,9 +776,9 @@ public class JSONObject {
   }
 
   /**
-   * Returns an array with the values corresponding to {@code names}. The
-   * array contains null for names that aren't mapped. This method returns
-   * null if {@code names} is either null or empty.
+   * Returns an array with the values corresponding to {@code names}. The array contains null for
+   * names that aren't mapped. This method returns null if {@code names} is either null or empty.
+   * 
    * @param names The names of the fields that we want the values for.
    * @return The selected values.
    * @throws JSONException On internal errors. Shouldn't happen.
@@ -779,11 +800,11 @@ public class JSONObject {
   }
 
   /**
-   * Returns an iterator of the {@code String} names in this object. The
-   * returned iterator supports {@link Iterator#remove() remove}, which will
-   * remove the corresponding mapping from this object. If this object is
-   * modified after the iterator is returned, the iterator's behavior is
+   * Returns an iterator of the {@code String} names in this object. The returned iterator supports
+   * {@link Iterator#remove() remove}, which will remove the corresponding mapping from this object.
+   * If this object is modified after the iterator is returned, the iterator's behavior is
    * undefined. The order of the keys is undefined.
+   * 
    * @return an iterator over the keys.
    */
   public Iterator<String> keys() {
@@ -791,12 +812,12 @@ public class JSONObject {
   }
 
   /**
-   * Returns the set of {@code String} names in this object. The returned set
-   * is a view of the keys in this object. {@link Set#remove(Object)} will remove
-   * the corresponding mapping from this object and set iterator behaviour
-   * is undefined if this object is modified after it is returned.
+   * Returns the set of {@code String} names in this object. The returned set is a view of the keys
+   * in this object. {@link Set#remove(Object)} will remove the corresponding mapping from this
+   * object and set iterator behaviour is undefined if this object is modified after it is returned.
    *
    * See {@link #keys()}.
+   * 
    * @return The names in this object.
    */
   public Set<String> keySet() {
@@ -804,19 +825,22 @@ public class JSONObject {
   }
 
   /**
-   * Returns an array containing the string names in this object. This method
-   * returns null if this object contains no mappings.
+   * Returns an array containing the string names in this object. This method returns null if this
+   * object contains no mappings.
+   * 
    * @return the names.
    */
   public JSONArray names() {
-    return nameValuePairs.isEmpty()
-        ? null
+    return nameValuePairs.isEmpty() ? null
         : new JSONArray(new ArrayList<String>(nameValuePairs.keySet()));
   }
 
   /**
    * Encodes this object as a compact JSON string, such as:
-   * <pre>{"query":"Pizza","locations":[94043,90210]}</pre>
+   * 
+   * <pre>
+   * {"query":"Pizza","locations":[94043,90210]}
+   * </pre>
    */
   @Override
   public String toString() {
@@ -830,8 +854,8 @@ public class JSONObject {
   }
 
   /**
-   * Encodes this object as a human readable JSON string for debugging, such
-   * as:
+   * Encodes this object as a human readable JSON string for debugging, such as:
+   * 
    * <pre>
    * {
    *     "query": "Pizza",
@@ -839,7 +863,9 @@ public class JSONObject {
    *         94043,
    *         90210
    *     ]
-   * }</pre>
+   * }
+   * </pre>
+   * 
    * @param indentSpaces the number of spaces to indent for each level of nesting.
    * @return The string containing the pretty form of this.
    * @throws JSONException On internal errors. Shouldn't happen.
@@ -860,8 +886,9 @@ public class JSONObject {
 
   /**
    * Encodes the number as a JSON string.
-   * @param number a finite value. May not be {@link Double#isNaN() NaNs} or {@link
-   * Double#isInfinite() infinities}.
+   * 
+   * @param number a finite value. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}.
    * @return The encoded number in string form.
    * @throws JSONException On internal errors. Shouldn't happen.
    */
@@ -887,8 +914,9 @@ public class JSONObject {
   }
 
   /**
-   * Encodes {@code data} as a JSON string. This applies quotes and any
-   * necessary character escaping.
+   * Encodes {@code data} as a JSON string. This applies quotes and any necessary character
+   * escaping.
+   * 
    * @param data the string to encode. Null will be interpreted as an empty string.
    * @return the quoted string.
    */
@@ -910,7 +938,8 @@ public class JSONObject {
   /**
    * Wraps the given object if necessary.
    *
-   * <p>If the object is null or , returns {@link #NULL}. If the object is a {@code JSONArray} or
+   * <p>
+   * If the object is null or , returns {@link #NULL}. If the object is a {@code JSONArray} or
    * {@code JSONObject}, no wrapping is necessary. If the object is {@code NULL}, no wrapping is
    * necessary. If the object is an array or {@code Collection}, returns an equivalent {@code
    * JSONArray}. If the object is a {@code Map}, returns an equivalent {@code JSONObject}. If the
@@ -918,6 +947,7 @@ public class JSONObject {
    * a {@code java} package, returns the result of {@code toString}. If the object is some other
    * kind of object then it is assumed to be a bean and is converted to a JSONObject. If wrapping
    * fails, returns null.
+   * 
    * @param o The object to wrap.
    * @return The wrapped (if necessary) form of the object {$code o}
    */

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/main/java/org/json/JSONString.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONString.java b/geode-json/src/main/java/org/json/JSONString.java
index 34815a8..4a09d89 100755
--- a/geode-json/src/main/java/org/json/JSONString.java
+++ b/geode-json/src/main/java/org/json/JSONString.java
@@ -1,18 +1,17 @@
 package org.json;
+
 /**
- * The <code>JSONString</code> interface allows a <code>toJSONString()</code> 
- * method so that a class can change the behavior of 
- * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
- * and <code>JSONWriter.value(</code>Object<code>)</code>. The 
- * <code>toJSONString</code> method will be used instead of the default behavior 
- * of using the Object's <code>toString()</code> method and quoting the result.
+ * The <code>JSONString</code> interface allows a <code>toJSONString()</code> method so that a class
+ * can change the behavior of <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
+ * and <code>JSONWriter.value(</code>Object<code>)</code>. The <code>toJSONString</code> method will
+ * be used instead of the default behavior of using the Object's <code>toString()</code> method and
+ * quoting the result.
  */
 public interface JSONString {
   /**
-   * The <code>toJSONString</code> method allows a class to produce its own JSON 
-   * serialization. 
+   * The <code>toJSONString</code> method allows a class to produce its own JSON serialization.
    * 
    * @return A strictly syntactically correct JSON text.
    */
   public String toJSONString();
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/main/java/org/json/JSONStringer.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONStringer.java b/geode-json/src/main/java/org/json/JSONStringer.java
index db1121e..43224a5 100755
--- a/geode-json/src/main/java/org/json/JSONStringer.java
+++ b/geode-json/src/main/java/org/json/JSONStringer.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -23,448 +21,439 @@ import java.util.List;
 // Note: this class was written without inspecting the non-free org.json sourcecode.
 
 /**
- * Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most
- * application developers should use those methods directly and disregard this
- * API. For example:<pre>
+ * Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most application
+ * developers should use those methods directly and disregard this API. For example:
+ * 
+ * <pre>
  * JSONObject object = ...
- * String json = object.toString();</pre>
+ * String json = object.toString();
+ * </pre>
  *
- * <p>Stringers only encode well-formed JSON strings. In particular:
+ * <p>
+ * Stringers only encode well-formed JSON strings. In particular:
  * <ul>
  * <li>The stringer must have exactly one top-level array or object.
- * <li>Lexical scopes must be balanced: every call to {@link #array} must
- * have a matching call to {@link #endArray} and every call to {@link
- * #object} must have a matching call to {@link #endObject}.
+ * <li>Lexical scopes must be balanced: every call to {@link #array} must have a matching call to
+ * {@link #endArray} and every call to {@link #object} must have a matching call to
+ * {@link #endObject}.
  * <li>Arrays may not contain keys (property names).
  * <li>Objects must alternate keys (property names) and values.
- * <li>Values are inserted with either literal {@link #value(Object) value}
- * calls, or by nesting arrays or objects.
+ * <li>Values are inserted with either literal {@link #value(Object) value} calls, or by nesting
+ * arrays or objects.
  * </ul>
- * Calls that would result in a malformed JSON string will fail with a
- * {@link JSONException}.
+ * Calls that would result in a malformed JSON string will fail with a {@link JSONException}.
  *
- * <p>This class provides no facility for pretty-printing (ie. indenting)
- * output. To encode indented output, use {@link JSONObject#toString(int)} or
- * {@link JSONArray#toString(int)}.
+ * <p>
+ * This class provides no facility for pretty-printing (ie. indenting) output. To encode indented
+ * output, use {@link JSONObject#toString(int)} or {@link JSONArray#toString(int)}.
  *
- * <p>Some implementations of the API support at most 20 levels of nesting.
- * Attempts to create more than 20 levels of nesting may fail with a {@link
- * JSONException}.
+ * <p>
+ * Some implementations of the API support at most 20 levels of nesting. Attempts to create more
+ * than 20 levels of nesting may fail with a {@link JSONException}.
  *
- * <p>Each stringer may be used to encode a single top level value. Instances of
- * this class are not thread safe. Although this class is nonfinal, it was not
- * designed for inheritance and should not be subclassed. In particular,
- * self-use by overrideable methods is not specified. See <i>Effective Java</i>
- * Item 17, "Design and Document or inheritance or else prohibit it" for further
+ * <p>
+ * Each stringer may be used to encode a single top level value. Instances of this class are not
+ * thread safe. Although this class is nonfinal, it was not designed for inheritance and should not
+ * be subclassed. In particular, self-use by overrideable methods is not specified. See <i>Effective
+ * Java</i> Item 17, "Design and Document or inheritance or else prohibit it" for further
  * information.
  */
 public class JSONStringer {
 
-    /**
-     * The output data, containing at most one top-level array or object.
-     */
-    final StringBuilder out = new StringBuilder();
+  /**
+   * The output data, containing at most one top-level array or object.
+   */
+  final StringBuilder out = new StringBuilder();
 
-    /**
-     * Lexical scoping elements within this stringer, necessary to insert the
-     * appropriate separator characters (ie. commas and colons) and to detect
-     * nesting errors.
-     */
-    enum Scope {
-
-        /**
-         * An array with no elements requires no separators or newlines before
-         * it is closed.
-         */
-        EMPTY_ARRAY,
-
-        /**
-         * A array with at least one value requires a comma and newline before
-         * the next element.
-         */
-        NONEMPTY_ARRAY,
-
-        /**
-         * An object with no keys or values requires no separators or newlines
-         * before it is closed.
-         */
-        EMPTY_OBJECT,
-
-        /**
-         * An object whose most recent element is a key. The next element must
-         * be a value.
-         */
-        DANGLING_KEY,
-
-        /**
-         * An object with at least one name/value pair requires a comma and
-         * newline before the next element.
-         */
-        NONEMPTY_OBJECT,
-
-        /**
-         * A special bracketless array needed by JSONStringer.join() and
-         * JSONObject.quote() only. Not used for JSON encoding.
-         */
-        NULL,
-    }
+  /**
+   * Lexical scoping elements within this stringer, necessary to insert the appropriate separator
+   * characters (ie. commas and colons) and to detect nesting errors.
+   */
+  enum Scope {
 
     /**
-     * Unlike the original implementation, this stack isn't limited to 20
-     * levels of nesting.
+     * An array with no elements requires no separators or newlines before it is closed.
      */
-    private final List<Scope> stack = new ArrayList<Scope>();
+    EMPTY_ARRAY,
 
     /**
-     * A string containing a full set of spaces for a single level of
-     * indentation, or null for no pretty printing.
+     * A array with at least one value requires a comma and newline before the next element.
      */
-    private final String indent;
-
-    public JSONStringer() {
-        indent = null;
-    }
-
-    JSONStringer(int indentSpaces) {
-        char[] indentChars = new char[indentSpaces];
-        Arrays.fill(indentChars, ' ');
-        indent = new String(indentChars);
-    }
+    NONEMPTY_ARRAY,
 
     /**
-     * Begins encoding a new array. Each call to this method must be paired with
-     * a call to {@link #endArray}.
-     *
-     * @return this stringer.
-     * @throws JSONException On internal errors. Shouldn't happen.
+     * An object with no keys or values requires no separators or newlines before it is closed.
      */
-    public JSONStringer array() throws JSONException {
-        return open(Scope.EMPTY_ARRAY, "[");
-    }
+    EMPTY_OBJECT,
 
     /**
-     * Ends encoding the current array.
-     *
-     * @return this stringer.
-     * @throws JSONException On internal errors. Shouldn't happen.
+     * An object whose most recent element is a key. The next element must be a value.
      */
-    public JSONStringer endArray() throws JSONException {
-        return close(Scope.EMPTY_ARRAY, Scope.NONEMPTY_ARRAY, "]");
-    }
+    DANGLING_KEY,
 
     /**
-     * Begins encoding a new object. Each call to this method must be paired
-     * with a call to {@link #endObject}.
-     *
-     * @return this stringer.
-     * @throws JSONException On internal errors. Shouldn't happen.
+     * An object with at least one name/value pair requires a comma and newline before the next
+     * element.
      */
-    public JSONStringer object() throws JSONException {
-        return open(Scope.EMPTY_OBJECT, "{");
-    }
+    NONEMPTY_OBJECT,
 
     /**
-     * Ends encoding the current object.
-     *
-     * @return this stringer.
-     * @throws JSONException On internal errors. Shouldn't happen.
+     * A special bracketless array needed by JSONStringer.join() and JSONObject.quote() only. Not
+     * used for JSON encoding.
      */
-    public JSONStringer endObject() throws JSONException {
-        return close(Scope.EMPTY_OBJECT, Scope.NONEMPTY_OBJECT, "}");
+    NULL,
+  }
+
+  /**
+   * Unlike the original implementation, this stack isn't limited to 20 levels of nesting.
+   */
+  private final List<Scope> stack = new ArrayList<Scope>();
+
+  /**
+   * A string containing a full set of spaces for a single level of indentation, or null for no
+   * pretty printing.
+   */
+  private final String indent;
+
+  public JSONStringer() {
+    indent = null;
+  }
+
+  JSONStringer(int indentSpaces) {
+    char[] indentChars = new char[indentSpaces];
+    Arrays.fill(indentChars, ' ');
+    indent = new String(indentChars);
+  }
+
+  /**
+   * Begins encoding a new array. Each call to this method must be paired with a call to
+   * {@link #endArray}.
+   *
+   * @return this stringer.
+   * @throws JSONException On internal errors. Shouldn't happen.
+   */
+  public JSONStringer array() throws JSONException {
+    return open(Scope.EMPTY_ARRAY, "[");
+  }
+
+  /**
+   * Ends encoding the current array.
+   *
+   * @return this stringer.
+   * @throws JSONException On internal errors. Shouldn't happen.
+   */
+  public JSONStringer endArray() throws JSONException {
+    return close(Scope.EMPTY_ARRAY, Scope.NONEMPTY_ARRAY, "]");
+  }
+
+  /**
+   * Begins encoding a new object. Each call to this method must be paired with a call to
+   * {@link #endObject}.
+   *
+   * @return this stringer.
+   * @throws JSONException On internal errors. Shouldn't happen.
+   */
+  public JSONStringer object() throws JSONException {
+    return open(Scope.EMPTY_OBJECT, "{");
+  }
+
+  /**
+   * Ends encoding the current object.
+   *
+   * @return this stringer.
+   * @throws JSONException On internal errors. Shouldn't happen.
+   */
+  public JSONStringer endObject() throws JSONException {
+    return close(Scope.EMPTY_OBJECT, Scope.NONEMPTY_OBJECT, "}");
+  }
+
+  /**
+   * Enters a new scope by appending any necessary whitespace and the given bracket.
+   */
+  JSONStringer open(Scope empty, String openBracket) throws JSONException {
+    if (stack.isEmpty() && out.length() > 0) {
+      throw new JSONException("Nesting problem: multiple top-level roots");
     }
-
-    /**
-     * Enters a new scope by appending any necessary whitespace and the given
-     * bracket.
-     */
-    JSONStringer open(Scope empty, String openBracket) throws JSONException {
-        if (stack.isEmpty() && out.length() > 0) {
-            throw new JSONException("Nesting problem: multiple top-level roots");
-        }
-        beforeValue();
-        stack.add(empty);
-        out.append(openBracket);
-        return this;
+    beforeValue();
+    stack.add(empty);
+    out.append(openBracket);
+    return this;
+  }
+
+  /**
+   * Closes the current scope by appending any necessary whitespace and the given bracket.
+   */
+  JSONStringer close(Scope empty, Scope nonempty, String closeBracket) throws JSONException {
+    Scope context = peek();
+    if (context != nonempty && context != empty) {
+      throw new JSONException("Nesting problem");
     }
 
-    /**
-     * Closes the current scope by appending any necessary whitespace and the
-     * given bracket.
-     */
-    JSONStringer close(Scope empty, Scope nonempty, String closeBracket) throws JSONException {
-        Scope context = peek();
-        if (context != nonempty && context != empty) {
-            throw new JSONException("Nesting problem");
-        }
-
-        stack.remove(stack.size() - 1);
-        if (context == nonempty) {
-            newline();
-        }
-        out.append(closeBracket);
-        return this;
+    stack.remove(stack.size() - 1);
+    if (context == nonempty) {
+      newline();
     }
-
-    /**
-     * Returns the value on the top of the stack.
-     */
-    private Scope peek() throws JSONException {
-        if (stack.isEmpty()) {
-            throw new JSONException("Nesting problem");
-        }
-        return stack.get(stack.size() - 1);
+    out.append(closeBracket);
+    return this;
+  }
+
+  /**
+   * Returns the value on the top of the stack.
+   */
+  private Scope peek() throws JSONException {
+    if (stack.isEmpty()) {
+      throw new JSONException("Nesting problem");
     }
-
-    /**
-     * Replace the value on the top of the stack with the given value.
-     */
-    private void replaceTop(Scope topOfStack) {
-        stack.set(stack.size() - 1, topOfStack);
+    return stack.get(stack.size() - 1);
+  }
+
+  /**
+   * Replace the value on the top of the stack with the given value.
+   */
+  private void replaceTop(Scope topOfStack) {
+    stack.set(stack.size() - 1, topOfStack);
+  }
+
+  /**
+   * Encodes {@code value}.
+   *
+   * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, Integer, Long, Double or
+   *        null. May not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}.
+   * @return this stringer.
+   * @throws JSONException On internal errors. Shouldn't happen.
+   */
+  public JSONStringer value(Object value) throws JSONException {
+    if (stack.isEmpty()) {
+      throw new JSONException("Nesting problem");
     }
 
-    /**
-     * Encodes {@code value}.
-     *
-     * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
-     *              Integer, Long, Double or null. May not be {@link Double#isNaN() NaNs}
-     *              or {@link Double#isInfinite() infinities}.
-     * @return this stringer.
-     * @throws JSONException On internal errors. Shouldn't happen.
-     */
-    public JSONStringer value(Object value) throws JSONException {
-        if (stack.isEmpty()) {
-            throw new JSONException("Nesting problem");
-        }
-
-        if (value instanceof JSONArray) {
-            ((JSONArray) value).writeTo(this);
-            return this;
-
-        } else if (value instanceof JSONObject) {
-            ((JSONObject) value).writeTo(this);
-            return this;
-        }
-
-        beforeValue();
-
-        if (value instanceof JSONString) {
-          out.append(((JSONString) value).toJSONString());
-          return this;
-        }
-
-        if (value == null
-              || value instanceof Boolean
-              || value == JSONObject.NULL) {
-            out.append(value);
-
-        } else if (value instanceof Number) {
-            out.append(JSONObject.numberToString((Number) value));
-
-        } else {
-            // Hack to make it possible that the value is not surrounded by quotes. (Used for JavaScript function calls)
-            // Example: { "name": "testkey", "value": window.myfunction() }
-            if (value.getClass().getSimpleName().contains("JSONFunction")) {
-                // note that no escaping of quotes (or anything else) is done in this case.
-                // that is fine because the only way to get to this point is to
-                // explicitly put a special kind of object into the JSON data structure.
-                out.append(value);
-            } else {
-                string(value.toString());
-            }
-        }
-
-        return this;
-    }
+    if (value instanceof JSONArray) {
+      ((JSONArray) value).writeTo(this);
+      return this;
 
-    /**
-     * Encodes {@code value} to this stringer.
-     *
-     * @param value The value to encode.
-     * @return this stringer.
-     * @throws JSONException On internal errors. Shouldn't happen.
-     */
-    public JSONStringer value(boolean value) throws JSONException {
-        if (stack.isEmpty()) {
-            throw new JSONException("Nesting problem");
-        }
-        beforeValue();
-        out.append(value);
-        return this;
+    } else if (value instanceof JSONObject) {
+      ((JSONObject) value).writeTo(this);
+      return this;
     }
 
-    /**
-     * Encodes {@code value} to this stringer.
-     *
-     * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
-     *              {@link Double#isInfinite() infinities}.
-     * @return this stringer.
-     * @throws JSONException On internal errors. Shouldn't happen.
-     */
-    public JSONStringer value(double value) throws JSONException {
-        if (stack.isEmpty()) {
-            throw new JSONException("Nesting problem");
-        }
-        beforeValue();
-        out.append(JSONObject.numberToString(value));
-        return this;
+    beforeValue();
+
+    if (value instanceof JSONString) {
+      out.append(((JSONString) value).toJSONString());
+      return this;
     }
 
-    /**
-     * Encodes {@code value} to this stringer.
-     *
-     * @param value The value to encode.
-     * @return this stringer.
-     * @throws JSONException If we have an internal error. Shouldn't happen.
-     */
-    public JSONStringer value(long value) throws JSONException {
-        if (stack.isEmpty()) {
-            throw new JSONException("Nesting problem");
-        }
-        beforeValue();
+    if (value == null || value instanceof Boolean || value == JSONObject.NULL) {
+      out.append(value);
+
+    } else if (value instanceof Number) {
+      out.append(JSONObject.numberToString((Number) value));
+
+    } else {
+      // Hack to make it possible that the value is not surrounded by quotes. (Used for JavaScript
+      // function calls)
+      // Example: { "name": "testkey", "value": window.myfunction() }
+      if (value.getClass().getSimpleName().contains("JSONFunction")) {
+        // note that no escaping of quotes (or anything else) is done in this case.
+        // that is fine because the only way to get to this point is to
+        // explicitly put a special kind of object into the JSON data structure.
         out.append(value);
-        return this;
+      } else {
+        string(value.toString());
+      }
     }
 
-    private void string(String value) {
-        out.append("\"");
-        char currentChar = 0;
-
-        for (int i = 0, length = value.length(); i < length; i++) {
-            char previousChar = currentChar;
-            currentChar = value.charAt(i);
-
-            /*
-             * From RFC 4627, "All Unicode characters may be placed within the
-             * quotation marks except for the characters that must be escaped:
-             * quotation mark, reverse solidus, and the control characters
-             * (U+0000 through U+001F)."
-             */
-            switch (currentChar) {
-                case '"':
-                case '\\':
-                    out.append('\\').append(currentChar);
-                    break;
-
-                case '/':
-                    // it makes life easier for HTML embedding of javascript if we escape </ sequences
-                    if (previousChar == '<') {
-                        out.append('\\');
-                    }
-                    out.append(currentChar);
-                    break;
-
-                case '\t':
-                    out.append("\\t");
-                    break;
-
-                case '\b':
-                    out.append("\\b");
-                    break;
-
-                case '\n':
-                    out.append("\\n");
-                    break;
-
-                case '\r':
-                    out.append("\\r");
-                    break;
-
-                case '\f':
-                    out.append("\\f");
-                    break;
-
-                default:
-                    if (currentChar <= 0x1F) {
-                        out.append(String.format("\\u%04x", (int) currentChar));
-                    } else {
-                        out.append(currentChar);
-                    }
-                    break;
-            }
-
-        }
-        out.append("\"");
+    return this;
+  }
+
+  /**
+   * Encodes {@code value} to this stringer.
+   *
+   * @param value The value to encode.
+   * @return this stringer.
+   * @throws JSONException On internal errors. Shouldn't happen.
+   */
+  public JSONStringer value(boolean value) throws JSONException {
+    if (stack.isEmpty()) {
+      throw new JSONException("Nesting problem");
     }
-
-    private void newline() {
-        if (indent == null) {
-            return;
-        }
-
-        out.append("\n");
-        for (int i = 0; i < stack.size(); i++) {
-            out.append(indent);
-        }
+    beforeValue();
+    out.append(value);
+    return this;
+  }
+
+  /**
+   * Encodes {@code value} to this stringer.
+   *
+   * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}.
+   * @return this stringer.
+   * @throws JSONException On internal errors. Shouldn't happen.
+   */
+  public JSONStringer value(double value) throws JSONException {
+    if (stack.isEmpty()) {
+      throw new JSONException("Nesting problem");
     }
+    beforeValue();
+    out.append(JSONObject.numberToString(value));
+    return this;
+  }
+
+  /**
+   * Encodes {@code value} to this stringer.
+   *
+   * @param value The value to encode.
+   * @return this stringer.
+   * @throws JSONException If we have an internal error. Shouldn't happen.
+   */
+  public JSONStringer value(long value) throws JSONException {
+    if (stack.isEmpty()) {
+      throw new JSONException("Nesting problem");
+    }
+    beforeValue();
+    out.append(value);
+    return this;
+  }
+
+  private void string(String value) {
+    out.append("\"");
+    char currentChar = 0;
+
+    for (int i = 0, length = value.length(); i < length; i++) {
+      char previousChar = currentChar;
+      currentChar = value.charAt(i);
+
+      /*
+       * From RFC 4627, "All Unicode characters may be placed within the quotation marks except for
+       * the characters that must be escaped: quotation mark, reverse solidus, and the control
+       * characters (U+0000 through U+001F)."
+       */
+      switch (currentChar) {
+        case '"':
+        case '\\':
+          out.append('\\').append(currentChar);
+          break;
+
+        case '/':
+          // it makes life easier for HTML embedding of javascript if we escape </ sequences
+          if (previousChar == '<') {
+            out.append('\\');
+          }
+          out.append(currentChar);
+          break;
+
+        case '\t':
+          out.append("\\t");
+          break;
+
+        case '\b':
+          out.append("\\b");
+          break;
+
+        case '\n':
+          out.append("\\n");
+          break;
+
+        case '\r':
+          out.append("\\r");
+          break;
+
+        case '\f':
+          out.append("\\f");
+          break;
+
+        default:
+          if (currentChar <= 0x1F) {
+            out.append(String.format("\\u%04x", (int) currentChar));
+          } else {
+            out.append(currentChar);
+          }
+          break;
+      }
 
-    /**
-     * Encodes the key (property name) to this stringer.
-     *
-     * @param name the name of the forthcoming value. May not be null.
-     * @return this stringer.
-     * @throws JSONException on internal errors, shouldn't happen.
-     */
-    public JSONStringer key(String name) throws JSONException {
-        if (name == null) {
-            throw new JSONException("Names must be non-null");
-        }
-        beforeKey();
-        string(name);
-        return this;
     }
+    out.append("\"");
+  }
 
-    /**
-     * Inserts any necessary separators and whitespace before a name. Also
-     * adjusts the stack to expect the key's value.
-     */
-    private void beforeKey() throws JSONException {
-        Scope context = peek();
-        if (context == Scope.NONEMPTY_OBJECT) { // first in object
-            out.append(',');
-        } else if (context != Scope.EMPTY_OBJECT) { // not in an object!
-            throw new JSONException("Nesting problem");
-        }
-        newline();
-        replaceTop(Scope.DANGLING_KEY);
+  private void newline() {
+    if (indent == null) {
+      return;
     }
 
-    /**
-     * Inserts any necessary separators and whitespace before a literal value,
-     * inline array, or inline object. Also adjusts the stack to expect either a
-     * closing bracket or another element.
-     */
-    private void beforeValue() throws JSONException {
-        if (stack.isEmpty()) {
-            return;
-        }
-
-        Scope context = peek();
-        if (context == Scope.EMPTY_ARRAY) { // first in array
-            replaceTop(Scope.NONEMPTY_ARRAY);
-            newline();
-        } else if (context == Scope.NONEMPTY_ARRAY) { // another in array
-            out.append(',');
-            newline();
-        } else if (context == Scope.DANGLING_KEY) { // value for key
-            out.append(indent == null ? ":" : ": ");
-            replaceTop(Scope.NONEMPTY_OBJECT);
-        } else if (context != Scope.NULL) {
-            throw new JSONException("Nesting problem");
-        }
+    out.append("\n");
+    for (int i = 0; i < stack.size(); i++) {
+      out.append(indent);
+    }
+  }
+
+  /**
+   * Encodes the key (property name) to this stringer.
+   *
+   * @param name the name of the forthcoming value. May not be null.
+   * @return this stringer.
+   * @throws JSONException on internal errors, shouldn't happen.
+   */
+  public JSONStringer key(String name) throws JSONException {
+    if (name == null) {
+      throw new JSONException("Names must be non-null");
+    }
+    beforeKey();
+    string(name);
+    return this;
+  }
+
+  /**
+   * Inserts any necessary separators and whitespace before a name. Also adjusts the stack to expect
+   * the key's value.
+   */
+  private void beforeKey() throws JSONException {
+    Scope context = peek();
+    if (context == Scope.NONEMPTY_OBJECT) { // first in object
+      out.append(',');
+    } else if (context != Scope.EMPTY_OBJECT) { // not in an object!
+      throw new JSONException("Nesting problem");
+    }
+    newline();
+    replaceTop(Scope.DANGLING_KEY);
+  }
+
+  /**
+   * Inserts any necessary separators and whitespace before a literal value, inline array, or inline
+   * object. Also adjusts the stack to expect either a closing bracket or another element.
+   */
+  private void beforeValue() throws JSONException {
+    if (stack.isEmpty()) {
+      return;
     }
 
-    /**
-     * Returns the encoded JSON string.
-     *
-     * <p>If invoked with unterminated arrays or unclosed objects, this method's
-     * return value is undefined.
-     *
-     * <p><strong>Warning:</strong> although it contradicts the general contract
-     * of {@link Object#toString}, this method returns null if the stringer
-     * contains no data.
-     */
-    @Override
-    public String toString() {
-        return out.length() == 0 ? null : out.toString();
+    Scope context = peek();
+    if (context == Scope.EMPTY_ARRAY) { // first in array
+      replaceTop(Scope.NONEMPTY_ARRAY);
+      newline();
+    } else if (context == Scope.NONEMPTY_ARRAY) { // another in array
+      out.append(',');
+      newline();
+    } else if (context == Scope.DANGLING_KEY) { // value for key
+      out.append(indent == null ? ":" : ": ");
+      replaceTop(Scope.NONEMPTY_OBJECT);
+    } else if (context != Scope.NULL) {
+      throw new JSONException("Nesting problem");
     }
+  }
+
+  /**
+   * Returns the encoded JSON string.
+   *
+   * <p>
+   * If invoked with unterminated arrays or unclosed objects, this method's return value is
+   * undefined.
+   *
+   * <p>
+   * <strong>Warning:</strong> although it contradicts the general contract of
+   * {@link Object#toString}, this method returns null if the stringer contains no data.
+   */
+  @Override
+  public String toString() {
+    return out.length() == 0 ? null : out.toString();
+  }
 }


[35/51] [abbrv] geode git commit: GEODE-2562 CTR Revise docs Main Features section

Posted by ds...@apache.org.
GEODE-2562 CTR  Revise docs Main Features section

- Remove instances of GemFire
- Simplify some language
- Add a paragraph about Geode Native (clients in other languages)


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/83ff6777
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/83ff6777
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/83ff6777

Branch: refs/heads/feature/GEM-1195
Commit: 83ff67777e431884ab510d83ca3c8b0e17c68998
Parents: 8a2983f
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Mar 1 14:21:42 2017 -0800
Committer: Karen Miller <km...@pivotal.io>
Committed: Wed Mar 1 14:21:42 2017 -0800

----------------------------------------------------------------------
 .../source/subnavs/geode-subnav.erb             |  2 +-
 .../getting_started/product_intro.html.md.erb   | 46 ++++++++++++--------
 2 files changed, 30 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/83ff6777/geode-book/master_middleman/source/subnavs/geode-subnav.erb
----------------------------------------------------------------------
diff --git a/geode-book/master_middleman/source/subnavs/geode-subnav.erb b/geode-book/master_middleman/source/subnavs/geode-subnav.erb
index 3711fff..5f03ee6 100644
--- a/geode-book/master_middleman/source/subnavs/geode-subnav.erb
+++ b/geode-book/master_middleman/source/subnavs/geode-subnav.erb
@@ -30,7 +30,7 @@ limitations under the License.
                         <a href="/docs/guide/11/getting_started/geode_overview.html">About Apache Geode</a>
                     </li>
                     <li>
-                        <a href="/docs/guide/11/getting_started/product_intro.html">Main Features of Apache Geode</a>
+                        <a href="/docs/guide/11/getting_started/product_intro.html">Main Features</a>
                     </li>
                     <li class="has_submenu">
                         <a href="/docs/guide/11/prereq_and_install.html">Prerequisites and Installation Instructions</a>

http://git-wip-us.apache.org/repos/asf/geode/blob/83ff6777/geode-docs/getting_started/product_intro.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/getting_started/product_intro.html.md.erb b/geode-docs/getting_started/product_intro.html.md.erb
index 471bd42..103b2dd 100644
--- a/geode-docs/getting_started/product_intro.html.md.erb
+++ b/geode-docs/getting_started/product_intro.html.md.erb
@@ -1,5 +1,5 @@
 ---
-title:  Main Features of Apache Geode
+title:  Main Features
 ---
 
 <!--
@@ -19,7 +19,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 -->
 
-This section summarizes the main features and key functionality of Apache Geode.
+This section summarizes main features and key functionality.
 
 -   [High Read-and-Write Throughput](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_CF0E3E5C4F884374B8F2F536DD2A375C)
 -   [Low and Predictable Latency](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_9C5D669B583646F1B817284EB494DDA7)
@@ -33,38 +33,39 @@ This section summarizes the main features and key functionality of Apache Geode.
 -   [Client/Server Security](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_577F601BC9854AA6B53CD3440F9B9A6A)
 -   [Multisite Data Distribution](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_091A306900D7402CAE5A46B5F9BFD612)
 -   [Continuous Querying](product_intro.html#concept_3B5E445B19884680900161BDF25E32C9__section_FF4C3B6E26104C4D93186F6FFE22B321)
+-   [Heterogeneous Data Sharing](product_intro.html#mainfeatures_heterogeneousdatasharing)
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_CF0E3E5C4F884374B8F2F536DD2A375C" class="no-quick-link"></a>High Read-and-Write Throughput
 
-Geode uses concurrent main-memory data structures and a highly optimized distribution infrastructure to provide read-and-write throughput. Applications can make copies of data dynamically in memory through synchronous or asynchronous replication for high read throughput or partition the data across many Geode system members to achieve high read-and-write throughput. Data partitioning doubles the aggregate throughput if the data access is fairly balanced across the entire data set. Linear increase in throughput is limited only by the backbone network capacity.
+Read-and-write throughput is provided by concurrent main-memory data structures and a highly optimized distribution infrastructure. Applications can make copies of data dynamically in memory through synchronous or asynchronous replication for high read throughput or partition the data across many system members to achieve high read-and-write throughput. Data partitioning doubles the aggregate throughput if the data access is fairly balanced across the entire data set. Linear increase in throughput is limited only by the backbone network capacity.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_9C5D669B583646F1B817284EB494DDA7" class="no-quick-link"></a>Low and Predictable Latency
 
-Geode's optimized caching layer minimizes context switches between threads and processes. It manages data in highly concurrent structures to minimize contention points. Communication to peer members is synchronous if the receivers can keep up, which keeps the latency for data distribution to a minimum. Servers manage object graphs in serialized form to reduce the strain on the garbage collector.
+The optimized caching layer minimizes context switches between threads and processes. It manages data in highly concurrent structures to minimize contention points. Communication to peer members is synchronous if the receivers can keep up, which keeps the latency for data distribution to a minimum. Servers manage object graphs in serialized form to reduce the strain on the garbage collector.
 
-Geode partitions subscription management (interest registration and continuous queries) across server data stores, ensuring that a subscription is processed only once for all interested clients. The resulting improvements in CPU use and bandwidth utilization improve throughput and reduce latency for client subscriptions.
+Subscription management (interest registration and continuous queries) is partitioned across server data stores, ensuring that a subscription is processed only once for all interested clients. The resulting improvements in CPU use and bandwidth utilization improve throughput and reduce latency for client subscriptions.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_EF7A73D35D1241289C9CA19EDDEBE959" class="no-quick-link"></a>High Scalability
 
-Geode achieves scalability through dynamic partitioning of data across many members and spreading the data load uniformly across the servers. For "hot" data, you can configure the system to expand dynamically to create more copies of the data. You can also provision application behavior to run in a distributed manner in close proximity to the data it needs.
+Scalability is achieved through dynamic partitioning of data across many members and spreading the data load uniformly across the servers. For "hot" data, you can configure the system to expand dynamically to create more copies of the data. You can also provision application behavior to run in a distributed manner in close proximity to the data it needs.
 
 If you need to support high and unpredictable bursts of concurrent client load, you can increase the number of servers managing the data and distribute the data and behavior across them to provide uniform and predictable response times. Clients are continuously load balanced to the server farm based on continuous feedback from the servers on their load conditions. With data partitioned and replicated across servers, clients can dynamically move to different servers to uniformly load the servers and deliver the best response times.
 
-You can also improve scalability by implementing asynchronous "write behind" of data changes to external data stores, like a database. Geode avoids a bottleneck by queuing all updates in order and redundantly. You can also conflate updates and propagate them in batch to the database.
+You can also improve scalability by implementing asynchronous "write behind" of data changes to external data stores, like a database. This avoids a bottleneck by queuing all updates in order and redundantly. You can also conflate updates and propagate them in batch to the database.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_CEB4ABFF83054AF6A47EA2FA09C240B1" class="no-quick-link"></a>Continuous Availability
 
-In addition to guaranteed consistent copies of data in memory, applications can persist data to disk on one or more Geode members synchronously or asynchronously by using Geode's "shared nothing disk architecture." All asynchronous events (store-forward events) are redundantly managed in at least two members such that if one server fails, the redundant one takes over. All clients connect to logical servers, and the client fails over automatically to alternate servers in a group during failures or when servers become unresponsive.
+In addition to guaranteed consistent copies of data in memory, applications can persist data to disk on one or more members synchronously or asynchronously by using a "shared nothing disk architecture." All asynchronous events (store-forward events) are redundantly managed in at least two members such that if one server fails, the redundant one takes over. All clients connect to logical servers, and the client fails over automatically to alternate servers in a group during failures or when servers become unresponsive.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_86D2B8CC346349F3913209AF87648A02" class="no-quick-link"></a>Reliable Event Notifications
 
 Publish/subscribe systems offer a data-distribution service where new events are published into the system and routed to all interested subscribers in a reliable manner. Traditional messaging platforms focus on message delivery, but often the receiving applications need access to related data before they can process the event. This requires them to access a standard database when the event is delivered, limiting the subscriber by the speed of the database.
 
-Geode offers data and events through a single system. Data is managed as objects in one or more distributed data regions, similar to tables in a database. Applications simply insert, update, or delete objects in data regions, and the platform delivers the object changes to the subscribers. The subscriber receiving the event has direct access to the related data in local memory or can fetch the data from one of the other members through a single hop.
+Data and events are offered through a single system. Data is managed as objects in one or more distributed data regions, similar to tables in a database. Applications simply insert, update, or delete objects in data regions, and the platform delivers the object changes to the subscribers. The subscriber receiving the event has direct access to the related data in local memory or can fetch the data from one of the other members through a single hop.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_A65B5F0DE8BF4AA6AFF16E3A75D4E0AD" class="no-quick-link"></a>Parallelized Application Behavior on Data Stores
 
-You can execute application business logic in parallel on the Geode members. Geode's data-aware function-execution service permits execution of arbitrary, data-dependent application functions on the members where the data is partitioned for locality of reference and scale.
+You can execute application business logic in parallel on members. The data-aware function-execution service permits execution of arbitrary, data-dependent application functions on the members where the data is partitioned for locality of reference and scale.
 
 By colocating the relevant data and parallelizing the calculation, you increase overall throughput. The calculation latency is inversely proportional to the number of members on which it can be parallelized.
 
@@ -72,9 +73,9 @@ The fundamental premise is to route the function transparently to the applicatio
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_97CABBFF553647F6BBBC40AA7AF6D4C7" class="no-quick-link"></a>Shared-Nothing Disk Persistence
 
-Each Geode system member manages data on disk files independent of other members. Failures in disks or cache failures in one member do not affect the ability of another cache instance to operate safely on its disk files. This "shared nothing" persistence architecture allows applications to be configured such that different classes of data are persisted on different members across the system, dramatically increasing the overall throughput of the application even when disk persistence is configured for application objects.
+Each distributed system member manages data on disk files independent of other members. Failures in disks or cache failures in one member do not affect the ability of another cache instance to operate safely on its disk files. This "shared nothing" persistence architecture allows applications to be configured such that different classes of data are persisted on different members across the system, dramatically increasing the overall throughput of the application even when disk persistence is configured for application objects.
 
-Unlike a traditional database system, Geode does not manage data and transaction logs in separate files. All data updates are appended to files that are similar to transactional logs of traditional databases. You can avoid disk-seek times if the disk is not concurrently used by other processes, and the only cost incurred is the rotational latency.
+Unlike a traditional database system, separate files are not used to manage data and transaction logs. All data updates are appended to files that are similar to transactional logs of traditional databases. You can avoid disk-seek times if the disk is not concurrently used by other processes, and the only cost incurred is the rotational latency.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_FCB2640F1BED4692A93F9300A41CE70D" class="no-quick-link"></a>Reduced Cost of Ownership
 
@@ -86,16 +87,27 @@ Clients can send individual data requests directly to the server holding the dat
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_577F601BC9854AA6B53CD3440F9B9A6A" class="no-quick-link"></a>Client/Server Security
 
-Geode supports running multiple, distinct users in client applications. This feature accommodates installations in which Geode clients are embedded in application servers and each application server supports data requests from many users. Each user may be authorized to access a small subset of data on the servers, as in a customer application where each customer can access only their own orders and shipments. Each user in the client connects to the server with its own set of credentials and has its own access authorization to the server cache.
-
-Client/server communication has increased security against replay attacks. The server sends the client a unique, random identifier with each response to be used in the next client request. Because of the identifier, even a repeated client operation call is sent as a unique request to the server.
+There may be multiple, distinct users in client applications. This feature accommodates installations in which clients are embedded in application servers and each application server supports data requests from many users. Each user may be authorized to access a small subset of data on the servers, as in a customer application where each customer can access only their own orders and shipments. Each user in the client connects to the server with its own set of credentials and has its own access authorization to the server cache.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_091A306900D7402CAE5A46B5F9BFD612" class="no-quick-link"></a>Multisite Data Distribution
 
-Scalability problems can result from data sites being spread out geographically across a wide-area network (WAN). GemFire offers a model to address these topologies, ranging from a single peer-to-peer cluster to reliable communications between data centers across the WAN. This model allows distributed systems to scale out in an unbounded and loosely coupled fashion without loss of performance, reliability or data consistency.
+Scalability problems can result from data sites being spread out geographically across a wide-area network (WAN). Models address these topologies, ranging from a single peer-to-peer cluster to reliable communications between data centers across the WAN. This model allows distributed systems to scale out in an unbounded and loosely coupled fashion without loss of performance, reliability or data consistency.
 
-At the core of this architecture is the gateway sender configuration used for distributing region events to a remote site. You can deploy gateway sender instances in parallel, which enables GemFire to increase the throughput for distributing region events across the WAN. You can also configure gateway sender queues for persistence and high availability to avoid data loss in the case of a member failure.
+At the core of this architecture is the gateway sender configuration used for distributing region events to a remote site. You can deploy gateway sender instances in parallel, which enables an increase in throughput for distributing region events across the WAN. You can also configure gateway sender queues for persistence and high availability to avoid data loss in the case of a member failure.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_FF4C3B6E26104C4D93186F6FFE22B321" class="no-quick-link"></a>Continuous Querying
 
 In messaging systems like Java Message Service, clients subscribe to topics and queues. Any message delivered to a topic is sent to the subscriber. Geode allows continuous querying by having applications express complex interest using Object Query Language.
+
+## <a id="mainfeatures_heterogeneousdatasharing" class="no-quick-link"></a>Heterogeneous Data Sharing
+
+C#, C++ and Java applications can share application business objects 
+without going through a transformation layer such as SOAP or XML.
+The server side behavior, though implemented in Java,
+provides a unique native cache for C++ and .NET applications.
+Application objects can be managed in the C++ process heap and 
+distributed to other processes using a common \u201con-the-wire\u201d representation
+for objects.
+A C++ serialized object can be directly deserialized as an equivalent Java 
+or C# object.
+A change to a business object in one language can trigger reliable notifications in applications written in the other supported languages.


[06/51] [abbrv] geode git commit: GEODE-2142: Removal of offending JSON.ORG code and license information

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/XML.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/XML.java b/geode-json/src/main/java/org/json/XML.java
deleted file mode 100755
index ae6d61a..0000000
--- a/geode-json/src/main/java/org/json/XML.java
+++ /dev/null
@@ -1,504 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-import java.util.Iterator;
-
-
-/**
- * This provides static methods to convert an XML text into a JSONObject, and to covert a JSONObject
- * into an XML text.
- * 
- * @author JSON.org
- * @version 2011-02-11
- */
-public class XML {
-
-  /** The Character '&'. */
-  public static final Character AMP = new Character('&');
-
-  /** The Character '''. */
-  public static final Character APOS = new Character('\'');
-
-  /** The Character '!'. */
-  public static final Character BANG = new Character('!');
-
-  /** The Character '='. */
-  public static final Character EQ = new Character('=');
-
-  /** The Character '>'. */
-  public static final Character GT = new Character('>');
-
-  /** The Character '<'. */
-  public static final Character LT = new Character('<');
-
-  /** The Character '?'. */
-  public static final Character QUEST = new Character('?');
-
-  /** The Character '"'. */
-  public static final Character QUOT = new Character('"');
-
-  /** The Character '/'. */
-  public static final Character SLASH = new Character('/');
-
-  /**
-   * Replace special characters with XML escapes:
-   * 
-   * <pre>
-   * &amp; <small>(ampersand)</small> is replaced by &amp;amp;
-   * &lt; <small>(less than)</small> is replaced by &amp;lt;
-   * &gt; <small>(greater than)</small> is replaced by &amp;gt;
-   * &quot; <small>(double quote)</small> is replaced by &amp;quot;
-   * </pre>
-   * 
-   * @param string The string to be escaped.
-   * @return The escaped string.
-   */
-  public static String escape(String string) {
-    StringBuffer sb = new StringBuffer();
-    for (int i = 0, length = string.length(); i < length; i++) {
-      char c = string.charAt(i);
-      switch (c) {
-        case '&':
-          sb.append("&amp;");
-          break;
-        case '<':
-          sb.append("&lt;");
-          break;
-        case '>':
-          sb.append("&gt;");
-          break;
-        case '"':
-          sb.append("&quot;");
-          break;
-        case '\'':
-          sb.append("&apos;");
-          break;
-        default:
-          sb.append(c);
-      }
-    }
-    return sb.toString();
-  }
-
-  /**
-   * Throw an exception if the string contains whitespace. Whitespace is not allowed in tagNames and
-   * attributes.
-   * 
-   * @param string
-   * @throws JSONException
-   */
-  public static void noSpace(String string) throws JSONException {
-    int i, length = string.length();
-    if (length == 0) {
-      throw new JSONException("Empty string.");
-    }
-    for (i = 0; i < length; i += 1) {
-      if (Character.isWhitespace(string.charAt(i))) {
-        throw new JSONException("'" + string + "' contains a space character.");
-      }
-    }
-  }
-
-  /**
-   * Scan the content following the named tag, attaching it to the context.
-   * 
-   * @param x The XMLTokener containing the source string.
-   * @param context The JSONObject that will include the new material.
-   * @param name The tag name.
-   * @return true if the close tag is processed.
-   * @throws JSONException
-   */
-  private static boolean parse(XMLTokener x, JSONObject context, String name) throws JSONException {
-    char c;
-    int i;
-    JSONObject jsonobject = null;
-    String string;
-    String tagName;
-    Object token;
-
-    // Test for and skip past these forms:
-    // <!-- ... -->
-    // <! ... >
-    // <![ ... ]]>
-    // <? ... ?>
-    // Report errors for these forms:
-    // <>
-    // <=
-    // <<
-
-    token = x.nextToken();
-
-    // <!
-
-    if (token == BANG) {
-      c = x.next();
-      if (c == '-') {
-        if (x.next() == '-') {
-          x.skipPast("-->");
-          return false;
-        }
-        x.back();
-      } else if (c == '[') {
-        token = x.nextToken();
-        if ("CDATA".equals(token)) {
-          if (x.next() == '[') {
-            string = x.nextCDATA();
-            if (string.length() > 0) {
-              context.accumulate("content", string);
-            }
-            return false;
-          }
-        }
-        throw x.syntaxError("Expected 'CDATA['");
-      }
-      i = 1;
-      do {
-        token = x.nextMeta();
-        if (token == null) {
-          throw x.syntaxError("Missing '>' after '<!'.");
-        } else if (token == LT) {
-          i += 1;
-        } else if (token == GT) {
-          i -= 1;
-        }
-      } while (i > 0);
-      return false;
-    } else if (token == QUEST) {
-
-      // <?
-
-      x.skipPast("?>");
-      return false;
-    } else if (token == SLASH) {
-
-      // Close tag </
-
-      token = x.nextToken();
-      if (name == null) {
-        throw x.syntaxError("Mismatched close tag " + token);
-      }
-      if (!token.equals(name)) {
-        throw x.syntaxError("Mismatched " + name + " and " + token);
-      }
-      if (x.nextToken() != GT) {
-        throw x.syntaxError("Misshaped close tag");
-      }
-      return true;
-
-    } else if (token instanceof Character) {
-      throw x.syntaxError("Misshaped tag");
-
-      // Open tag <
-
-    } else {
-      tagName = (String) token;
-      token = null;
-      jsonobject = new JSONObject();
-      for (;;) {
-        if (token == null) {
-          token = x.nextToken();
-        }
-
-        // attribute = value
-
-        if (token instanceof String) {
-          string = (String) token;
-          token = x.nextToken();
-          if (token == EQ) {
-            token = x.nextToken();
-            if (!(token instanceof String)) {
-              throw x.syntaxError("Missing value");
-            }
-            jsonobject.accumulate(string, XML.stringToValue((String) token));
-            token = null;
-          } else {
-            jsonobject.accumulate(string, "");
-          }
-
-          // Empty tag <.../>
-
-        } else if (token == SLASH) {
-          if (x.nextToken() != GT) {
-            throw x.syntaxError("Misshaped tag");
-          }
-          if (jsonobject.length() > 0) {
-            context.accumulate(tagName, jsonobject);
-          } else {
-            context.accumulate(tagName, "");
-          }
-          return false;
-
-          // Content, between <...> and </...>
-
-        } else if (token == GT) {
-          for (;;) {
-            token = x.nextContent();
-            if (token == null) {
-              if (tagName != null) {
-                throw x.syntaxError("Unclosed tag " + tagName);
-              }
-              return false;
-            } else if (token instanceof String) {
-              string = (String) token;
-              if (string.length() > 0) {
-                jsonobject.accumulate("content", XML.stringToValue(string));
-              }
-
-              // Nested element
-
-            } else if (token == LT) {
-              if (parse(x, jsonobject, tagName)) {
-                if (jsonobject.length() == 0) {
-                  context.accumulate(tagName, "");
-                } else if (jsonobject.length() == 1 && jsonobject.opt("content") != null) {
-                  context.accumulate(tagName, jsonobject.opt("content"));
-                } else {
-                  context.accumulate(tagName, jsonobject);
-                }
-                return false;
-              }
-            }
-          }
-        } else {
-          throw x.syntaxError("Misshaped tag");
-        }
-      }
-    }
-  }
-
-
-  /**
-   * Try to convert a string into a number, boolean, or null. If the string can't be converted,
-   * return the string. This is much less ambitious than JSONObject.stringToValue, especially
-   * because it does not attempt to convert plus forms, octal forms, hex forms, or E forms lacking
-   * decimal points.
-   * 
-   * @param string A String.
-   * @return A simple JSON value.
-   */
-  public static Object stringToValue(String string) {
-    if ("".equals(string)) {
-      return string;
-    }
-    if ("true".equalsIgnoreCase(string)) {
-      return Boolean.TRUE;
-    }
-    if ("false".equalsIgnoreCase(string)) {
-      return Boolean.FALSE;
-    }
-    if ("null".equalsIgnoreCase(string)) {
-      return JSONObject.NULL;
-    }
-    if ("0".equals(string)) {
-      return new Integer(0);
-    }
-
-    // If it might be a number, try converting it. If that doesn't work,
-    // return the string.
-
-    try {
-      char initial = string.charAt(0);
-      boolean negative = false;
-      if (initial == '-') {
-        initial = string.charAt(1);
-        negative = true;
-      }
-      if (initial == '0' && string.charAt(negative ? 2 : 1) == '0') {
-        return string;
-      }
-      if ((initial >= '0' && initial <= '9')) {
-        if (string.indexOf('.') >= 0) {
-          return Double.valueOf(string);
-        } else if (string.indexOf('e') < 0 && string.indexOf('E') < 0) {
-          Long myLong = new Long(string);
-          if (myLong.longValue() == myLong.intValue()) {
-            return new Integer(myLong.intValue());
-          } else {
-            return myLong;
-          }
-        }
-      }
-    } catch (Exception ignore) {
-    }
-    return string;
-  }
-
-
-  /**
-   * Convert a well-formed (but not necessarily valid) XML string into a JSONObject. Some
-   * information may be lost in this transformation because JSON is a data format and XML is a
-   * document format. XML uses elements, attributes, and content text, while JSON uses unordered
-   * collections of name/value pairs and arrays of values. JSON does not does not like to
-   * distinguish between elements and attributes. Sequences of similar elements are represented as
-   * JSONArrays. Content text may be placed in a "content" member. Comments, prologs, DTDs, and
-   * <code>&lt;[ [ ]]></code> are ignored.
-   * 
-   * @param string The source string.
-   * @return A JSONObject containing the structured data from the XML string.
-   * @throws JSONException
-   */
-  public static JSONObject toJSONObject(String string) throws JSONException {
-    JSONObject jo = new JSONObject();
-    XMLTokener x = new XMLTokener(string);
-    while (x.more() && x.skipPast("<")) {
-      parse(x, jo, null);
-    }
-    return jo;
-  }
-
-
-  /**
-   * Convert a JSONObject into a well-formed, element-normal XML string.
-   * 
-   * @param object A JSONObject.
-   * @return A string.
-   * @throws JSONException
-   */
-  public static String toString(Object object) throws JSONException {
-    return toString(object, null);
-  }
-
-
-  /**
-   * Convert a JSONObject into a well-formed, element-normal XML string.
-   * 
-   * @param object A JSONObject.
-   * @param tagName The optional name of the enclosing tag.
-   * @return A string.
-   * @throws JSONException
-   */
-  public static String toString(Object object, String tagName) throws JSONException {
-    StringBuffer sb = new StringBuffer();
-    int i;
-    JSONArray ja;
-    JSONObject jo;
-    String key;
-    Iterator keys;
-    int length;
-    String string;
-    Object value;
-    if (object instanceof JSONObject) {
-
-      // Emit <tagName>
-
-      if (tagName != null) {
-        sb.append('<');
-        sb.append(tagName);
-        sb.append('>');
-      }
-
-      // Loop thru the keys.
-
-      jo = (JSONObject) object;
-      keys = jo.keys();
-      while (keys.hasNext()) {
-        key = keys.next().toString();
-        value = jo.opt(key);
-        if (value == null) {
-          value = "";
-        }
-        if (value instanceof String) {
-          string = (String) value;
-        } else {
-          string = null;
-        }
-
-        // Emit content in body
-
-        if ("content".equals(key)) {
-          if (value instanceof JSONArray) {
-            ja = (JSONArray) value;
-            length = ja.length();
-            for (i = 0; i < length; i += 1) {
-              if (i > 0) {
-                sb.append('\n');
-              }
-              sb.append(escape(ja.get(i).toString()));
-            }
-          } else {
-            sb.append(escape(value.toString()));
-          }
-
-          // Emit an array of similar keys
-
-        } else if (value instanceof JSONArray) {
-          ja = (JSONArray) value;
-          length = ja.length();
-          for (i = 0; i < length; i += 1) {
-            value = ja.get(i);
-            if (value instanceof JSONArray) {
-              sb.append('<');
-              sb.append(key);
-              sb.append('>');
-              sb.append(toString(value));
-              sb.append("</");
-              sb.append(key);
-              sb.append('>');
-            } else {
-              sb.append(toString(value, key));
-            }
-          }
-        } else if ("".equals(value)) {
-          sb.append('<');
-          sb.append(key);
-          sb.append("/>");
-
-          // Emit a new tag <k>
-
-        } else {
-          sb.append(toString(value, key));
-        }
-      }
-      if (tagName != null) {
-
-        // Emit the </tagname> close tag
-
-        sb.append("</");
-        sb.append(tagName);
-        sb.append('>');
-      }
-      return sb.toString();
-
-      // XML does not have good support for arrays. If an array appears in a place
-      // where XML is lacking, synthesize an <array> element.
-
-    } else {
-      if (object.getClass().isArray()) {
-        object = new JSONArray(object);
-      }
-      if (object instanceof JSONArray) {
-        ja = (JSONArray) object;
-        length = ja.length();
-        for (i = 0; i < length; i += 1) {
-          sb.append(toString(ja.opt(i), tagName == null ? "array" : tagName));
-        }
-        return sb.toString();
-      } else {
-        string = (object == null) ? "null" : escape(object.toString());
-        return (tagName == null) ? "\"" + string + "\""
-            : (string.length() == 0) ? "<" + tagName + "/>"
-                : "<" + tagName + ">" + string + "</" + tagName + ">";
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/XMLTokener.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/XMLTokener.java b/geode-json/src/main/java/org/json/XMLTokener.java
deleted file mode 100755
index f56a1f6..0000000
--- a/geode-json/src/main/java/org/json/XMLTokener.java
+++ /dev/null
@@ -1,362 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * The XMLTokener extends the JSONTokener to provide additional methods for the parsing of XML
- * texts.
- * 
- * @author JSON.org
- * @version 2010-12-24
- */
-public class XMLTokener extends JSONTokener {
-
-
-  /**
-   * The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot.
-   */
-  public static final java.util.HashMap entity;
-
-  static {
-    entity = new java.util.HashMap(8);
-    entity.put("amp", XML.AMP);
-    entity.put("apos", XML.APOS);
-    entity.put("gt", XML.GT);
-    entity.put("lt", XML.LT);
-    entity.put("quot", XML.QUOT);
-  }
-
-  /**
-   * Construct an XMLTokener from a string.
-   * 
-   * @param s A source string.
-   */
-  public XMLTokener(String s) {
-    super(s);
-  }
-
-  /**
-   * Get the text in the CDATA block.
-   * 
-   * @return The string up to the <code>]]&gt;</code>.
-   * @throws JSONException If the <code>]]&gt;</code> is not found.
-   */
-  public String nextCDATA() throws JSONException {
-    char c;
-    int i;
-    StringBuffer sb = new StringBuffer();
-    for (;;) {
-      c = next();
-      if (end()) {
-        throw syntaxError("Unclosed CDATA");
-      }
-      sb.append(c);
-      i = sb.length() - 3;
-      if (i >= 0 && sb.charAt(i) == ']' && sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') {
-        sb.setLength(i);
-        return sb.toString();
-      }
-    }
-  }
-
-
-  /**
-   * Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<'
-   * character which begins a markup tag, and the content text between markup tags.
-   *
-   * @return A string, or a '<' Character, or null if there is no more source text.
-   * @throws JSONException
-   */
-  public Object nextContent() throws JSONException {
-    char c;
-    StringBuffer sb;
-    do {
-      c = next();
-    } while (Character.isWhitespace(c));
-    if (c == 0) {
-      return null;
-    }
-    if (c == '<') {
-      return XML.LT;
-    }
-    sb = new StringBuffer();
-    for (;;) {
-      if (c == '<' || c == 0) {
-        back();
-        return sb.toString().trim();
-      }
-      if (c == '&') {
-        sb.append(nextEntity(c));
-      } else {
-        sb.append(c);
-      }
-      c = next();
-    }
-  }
-
-
-  /**
-   * Return the next entity. These entities are translated to Characters:
-   * <code>&amp;  &apos;  &gt;  &lt;  &quot;</code>.
-   * 
-   * @param ampersand An ampersand character.
-   * @return A Character or an entity String if the entity is not recognized.
-   * @throws JSONException If missing ';' in XML entity.
-   */
-  public Object nextEntity(char ampersand) throws JSONException {
-    StringBuffer sb = new StringBuffer();
-    for (;;) {
-      char c = next();
-      if (Character.isLetterOrDigit(c) || c == '#') {
-        sb.append(Character.toLowerCase(c));
-      } else if (c == ';') {
-        break;
-      } else {
-        throw syntaxError("Missing ';' in XML entity: &" + sb);
-      }
-    }
-    String string = sb.toString();
-    Object object = entity.get(string);
-    return object != null ? object : ampersand + string + ";";
-  }
-
-
-  /**
-   * Returns the next XML meta token. This is used for skipping over <!...> and <?...?> structures.
-   * 
-   * @return Syntax characters (<code>< > / = ! ?</code>) are returned as Character, and strings and
-   *         names are returned as Boolean. We don't care what the values actually are.
-   * @throws JSONException If a string is not properly closed or if the XML is badly structured.
-   */
-  public Object nextMeta() throws JSONException {
-    char c;
-    char q;
-    do {
-      c = next();
-    } while (Character.isWhitespace(c));
-    switch (c) {
-      case 0:
-        throw syntaxError("Misshaped meta tag");
-      case '<':
-        return XML.LT;
-      case '>':
-        return XML.GT;
-      case '/':
-        return XML.SLASH;
-      case '=':
-        return XML.EQ;
-      case '!':
-        return XML.BANG;
-      case '?':
-        return XML.QUEST;
-      case '"':
-      case '\'':
-        q = c;
-        for (;;) {
-          c = next();
-          if (c == 0) {
-            throw syntaxError("Unterminated string");
-          }
-          if (c == q) {
-            return Boolean.TRUE;
-          }
-        }
-      default:
-        for (;;) {
-          c = next();
-          if (Character.isWhitespace(c)) {
-            return Boolean.TRUE;
-          }
-          switch (c) {
-            case 0:
-            case '<':
-            case '>':
-            case '/':
-            case '=':
-            case '!':
-            case '?':
-            case '"':
-            case '\'':
-              back();
-              return Boolean.TRUE;
-          }
-        }
-    }
-  }
-
-
-  /**
-   * Get the next XML Token. These tokens are found inside of angle brackets. It may be one of these
-   * characters: <code>/ > = ! ?</code> or it may be a string wrapped in single quotes or double
-   * quotes, or it may be a name.
-   * 
-   * @return a String or a Character.
-   * @throws JSONException If the XML is not well formed.
-   */
-  public Object nextToken() throws JSONException {
-    char c;
-    char q;
-    StringBuffer sb;
-    do {
-      c = next();
-    } while (Character.isWhitespace(c));
-    switch (c) {
-      case 0:
-        throw syntaxError("Misshaped element");
-      case '<':
-        throw syntaxError("Misplaced '<'");
-      case '>':
-        return XML.GT;
-      case '/':
-        return XML.SLASH;
-      case '=':
-        return XML.EQ;
-      case '!':
-        return XML.BANG;
-      case '?':
-        return XML.QUEST;
-
-      // Quoted string
-
-      case '"':
-      case '\'':
-        q = c;
-        sb = new StringBuffer();
-        for (;;) {
-          c = next();
-          if (c == 0) {
-            throw syntaxError("Unterminated string");
-          }
-          if (c == q) {
-            return sb.toString();
-          }
-          if (c == '&') {
-            sb.append(nextEntity(c));
-          } else {
-            sb.append(c);
-          }
-        }
-      default:
-
-        // Name
-
-        sb = new StringBuffer();
-        for (;;) {
-          sb.append(c);
-          c = next();
-          if (Character.isWhitespace(c)) {
-            return sb.toString();
-          }
-          switch (c) {
-            case 0:
-              return sb.toString();
-            case '>':
-            case '/':
-            case '=':
-            case '!':
-            case '?':
-            case '[':
-            case ']':
-              back();
-              return sb.toString();
-            case '<':
-            case '"':
-            case '\'':
-              throw syntaxError("Bad character in a name");
-          }
-        }
-    }
-  }
-
-
-  /**
-   * Skip characters until past the requested string. If it is not found, we are left at the end of
-   * the source with a result of false.
-   * 
-   * @param to A string to skip past.
-   * @throws JSONException
-   */
-  public boolean skipPast(String to) throws JSONException {
-    boolean b;
-    char c;
-    int i;
-    int j;
-    int offset = 0;
-    int length = to.length();
-    char[] circle = new char[length];
-
-    /*
-     * First fill the circle buffer with as many characters as are in the to string. If we reach an
-     * early end, bail.
-     */
-
-    for (i = 0; i < length; i += 1) {
-      c = next();
-      if (c == 0) {
-        return false;
-      }
-      circle[i] = c;
-    }
-    /*
-     * We will loop, possibly for all of the remaining characters.
-     */
-    for (;;) {
-      j = offset;
-      b = true;
-      /*
-       * Compare the circle buffer with the to string.
-       */
-      for (i = 0; i < length; i += 1) {
-        if (circle[j] != to.charAt(i)) {
-          b = false;
-          break;
-        }
-        j += 1;
-        if (j >= length) {
-          j -= length;
-        }
-      }
-      /*
-       * If we exit the loop with b intact, then victory is ours.
-       */
-      if (b) {
-        return true;
-      }
-      /*
-       * Get the next character. If there isn't one, then defeat is ours.
-       */
-      c = next();
-      if (c == 0) {
-        return false;
-      }
-      /*
-       * Shove the character in the circle buffer and advance the circle offset. The offset is mod
-       * n.
-       */
-      circle[offset] = c;
-      offset += 1;
-      if (offset >= length) {
-        offset -= length;
-      }
-    }
-  }
-}


[11/51] [abbrv] geode git commit: GEODE-2142: spotless

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/test/java/org/json/JSONStringerTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONStringerTest.java b/geode-json/src/test/java/org/json/JSONStringerTest.java
index 7c7362d..b3a8188 100755
--- a/geode-json/src/test/java/org/json/JSONStringerTest.java
+++ b/geode-json/src/test/java/org/json/JSONStringerTest.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -27,395 +25,392 @@ import static org.junit.Assert.*;
  */
 public class JSONStringerTest {
 
-    @Test
-    public void testJSONFunctionHackTest() {
-        JSONStringer stringer = new JSONStringer();
-        stringer.object();
-        stringer.key("key");
-        stringer.value(new JSONFunctionTestObject("window.test('foo' + \"bar\")"));
-        stringer.endObject();
-        assertEquals("{\"key\":window.test('foo' + \"bar\")}", stringer.toString());
+  @Test
+  public void testJSONFunctionHackTest() {
+    JSONStringer stringer = new JSONStringer();
+    stringer.object();
+    stringer.key("key");
+    stringer.value(new JSONFunctionTestObject("window.test('foo' + \"bar\")"));
+    stringer.endObject();
+    assertEquals("{\"key\":window.test('foo' + \"bar\")}", stringer.toString());
+  }
+
+  @Test
+  public void testEmptyStringer() {
+    // why isn't this the empty string?
+    assertNull(new JSONStringer().toString());
+  }
+
+  @Test
+  public void testValueJSONNull() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.array();
+    stringer.value(JSONObject.NULL);
+    stringer.endArray();
+    assertEquals("[null]", stringer.toString());
+  }
+
+  @Test
+  public void testEmptyObject() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.object();
+    stringer.endObject();
+    assertEquals("{}", stringer.toString());
+  }
+
+  @Test
+  public void testEmptyArray() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.array();
+    stringer.endArray();
+    assertEquals("[]", stringer.toString());
+  }
+
+  @Test
+  public void testArray() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.array();
+    stringer.value(false);
+    stringer.value(5.0);
+    stringer.value(5L);
+    stringer.value("five");
+    stringer.value(null);
+    stringer.endArray();
+    assertEquals("[false,5,5,\"five\",null]", stringer.toString());
+  }
+
+  @Test
+  public void testValueObjectMethods() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.array();
+    stringer.value(Boolean.FALSE);
+    stringer.value(Double.valueOf(5.0));
+    stringer.value(Long.valueOf(5L));
+    stringer.endArray();
+    assertEquals("[false,5,5]", stringer.toString());
+  }
+
+  @Test
+  public void testKeyValue() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.object();
+    stringer.key("a").value(false);
+    stringer.key("b").value(5.0);
+    stringer.key("c").value(5L);
+    stringer.key("d").value("five");
+    stringer.key("e").value(null);
+    stringer.endObject();
+    assertEquals("{\"a\":false," + "\"b\":5," + "\"c\":5," + "\"d\":\"five\"," + "\"e\":null}",
+        stringer.toString());
+  }
+
+  /**
+   * Test what happens when extreme values are emitted. Such values are likely to be rounded during
+   * parsing.
+   */
+  @Test
+  public void testNumericRepresentations() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.array();
+    stringer.value(Long.MAX_VALUE);
+    stringer.value(Double.MIN_VALUE);
+    stringer.endArray();
+    assertEquals("[9223372036854775807,4.9E-324]", stringer.toString());
+  }
+
+  @Test
+  public void testWeirdNumbers() throws JSONException {
+    try {
+      new JSONStringer().array().value(Double.NaN);
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testEmptyStringer() {
-        // why isn't this the empty string?
-        assertNull(new JSONStringer().toString());
+    try {
+      new JSONStringer().array().value(Double.NEGATIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testValueJSONNull() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.array();
-        stringer.value(JSONObject.NULL);
-        stringer.endArray();
-        assertEquals("[null]", stringer.toString());
+    try {
+      new JSONStringer().array().value(Double.POSITIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
     }
 
-    @Test
-    public void testEmptyObject() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.object();
-        stringer.endObject();
-        assertEquals("{}", stringer.toString());
+    JSONStringer stringer = new JSONStringer();
+    stringer.array();
+    stringer.value(-0.0d);
+    stringer.value(0.0d);
+    stringer.endArray();
+    assertEquals("[-0,0]", stringer.toString());
+  }
+
+  @Test
+  public void testMismatchedScopes() {
+    try {
+      new JSONStringer().key("a");
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testEmptyArray() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.array();
-        stringer.endArray();
-        assertEquals("[]", stringer.toString());
+    try {
+      new JSONStringer().value("a");
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testArray() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.array();
-        stringer.value(false);
-        stringer.value(5.0);
-        stringer.value(5L);
-        stringer.value("five");
-        stringer.value(null);
-        stringer.endArray();
-        assertEquals("[false,5,5,\"five\",null]", stringer.toString());
+    try {
+      new JSONStringer().endObject();
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testValueObjectMethods() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.array();
-        stringer.value(Boolean.FALSE);
-        stringer.value(Double.valueOf(5.0));
-        stringer.value(Long.valueOf(5L));
-        stringer.endArray();
-        assertEquals("[false,5,5]", stringer.toString());
+    try {
+      new JSONStringer().endArray();
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testKeyValue() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.object();
-        stringer.key("a").value(false);
-        stringer.key("b").value(5.0);
-        stringer.key("c").value(5L);
-        stringer.key("d").value("five");
-        stringer.key("e").value(null);
-        stringer.endObject();
-        assertEquals("{\"a\":false," +
-                "\"b\":5," +
-                "\"c\":5," +
-                "\"d\":\"five\"," +
-                "\"e\":null}", stringer.toString());
+    try {
+      new JSONStringer().array().endObject();
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    /**
-     * Test what happens when extreme values are emitted. Such values are likely
-     * to be rounded during parsing.
-     */
-    @Test
-    public void testNumericRepresentations() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.array();
-        stringer.value(Long.MAX_VALUE);
-        stringer.value(Double.MIN_VALUE);
-        stringer.endArray();
-        assertEquals("[9223372036854775807,4.9E-324]", stringer.toString());
+    try {
+      new JSONStringer().object().endArray();
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testWeirdNumbers() throws JSONException {
-        try {
-            new JSONStringer().array().value(Double.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().array().value(Double.NEGATIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().array().value(Double.POSITIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-
-        JSONStringer stringer = new JSONStringer();
-        stringer.array();
-        stringer.value(-0.0d);
-        stringer.value(0.0d);
-        stringer.endArray();
-        assertEquals("[-0,0]", stringer.toString());
+    try {
+      new JSONStringer().object().key("a").key("a");
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testMismatchedScopes() {
-        try {
-            new JSONStringer().key("a");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().value("a");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().endObject();
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().endArray();
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().array().endObject();
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().object().endArray();
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().object().key("a").key("a");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONStringer().object().value(false);
-            fail();
-        } catch (JSONException ignored) {
-        }
+    try {
+      new JSONStringer().object().value(false);
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testNullKey() {
-        try {
-            new JSONStringer().object().key(null);
-            fail();
-        } catch (JSONException ignored) {
-        }
+  }
+
+  @Test
+  public void testNullKey() {
+    try {
+      new JSONStringer().object().key(null);
+      fail();
+    } catch (JSONException ignored) {
     }
-
-    @Test
-    public void testRepeatedKey() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.object();
-        stringer.key("a").value(true);
-        stringer.key("a").value(false);
-        stringer.endObject();
-        // JSONStringer doesn't attempt to detect duplicates
-        assertEquals("{\"a\":true,\"a\":false}", stringer.toString());
+  }
+
+  @Test
+  public void testRepeatedKey() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.object();
+    stringer.key("a").value(true);
+    stringer.key("a").value(false);
+    stringer.endObject();
+    // JSONStringer doesn't attempt to detect duplicates
+    assertEquals("{\"a\":true,\"a\":false}", stringer.toString());
+  }
+
+  @Test
+  public void testEmptyKey() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.object();
+    stringer.key("").value(false);
+    stringer.endObject();
+    assertEquals("{\"\":false}", stringer.toString()); // legit behaviour!
+  }
+
+  @Test
+  public void testEscaping() throws JSONException {
+    assertEscapedAllWays("a", "a");
+    assertEscapedAllWays("a\\\"", "a\"");
+    assertEscapedAllWays("\\\"", "\"");
+    assertEscapedAllWays(":", ":");
+    assertEscapedAllWays(",", ",");
+    assertEscapedAllWays("\\b", "\b");
+    assertEscapedAllWays("\\f", "\f");
+    assertEscapedAllWays("\\n", "\n");
+    assertEscapedAllWays("\\r", "\r");
+    assertEscapedAllWays("\\t", "\t");
+    assertEscapedAllWays(" ", " ");
+    assertEscapedAllWays("\\\\", "\\");
+    assertEscapedAllWays("{", "{");
+    assertEscapedAllWays("}", "}");
+    assertEscapedAllWays("[", "[");
+    assertEscapedAllWays("]", "]");
+    assertEscapedAllWays("\\u0000", "\0");
+    assertEscapedAllWays("\\u0019", "\u0019");
+    assertEscapedAllWays(" ", "\u0020");
+    assertEscapedAllWays("<\\/foo>", "</foo>");
+  }
+
+  private void assertEscapedAllWays(String escaped, String original) throws JSONException {
+    assertEquals("{\"" + escaped + "\":false}",
+        new JSONStringer().object().key(original).value(false).endObject().toString());
+    assertEquals("{\"a\":\"" + escaped + "\"}",
+        new JSONStringer().object().key("a").value(original).endObject().toString());
+    assertEquals("[\"" + escaped + "\"]",
+        new JSONStringer().array().value(original).endArray().toString());
+    assertEquals("\"" + escaped + "\"", JSONObject.quote(original));
+  }
+
+  @Test
+  public void testJSONArrayAsValue() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put(false);
+    JSONStringer stringer = new JSONStringer();
+    stringer.array();
+    stringer.value(array);
+    stringer.endArray();
+    assertEquals("[[false]]", stringer.toString());
+  }
+
+  @Test
+  public void testJSONObjectAsValue() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("a", false);
+    JSONStringer stringer = new JSONStringer();
+    stringer.object();
+    stringer.key("b").value(object);
+    stringer.endObject();
+    assertEquals("{\"b\":{\"a\":false}}", stringer.toString());
+  }
+
+  @Test
+  public void testArrayNestingMaxDepthSupports20() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    for (int i = 0; i < 20; i++) {
+      stringer.array();
     }
-
-    @Test
-    public void testEmptyKey() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.object();
-        stringer.key("").value(false);
-        stringer.endObject();
-        assertEquals("{\"\":false}", stringer.toString()); // legit behaviour!
+    for (int i = 0; i < 20; i++) {
+      stringer.endArray();
     }
+    assertEquals("[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]", stringer.toString());
 
-    @Test
-    public void testEscaping() throws JSONException {
-        assertEscapedAllWays("a", "a");
-        assertEscapedAllWays("a\\\"", "a\"");
-        assertEscapedAllWays("\\\"", "\"");
-        assertEscapedAllWays(":", ":");
-        assertEscapedAllWays(",", ",");
-        assertEscapedAllWays("\\b", "\b");
-        assertEscapedAllWays("\\f", "\f");
-        assertEscapedAllWays("\\n", "\n");
-        assertEscapedAllWays("\\r", "\r");
-        assertEscapedAllWays("\\t", "\t");
-        assertEscapedAllWays(" ", " ");
-        assertEscapedAllWays("\\\\", "\\");
-        assertEscapedAllWays("{", "{");
-        assertEscapedAllWays("}", "}");
-        assertEscapedAllWays("[", "[");
-        assertEscapedAllWays("]", "]");
-        assertEscapedAllWays("\\u0000", "\0");
-        assertEscapedAllWays("\\u0019", "\u0019");
-        assertEscapedAllWays(" ", "\u0020");
-        assertEscapedAllWays("<\\/foo>", "</foo>");
+    stringer = new JSONStringer();
+    for (int i = 0; i < 20; i++) {
+      stringer.array();
     }
-
-    private void assertEscapedAllWays(String escaped, String original) throws JSONException {
-        assertEquals("{\"" + escaped + "\":false}",
-                new JSONStringer().object().key(original).value(false).endObject().toString());
-        assertEquals("{\"a\":\"" + escaped + "\"}",
-                new JSONStringer().object().key("a").value(original).endObject().toString());
-        assertEquals("[\"" + escaped + "\"]",
-                new JSONStringer().array().value(original).endArray().toString());
-        assertEquals("\"" + escaped + "\"", JSONObject.quote(original));
+  }
+
+  @Test
+  public void testObjectNestingMaxDepthSupports20() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    for (int i = 0; i < 20; i++) {
+      stringer.object();
+      stringer.key("a");
     }
-
-    @Test
-    public void testJSONArrayAsValue() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put(false);
-        JSONStringer stringer = new JSONStringer();
-        stringer.array();
-        stringer.value(array);
-        stringer.endArray();
-        assertEquals("[[false]]", stringer.toString());
+    stringer.value(false);
+    for (int i = 0; i < 20; i++) {
+      stringer.endObject();
     }
-
-    @Test
-    public void testJSONObjectAsValue() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("a", false);
-        JSONStringer stringer = new JSONStringer();
-        stringer.object();
-        stringer.key("b").value(object);
-        stringer.endObject();
-        assertEquals("{\"b\":{\"a\":false}}", stringer.toString());
+    assertEquals("{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":"
+        + "{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":false"
+        + "}}}}}}}}}}}}}}}}}}}}", stringer.toString());
+
+    stringer = new JSONStringer();
+    for (int i = 0; i < 20; i++) {
+      stringer.object();
+      stringer.key("a");
     }
-
-    @Test
-    public void testArrayNestingMaxDepthSupports20() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        for (int i = 0; i < 20; i++) {
-            stringer.array();
-        }
-        for (int i = 0; i < 20; i++) {
-            stringer.endArray();
-        }
-        assertEquals("[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]", stringer.toString());
-
-        stringer = new JSONStringer();
-        for (int i = 0; i < 20; i++) {
-            stringer.array();
-        }
+  }
+
+  @Test
+  public void testMixedMaxDepthSupports20() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    for (int i = 0; i < 20; i += 2) {
+      stringer.array();
+      stringer.object();
+      stringer.key("a");
     }
-
-    @Test
-    public void testObjectNestingMaxDepthSupports20() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        for (int i = 0; i < 20; i++) {
-            stringer.object();
-            stringer.key("a");
-        }
-        stringer.value(false);
-        for (int i = 0; i < 20; i++) {
-            stringer.endObject();
-        }
-        assertEquals("{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":" +
-                "{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":false" +
-                "}}}}}}}}}}}}}}}}}}}}", stringer.toString());
-
-        stringer = new JSONStringer();
-        for (int i = 0; i < 20; i++) {
-            stringer.object();
-            stringer.key("a");
-        }
+    stringer.value(false);
+    for (int i = 0; i < 20; i += 2) {
+      stringer.endObject();
+      stringer.endArray();
     }
-
-    @Test
-    public void testMixedMaxDepthSupports20() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        for (int i = 0; i < 20; i += 2) {
-            stringer.array();
-            stringer.object();
-            stringer.key("a");
-        }
-        stringer.value(false);
-        for (int i = 0; i < 20; i += 2) {
-            stringer.endObject();
-            stringer.endArray();
-        }
-        assertEquals("[{\"a\":[{\"a\":[{\"a\":[{\"a\":[{\"a\":" +
-                "[{\"a\":[{\"a\":[{\"a\":[{\"a\":[{\"a\":false" +
-                "}]}]}]}]}]}]}]}]}]}]", stringer.toString());
-
-        stringer = new JSONStringer();
-        for (int i = 0; i < 20; i += 2) {
-            stringer.array();
-            stringer.object();
-            stringer.key("a");
-        }
+    assertEquals("[{\"a\":[{\"a\":[{\"a\":[{\"a\":[{\"a\":"
+        + "[{\"a\":[{\"a\":[{\"a\":[{\"a\":[{\"a\":false" + "}]}]}]}]}]}]}]}]}]}]",
+        stringer.toString());
+
+    stringer = new JSONStringer();
+    for (int i = 0; i < 20; i += 2) {
+      stringer.array();
+      stringer.object();
+      stringer.key("a");
     }
+  }
 
-    @Test
-    public void testMaxDepthWithArrayValue() throws JSONException {
-        JSONArray array = new JSONArray();
-        array.put(false);
-
-        JSONStringer stringer = new JSONStringer();
-        for (int i = 0; i < 20; i++) {
-            stringer.array();
-        }
-        stringer.value(array);
-        for (int i = 0; i < 20; i++) {
-            stringer.endArray();
-        }
-        assertEquals("[[[[[[[[[[[[[[[[[[[[[false]]]]]]]]]]]]]]]]]]]]]", stringer.toString());
-    }
+  @Test
+  public void testMaxDepthWithArrayValue() throws JSONException {
+    JSONArray array = new JSONArray();
+    array.put(false);
 
-    @Test
-    public void testMaxDepthWithObjectValue() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("a", false);
-        JSONStringer stringer = new JSONStringer();
-        for (int i = 0; i < 20; i++) {
-            stringer.object();
-            stringer.key("b");
-        }
-        stringer.value(object);
-        for (int i = 0; i < 20; i++) {
-            stringer.endObject();
-        }
-        assertEquals("{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":" +
-                "{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":" +
-                "{\"a\":false}}}}}}}}}}}}}}}}}}}}}", stringer.toString());
+    JSONStringer stringer = new JSONStringer();
+    for (int i = 0; i < 20; i++) {
+      stringer.array();
     }
-
-    @Test
-    public void testMultipleRoots() throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.array();
-        stringer.endArray();
-        try {
-            stringer.object();
-            fail();
-        } catch (JSONException ignored) {
-        }
+    stringer.value(array);
+    for (int i = 0; i < 20; i++) {
+      stringer.endArray();
     }
-
-    @Test
-    public void testEnums() {
-        JSONObject x = new JSONObject();
-        x.put("a", TimeUnit.SECONDS);
-        x.put("b", "xyx");
-        JSONStringer s = new JSONStringer();
-        s.array();
-        s.value(x);
-        s.endArray();
-        assertEquals("[{\"a\":\"SECONDS\",\"b\":\"xyx\"}]", s.toString());
+    assertEquals("[[[[[[[[[[[[[[[[[[[[[false]]]]]]]]]]]]]]]]]]]]]", stringer.toString());
+  }
+
+  @Test
+  public void testMaxDepthWithObjectValue() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("a", false);
+    JSONStringer stringer = new JSONStringer();
+    for (int i = 0; i < 20; i++) {
+      stringer.object();
+      stringer.key("b");
     }
-
-    @Test
-    public void testJsonString() {
-        JSONObject x = new JSONObject();
-        x.put("a", new Goo());
-        JSONStringer s = new JSONStringer();
-        s.array();
-        s.value(x);
-        s.endArray();
-        // note lack of quotes
-        assertEquals("[{\"a\":fffooo}]", s.toString());
+    stringer.value(object);
+    for (int i = 0; i < 20; i++) {
+      stringer.endObject();
     }
-
-    private static class Goo implements JSONString {
-        @Override
-        public String toJSONString() {
-            return "fffooo";
-        }
+    assertEquals("{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":"
+        + "{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":"
+        + "{\"a\":false}}}}}}}}}}}}}}}}}}}}}", stringer.toString());
+  }
+
+  @Test
+  public void testMultipleRoots() throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.array();
+    stringer.endArray();
+    try {
+      stringer.object();
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testEnums() {
+    JSONObject x = new JSONObject();
+    x.put("a", TimeUnit.SECONDS);
+    x.put("b", "xyx");
+    JSONStringer s = new JSONStringer();
+    s.array();
+    s.value(x);
+    s.endArray();
+    assertEquals("[{\"a\":\"SECONDS\",\"b\":\"xyx\"}]", s.toString());
+  }
+
+  @Test
+  public void testJsonString() {
+    JSONObject x = new JSONObject();
+    x.put("a", new Goo());
+    JSONStringer s = new JSONStringer();
+    s.array();
+    s.value(x);
+    s.endArray();
+    // note lack of quotes
+    assertEquals("[{\"a\":fffooo}]", s.toString());
+  }
+
+  private static class Goo implements JSONString {
+    @Override
+    public String toJSONString() {
+      return "fffooo";
     }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/test/java/org/json/JSONTokenerTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONTokenerTest.java b/geode-json/src/test/java/org/json/JSONTokenerTest.java
index 9975177..f68b3ce 100755
--- a/geode-json/src/test/java/org/json/JSONTokenerTest.java
+++ b/geode-json/src/test/java/org/json/JSONTokenerTest.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -24,598 +22,595 @@ import junit.framework.TestCase;
  */
 public class JSONTokenerTest extends TestCase {
 
-    public void testNulls() throws JSONException {
-        // JSONTokener accepts null, only to fail later on almost all APIs!
-        new JSONTokener((String) null).back();
-
-        try {
-            new JSONTokener((String) null).more();
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).next();
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).next(3);
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).next('A');
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).nextClean();
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).nextString('"');
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).nextTo('A');
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).nextTo("ABC");
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).nextValue();
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).skipPast("ABC");
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        try {
-            new JSONTokener((String) null).skipTo('A');
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-
-        //noinspection ThrowableResultOfMethodCallIgnored
-        assertEquals("foo! at character 0 of null",
-                new JSONTokener((String) null).syntaxError("foo!").getMessage());
-
-        assertEquals(" at character 0 of null", new JSONTokener((String) null).toString());
-    }
-
-    public void testEmptyString() throws JSONException {
-        JSONTokener backTokener = new JSONTokener("");
-        backTokener.back();
-        assertEquals(" at character 0 of ", backTokener.toString());
-        assertFalse(new JSONTokener("").more());
-        assertEquals('\0', new JSONTokener("").next());
-        try {
-            new JSONTokener("").next(3);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONTokener("").next('A');
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals('\0', new JSONTokener("").nextClean());
-        try {
-            new JSONTokener("").nextString('"');
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals("", new JSONTokener("").nextTo('A'));
-        assertEquals("", new JSONTokener("").nextTo("ABC"));
-        try {
-            new JSONTokener("").nextValue();
-            fail();
-        } catch (JSONException ignored) {
-        }
-        new JSONTokener("").skipPast("ABC");
-        assertEquals('\0', new JSONTokener("").skipTo('A'));
-        //noinspection ThrowableResultOfMethodCallIgnored
-        assertEquals("foo! at character 0 of ",
-                new JSONTokener("").syntaxError("foo!").getMessage());
-        assertEquals(" at character 0 of ", new JSONTokener("").toString());
-    }
-
-    public void testCharacterNavigation() throws JSONException {
-        JSONTokener abcdeTokener = new JSONTokener("ABCDE");
-        assertEquals('A', abcdeTokener.next());
-        assertEquals('B', abcdeTokener.next('B'));
-        assertEquals("CD", abcdeTokener.next(2));
-        try {
-            abcdeTokener.next(2);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals('E', abcdeTokener.nextClean());
-        assertEquals('\0', abcdeTokener.next());
-        assertFalse(abcdeTokener.more());
-        abcdeTokener.back();
-        assertTrue(abcdeTokener.more());
-        assertEquals('E', abcdeTokener.next());
-    }
-
-    public void testBackNextAndMore() throws JSONException {
-        JSONTokener abcTokener = new JSONTokener("ABC");
-        assertTrue(abcTokener.more());
-        abcTokener.next();
-        abcTokener.next();
-        assertTrue(abcTokener.more());
-        abcTokener.next();
-        assertFalse(abcTokener.more());
-        abcTokener.back();
-        assertTrue(abcTokener.more());
-        abcTokener.next();
-        assertFalse(abcTokener.more());
-        abcTokener.back();
-        abcTokener.back();
-        abcTokener.back();
-        abcTokener.back(); // you can back up before the beginning of a String!
-        assertEquals('A', abcTokener.next());
-    }
-
-    public void testNextMatching() throws JSONException {
-        JSONTokener abcdTokener = new JSONTokener("ABCD");
-        assertEquals('A', abcdTokener.next('A'));
-        try {
-            abcdTokener.next('C'); // although it failed, this op consumes a character of input
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals('C', abcdTokener.next('C'));
-        assertEquals('D', abcdTokener.next('D'));
-        try {
-            abcdTokener.next('E');
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    public void testNextN() throws JSONException {
-        JSONTokener abcdeTokener = new JSONTokener("ABCDEF");
-        assertEquals("", abcdeTokener.next(0));
-        try {
-            abcdeTokener.next(7);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals("ABC", abcdeTokener.next(3));
-        try {
-            abcdeTokener.next(4);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    public void testNextNWithAllRemaining() throws JSONException {
-        JSONTokener tokener = new JSONTokener("ABCDEF");
-        tokener.next(3);
-        try {
-            tokener.next(3);
-        } catch (JSONException e) {
-            AssertionFailedError error = new AssertionFailedError("off-by-one error?");
-            error.initCause(e);
-            throw error;
-        }
-    }
-
-    public void testNext0() throws JSONException {
-        JSONTokener tokener = new JSONTokener("ABCDEF");
-        tokener.next(5);
-        tokener.next();
-        try {
-            tokener.next(0);
-        } catch (JSONException e) {
-            Error error = new AssertionFailedError("Returning an empty string should be valid");
-            error.initCause(e);
-            throw error;
-        }
-    }
-
-    public void testNextCleanComments() throws JSONException {
-        JSONTokener tokener = new JSONTokener(
-                "  A  /*XX*/B/*XX//XX\n//XX\nXX*/C//X//X//X\nD/*X*///X\n");
-        assertEquals('A', tokener.nextClean());
-        assertEquals('B', tokener.nextClean());
-        assertEquals('C', tokener.nextClean());
-        assertEquals('D', tokener.nextClean());
-        assertEquals('\0', tokener.nextClean());
-    }
-
-    public void testNextCleanNestedCStyleComments() throws JSONException {
-        JSONTokener tokener = new JSONTokener("A /* B /* C */ D */ E");
-        assertEquals('A', tokener.nextClean());
-        assertEquals('D', tokener.nextClean());
-        assertEquals('*', tokener.nextClean());
-        assertEquals('/', tokener.nextClean());
-        assertEquals('E', tokener.nextClean());
-    }
-
-    /**
-     * Some applications rely on parsing '#' to lead an end-of-line comment.
-     * http://b/2571423
-     */
-    public void testNextCleanHashComments() throws JSONException {
-        JSONTokener tokener = new JSONTokener("A # B */ /* C */ \nD #");
-        assertEquals('A', tokener.nextClean());
-        assertEquals('D', tokener.nextClean());
-        assertEquals('\0', tokener.nextClean());
-    }
-
-    public void testNextCleanCommentsTrailingSingleSlash() throws JSONException {
-        JSONTokener tokener = new JSONTokener(" / S /");
-        assertEquals('/', tokener.nextClean());
-        assertEquals('S', tokener.nextClean());
-        assertEquals('/', tokener.nextClean());
-        assertEquals("nextClean doesn't consume a trailing slash",
-                '\0', tokener.nextClean());
-    }
-
-    public void testNextCleanTrailingOpenComment() throws JSONException {
-        try {
-            new JSONTokener("  /* ").nextClean();
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals('\0', new JSONTokener("  // ").nextClean());
-    }
-
-    public void testNextCleanNewlineDelimiters() throws JSONException {
-        assertEquals('B', new JSONTokener("  // \r\n  B ").nextClean());
-        assertEquals('B', new JSONTokener("  // \n  B ").nextClean());
-        assertEquals('B', new JSONTokener("  // \r  B ").nextClean());
-    }
-
-    public void testNextCleanSkippedWhitespace() throws JSONException {
-        assertEquals("character tabulation", 'A', new JSONTokener("\tA").nextClean());
-        assertEquals("line feed",            'A', new JSONTokener("\nA").nextClean());
-        assertEquals("carriage return",      'A', new JSONTokener("\rA").nextClean());
-        assertEquals("space",                'A', new JSONTokener(" A").nextClean());
-    }
-
-    /**
-     * Tests which characters tokener treats as ignorable whitespace. See Kevin Bourrillion's
-     * <a href="https://spreadsheets.google.com/pub?key=pd8dAQyHbdewRsnE5x5GzKQ">list
-     * of whitespace characters</a>.
-     */
-    public void testNextCleanRetainedWhitespace() throws JSONException {
-        assertNotClean("null",                      '\u0000');
-        assertNotClean("next line",                 '\u0085');
-        assertNotClean("non-breaking space",        '\u00a0');
-        assertNotClean("ogham space mark",          '\u1680');
-        assertNotClean("mongolian vowel separator", '\u180e');
-        assertNotClean("en quad",                   '\u2000');
-        assertNotClean("em quad",                   '\u2001');
-        assertNotClean("en space",                  '\u2002');
-        assertNotClean("em space",                  '\u2003');
-        assertNotClean("three-per-em space",        '\u2004');
-        assertNotClean("four-per-em space",         '\u2005');
-        assertNotClean("six-per-em space",          '\u2006');
-        assertNotClean("figure space",              '\u2007');
-        assertNotClean("punctuation space",         '\u2008');
-        assertNotClean("thin space",                '\u2009');
-        assertNotClean("hair space",                '\u200a');
-        assertNotClean("zero-width space",          '\u200b');
-        assertNotClean("left-to-right mark",        '\u200e');
-        assertNotClean("right-to-left mark",        '\u200f');
-        assertNotClean("line separator",            '\u2028');
-        assertNotClean("paragraph separator",       '\u2029');
-        assertNotClean("narrow non-breaking space", '\u202f');
-        assertNotClean("medium mathematical space", '\u205f');
-        assertNotClean("ideographic space",         '\u3000');
-        assertNotClean("line tabulation",           '\u000b');
-        assertNotClean("form feed",                 '\u000c');
-        assertNotClean("information separator 4",   '\u001c');
-        assertNotClean("information separator 3",   '\u001d');
-        assertNotClean("information separator 2",   '\u001e');
-        assertNotClean("information separator 1",   '\u001f');
-    }
-
-    private void assertNotClean(String name, char c) throws JSONException {
-        assertEquals("The character " + name + " is not whitespace according to the JSON spec.",
-                c, new JSONTokener(new String(new char[] { c, 'A' })).nextClean());
-    }
-
-    public void testNextString() throws JSONException {
-        assertEquals("", new JSONTokener("'").nextString('\''));
-        assertEquals("", new JSONTokener("\"").nextString('\"'));
-        assertEquals("ABC", new JSONTokener("ABC'DEF").nextString('\''));
-        assertEquals("ABC", new JSONTokener("ABC'''DEF").nextString('\''));
-
-        // nextString permits slash-escaping of arbitrary characters!
-        assertEquals("ABC", new JSONTokener("A\\B\\C'DEF").nextString('\''));
-
-        JSONTokener tokener = new JSONTokener(" 'abc' 'def' \"ghi\"");
-        tokener.next();
-        assertEquals('\'', tokener.next());
-        assertEquals("abc", tokener.nextString('\''));
-        tokener.next();
-        assertEquals('\'', tokener.next());
-        assertEquals("def", tokener.nextString('\''));
-        tokener.next();
-        assertEquals('"', tokener.next());
-        assertEquals("ghi", tokener.nextString('\"'));
-        assertFalse(tokener.more());
-    }
-
-    public void testNextStringNoDelimiter() throws JSONException {
-        try {
-            new JSONTokener("").nextString('\'');
-            fail();
-        } catch (JSONException ignored) {
-        }
-
-        JSONTokener tokener = new JSONTokener(" 'abc");
-        tokener.next();
-        tokener.next();
-        try {
-            tokener.next('\'');
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    public void testNextStringEscapedQuote() throws JSONException {
-        try {
-            new JSONTokener("abc\\").nextString('"');
-            fail();
-        } catch (JSONException ignored) {
-        }
-
-        // we're mixing Java escaping like \" and JavaScript escaping like \\\"
-        // which makes these tests extra tricky to read!
-        assertEquals("abc\"def", new JSONTokener("abc\\\"def\"ghi").nextString('"'));
-        assertEquals("abc\\def", new JSONTokener("abc\\\\def\"ghi").nextString('"'));
-        assertEquals("abc/def", new JSONTokener("abc\\/def\"ghi").nextString('"'));
-        assertEquals("abc\bdef", new JSONTokener("abc\\bdef\"ghi").nextString('"'));
-        assertEquals("abc\fdef", new JSONTokener("abc\\fdef\"ghi").nextString('"'));
-        assertEquals("abc\ndef", new JSONTokener("abc\\ndef\"ghi").nextString('"'));
-        assertEquals("abc\rdef", new JSONTokener("abc\\rdef\"ghi").nextString('"'));
-        assertEquals("abc\tdef", new JSONTokener("abc\\tdef\"ghi").nextString('"'));
-    }
-
-    public void testNextStringUnicodeEscaped() throws JSONException {
-        // we're mixing Java escaping like \\ and JavaScript escaping like \\u
-        assertEquals("abc def", new JSONTokener("abc\\u0020def\"ghi").nextString('"'));
-        assertEquals("abcU0020def", new JSONTokener("abc\\U0020def\"ghi").nextString('"'));
-
-        // JSON requires 4 hex characters after a unicode escape
-        try {
-            new JSONTokener("abc\\u002\"").nextString('"');
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONTokener("abc\\u").nextString('"');
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONTokener("abc\\u    \"").nextString('"');
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals("abc\"def", new JSONTokener("abc\\u0022def\"ghi").nextString('"'));
-        try {
-            new JSONTokener("abc\\u000G\"").nextString('"');
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    public void testNextStringNonQuote() throws JSONException {
-        assertEquals("AB", new JSONTokener("ABC").nextString('C'));
-        assertEquals("ABCD", new JSONTokener("AB\\CDC").nextString('C'));
-        assertEquals("AB\nC", new JSONTokener("AB\\nCn").nextString('n'));
-    }
-
-    public void testNextTo() throws JSONException {
-        assertEquals("ABC", new JSONTokener("ABCDEFG").nextTo("DHI"));
-        assertEquals("ABCDEF", new JSONTokener("ABCDEF").nextTo(""));
-
-        JSONTokener tokener = new JSONTokener("ABC\rDEF\nGHI\r\nJKL");
-        assertEquals("ABC", tokener.nextTo("M"));
-        assertEquals('\r', tokener.next());
-        assertEquals("DEF", tokener.nextTo("M"));
-        assertEquals('\n', tokener.next());
-        assertEquals("GHI", tokener.nextTo("M"));
-        assertEquals('\r', tokener.next());
-        assertEquals('\n', tokener.next());
-        assertEquals("JKL", tokener.nextTo("M"));
-
-        tokener = new JSONTokener("ABCDEFGHI");
-        assertEquals("ABC", tokener.nextTo("DEF"));
-        assertEquals("", tokener.nextTo("DEF"));
-        assertEquals('D', tokener.next());
-        assertEquals("", tokener.nextTo("DEF"));
-        assertEquals('E', tokener.next());
-        assertEquals("", tokener.nextTo("DEF"));
-        assertEquals('F', tokener.next());
-        assertEquals("GHI", tokener.nextTo("DEF"));
-        assertEquals("", tokener.nextTo("DEF"));
-
-        tokener = new JSONTokener(" \t \fABC \t DEF");
-        assertEquals("ABC", tokener.nextTo("DEF"));
-        assertEquals('D', tokener.next());
-
-        tokener = new JSONTokener(" \t \fABC \n DEF");
-        assertEquals("ABC", tokener.nextTo("\n"));
-        assertEquals("", tokener.nextTo("\n"));
-
-        tokener = new JSONTokener("");
-        try {
-            tokener.nextTo(null);
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-    }
-
-    public void testNextToTrimming() {
-        assertEquals("ABC", new JSONTokener("\t ABC \tDEF").nextTo("DE"));
-        assertEquals("ABC", new JSONTokener("\t ABC \tDEF").nextTo('D'));
-    }
-
-    public void testNextToTrailing() {
-        assertEquals("ABC DEF", new JSONTokener("\t ABC DEF \t").nextTo("G"));
-        assertEquals("ABC DEF", new JSONTokener("\t ABC DEF \t").nextTo('G'));
-    }
-
-    public void testNextToDoesntStopOnNull() {
-        String message = "nextTo() shouldn't stop after \\0 characters";
-        JSONTokener tokener = new JSONTokener(" \0\t \fABC \n DEF");
-        assertEquals(message, "ABC", tokener.nextTo("D"));
-        assertEquals(message, '\n', tokener.next());
-        assertEquals(message, "", tokener.nextTo("D"));
-    }
-
-    public void testNextToConsumesNull() {
-        String message = "nextTo shouldn't consume \\0.";
-        JSONTokener tokener = new JSONTokener("ABC\0DEF");
-        assertEquals(message, "ABC", tokener.nextTo("\0"));
-        assertEquals(message, '\0', tokener.next());
-        assertEquals(message, "DEF", tokener.nextTo("\0"));
-    }
-
-    public void testSkipPast() {
-        JSONTokener tokener = new JSONTokener("ABCDEF");
-        tokener.skipPast("ABC");
-        assertEquals('D', tokener.next());
-        tokener.skipPast("EF");
-        assertEquals('\0', tokener.next());
-
-        tokener = new JSONTokener("ABCDEF");
-        tokener.skipPast("ABCDEF");
-        assertEquals('\0', tokener.next());
-
-        tokener = new JSONTokener("ABCDEF");
-        tokener.skipPast("G");
-        assertEquals('\0', tokener.next());
-
-        tokener = new JSONTokener("ABC\0ABC");
-        tokener.skipPast("ABC");
-        assertEquals('\0', tokener.next());
-        assertEquals('A', tokener.next());
-
-        tokener = new JSONTokener("\0ABC");
-        tokener.skipPast("ABC");
-        assertEquals('\0', tokener.next());
-
-        tokener = new JSONTokener("ABC\nDEF");
-        tokener.skipPast("DEF");
-        assertEquals('\0', tokener.next());
-
-        tokener = new JSONTokener("ABC");
-        tokener.skipPast("ABCDEF");
-        assertEquals('\0', tokener.next());
-
-        tokener = new JSONTokener("ABCDABCDABCD");
-        tokener.skipPast("ABC");
-        assertEquals('D', tokener.next());
-        tokener.skipPast("ABC");
-        assertEquals('D', tokener.next());
-        tokener.skipPast("ABC");
-        assertEquals('D', tokener.next());
-
-        tokener = new JSONTokener("");
-        try {
-            tokener.skipPast(null);
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-    }
-
-    public void testSkipTo() {
-        JSONTokener tokener = new JSONTokener("ABCDEF");
-        tokener.skipTo('A');
-        assertEquals('A', tokener.next());
-        tokener.skipTo('D');
-        assertEquals('D', tokener.next());
-        tokener.skipTo('G');
-        assertEquals('E', tokener.next());
-        tokener.skipTo('A');
-        assertEquals('F', tokener.next());
-
-        tokener = new JSONTokener("ABC\nDEF");
-        tokener.skipTo('F');
-        assertEquals('F', tokener.next());
-
-        tokener = new JSONTokener("ABCfDEF");
-        tokener.skipTo('F');
-        assertEquals('F', tokener.next());
-
-        tokener = new JSONTokener("ABC/* DEF */");
-        tokener.skipTo('D');
-        assertEquals('D', tokener.next());
-    }
-
-    public void testSkipToStopsOnNull() {
-        JSONTokener tokener = new JSONTokener("ABC\0DEF");
-        tokener.skipTo('F');
-        assertEquals("skipTo shouldn't stop when it sees '\\0'", 'F', tokener.next());
-    }
-
-    public void testBomIgnoredAsFirstCharacterOfDocument() throws JSONException {
-        JSONTokener tokener = new JSONTokener("\ufeff[]");
-        JSONArray array = (JSONArray) tokener.nextValue();
-        assertEquals(0, array.length());
-    }
-
-    public void testBomTreatedAsCharacterInRestOfDocument() throws JSONException {
-        JSONTokener tokener = new JSONTokener("[\ufeff]");
-        JSONArray array = (JSONArray) tokener.nextValue();
-        assertEquals(1, array.length());
-    }
-
-    public void testDehexchar() {
-        assertEquals( 0, JSONTokener.dehexchar('0'));
-        assertEquals( 1, JSONTokener.dehexchar('1'));
-        assertEquals( 2, JSONTokener.dehexchar('2'));
-        assertEquals( 3, JSONTokener.dehexchar('3'));
-        assertEquals( 4, JSONTokener.dehexchar('4'));
-        assertEquals( 5, JSONTokener.dehexchar('5'));
-        assertEquals( 6, JSONTokener.dehexchar('6'));
-        assertEquals( 7, JSONTokener.dehexchar('7'));
-        assertEquals( 8, JSONTokener.dehexchar('8'));
-        assertEquals( 9, JSONTokener.dehexchar('9'));
-        assertEquals(10, JSONTokener.dehexchar('A'));
-        assertEquals(11, JSONTokener.dehexchar('B'));
-        assertEquals(12, JSONTokener.dehexchar('C'));
-        assertEquals(13, JSONTokener.dehexchar('D'));
-        assertEquals(14, JSONTokener.dehexchar('E'));
-        assertEquals(15, JSONTokener.dehexchar('F'));
-        assertEquals(10, JSONTokener.dehexchar('a'));
-        assertEquals(11, JSONTokener.dehexchar('b'));
-        assertEquals(12, JSONTokener.dehexchar('c'));
-        assertEquals(13, JSONTokener.dehexchar('d'));
-        assertEquals(14, JSONTokener.dehexchar('e'));
-        assertEquals(15, JSONTokener.dehexchar('f'));
-
-        for (int c = 0; c <= 0xFFFF; c++) {
-            if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) {
-                continue;
-            }
-            assertEquals("dehexchar " + c, -1, JSONTokener.dehexchar((char) c));
-        }
+  public void testNulls() throws JSONException {
+    // JSONTokener accepts null, only to fail later on almost all APIs!
+    new JSONTokener((String) null).back();
+
+    try {
+      new JSONTokener((String) null).more();
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).next();
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).next(3);
+      fail();
+    } catch (NullPointerException ignored) {
     }
+
+    try {
+      new JSONTokener((String) null).next('A');
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).nextClean();
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).nextString('"');
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).nextTo('A');
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).nextTo("ABC");
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).nextValue();
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).skipPast("ABC");
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    try {
+      new JSONTokener((String) null).skipTo('A');
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+
+    // noinspection ThrowableResultOfMethodCallIgnored
+    assertEquals("foo! at character 0 of null",
+        new JSONTokener((String) null).syntaxError("foo!").getMessage());
+
+    assertEquals(" at character 0 of null", new JSONTokener((String) null).toString());
+  }
+
+  public void testEmptyString() throws JSONException {
+    JSONTokener backTokener = new JSONTokener("");
+    backTokener.back();
+    assertEquals(" at character 0 of ", backTokener.toString());
+    assertFalse(new JSONTokener("").more());
+    assertEquals('\0', new JSONTokener("").next());
+    try {
+      new JSONTokener("").next(3);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      new JSONTokener("").next('A');
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals('\0', new JSONTokener("").nextClean());
+    try {
+      new JSONTokener("").nextString('"');
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals("", new JSONTokener("").nextTo('A'));
+    assertEquals("", new JSONTokener("").nextTo("ABC"));
+    try {
+      new JSONTokener("").nextValue();
+      fail();
+    } catch (JSONException ignored) {
+    }
+    new JSONTokener("").skipPast("ABC");
+    assertEquals('\0', new JSONTokener("").skipTo('A'));
+    // noinspection ThrowableResultOfMethodCallIgnored
+    assertEquals("foo! at character 0 of ", new JSONTokener("").syntaxError("foo!").getMessage());
+    assertEquals(" at character 0 of ", new JSONTokener("").toString());
+  }
+
+  public void testCharacterNavigation() throws JSONException {
+    JSONTokener abcdeTokener = new JSONTokener("ABCDE");
+    assertEquals('A', abcdeTokener.next());
+    assertEquals('B', abcdeTokener.next('B'));
+    assertEquals("CD", abcdeTokener.next(2));
+    try {
+      abcdeTokener.next(2);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals('E', abcdeTokener.nextClean());
+    assertEquals('\0', abcdeTokener.next());
+    assertFalse(abcdeTokener.more());
+    abcdeTokener.back();
+    assertTrue(abcdeTokener.more());
+    assertEquals('E', abcdeTokener.next());
+  }
+
+  public void testBackNextAndMore() throws JSONException {
+    JSONTokener abcTokener = new JSONTokener("ABC");
+    assertTrue(abcTokener.more());
+    abcTokener.next();
+    abcTokener.next();
+    assertTrue(abcTokener.more());
+    abcTokener.next();
+    assertFalse(abcTokener.more());
+    abcTokener.back();
+    assertTrue(abcTokener.more());
+    abcTokener.next();
+    assertFalse(abcTokener.more());
+    abcTokener.back();
+    abcTokener.back();
+    abcTokener.back();
+    abcTokener.back(); // you can back up before the beginning of a String!
+    assertEquals('A', abcTokener.next());
+  }
+
+  public void testNextMatching() throws JSONException {
+    JSONTokener abcdTokener = new JSONTokener("ABCD");
+    assertEquals('A', abcdTokener.next('A'));
+    try {
+      abcdTokener.next('C'); // although it failed, this op consumes a character of input
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals('C', abcdTokener.next('C'));
+    assertEquals('D', abcdTokener.next('D'));
+    try {
+      abcdTokener.next('E');
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  public void testNextN() throws JSONException {
+    JSONTokener abcdeTokener = new JSONTokener("ABCDEF");
+    assertEquals("", abcdeTokener.next(0));
+    try {
+      abcdeTokener.next(7);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals("ABC", abcdeTokener.next(3));
+    try {
+      abcdeTokener.next(4);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  public void testNextNWithAllRemaining() throws JSONException {
+    JSONTokener tokener = new JSONTokener("ABCDEF");
+    tokener.next(3);
+    try {
+      tokener.next(3);
+    } catch (JSONException e) {
+      AssertionFailedError error = new AssertionFailedError("off-by-one error?");
+      error.initCause(e);
+      throw error;
+    }
+  }
+
+  public void testNext0() throws JSONException {
+    JSONTokener tokener = new JSONTokener("ABCDEF");
+    tokener.next(5);
+    tokener.next();
+    try {
+      tokener.next(0);
+    } catch (JSONException e) {
+      Error error = new AssertionFailedError("Returning an empty string should be valid");
+      error.initCause(e);
+      throw error;
+    }
+  }
+
+  public void testNextCleanComments() throws JSONException {
+    JSONTokener tokener =
+        new JSONTokener("  A  /*XX*/B/*XX//XX\n//XX\nXX*/C//X//X//X\nD/*X*///X\n");
+    assertEquals('A', tokener.nextClean());
+    assertEquals('B', tokener.nextClean());
+    assertEquals('C', tokener.nextClean());
+    assertEquals('D', tokener.nextClean());
+    assertEquals('\0', tokener.nextClean());
+  }
+
+  public void testNextCleanNestedCStyleComments() throws JSONException {
+    JSONTokener tokener = new JSONTokener("A /* B /* C */ D */ E");
+    assertEquals('A', tokener.nextClean());
+    assertEquals('D', tokener.nextClean());
+    assertEquals('*', tokener.nextClean());
+    assertEquals('/', tokener.nextClean());
+    assertEquals('E', tokener.nextClean());
+  }
+
+  /**
+   * Some applications rely on parsing '#' to lead an end-of-line comment. http://b/2571423
+   */
+  public void testNextCleanHashComments() throws JSONException {
+    JSONTokener tokener = new JSONTokener("A # B */ /* C */ \nD #");
+    assertEquals('A', tokener.nextClean());
+    assertEquals('D', tokener.nextClean());
+    assertEquals('\0', tokener.nextClean());
+  }
+
+  public void testNextCleanCommentsTrailingSingleSlash() throws JSONException {
+    JSONTokener tokener = new JSONTokener(" / S /");
+    assertEquals('/', tokener.nextClean());
+    assertEquals('S', tokener.nextClean());
+    assertEquals('/', tokener.nextClean());
+    assertEquals("nextClean doesn't consume a trailing slash", '\0', tokener.nextClean());
+  }
+
+  public void testNextCleanTrailingOpenComment() throws JSONException {
+    try {
+      new JSONTokener("  /* ").nextClean();
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals('\0', new JSONTokener("  // ").nextClean());
+  }
+
+  public void testNextCleanNewlineDelimiters() throws JSONException {
+    assertEquals('B', new JSONTokener("  // \r\n  B ").nextClean());
+    assertEquals('B', new JSONTokener("  // \n  B ").nextClean());
+    assertEquals('B', new JSONTokener("  // \r  B ").nextClean());
+  }
+
+  public void testNextCleanSkippedWhitespace() throws JSONException {
+    assertEquals("character tabulation", 'A', new JSONTokener("\tA").nextClean());
+    assertEquals("line feed", 'A', new JSONTokener("\nA").nextClean());
+    assertEquals("carriage return", 'A', new JSONTokener("\rA").nextClean());
+    assertEquals("space", 'A', new JSONTokener(" A").nextClean());
+  }
+
+  /**
+   * Tests which characters tokener treats as ignorable whitespace. See Kevin Bourrillion's
+   * <a href="https://spreadsheets.google.com/pub?key=pd8dAQyHbdewRsnE5x5GzKQ">list of whitespace
+   * characters</a>.
+   */
+  public void testNextCleanRetainedWhitespace() throws JSONException {
+    assertNotClean("null", '\u0000');
+    assertNotClean("next line", '\u0085');
+    assertNotClean("non-breaking space", '\u00a0');
+    assertNotClean("ogham space mark", '\u1680');
+    assertNotClean("mongolian vowel separator", '\u180e');
+    assertNotClean("en quad", '\u2000');
+    assertNotClean("em quad", '\u2001');
+    assertNotClean("en space", '\u2002');
+    assertNotClean("em space", '\u2003');
+    assertNotClean("three-per-em space", '\u2004');
+    assertNotClean("four-per-em space", '\u2005');
+    assertNotClean("six-per-em space", '\u2006');
+    assertNotClean("figure space", '\u2007');
+    assertNotClean("punctuation space", '\u2008');
+    assertNotClean("thin space", '\u2009');
+    assertNotClean("hair space", '\u200a');
+    assertNotClean("zero-width space", '\u200b');
+    assertNotClean("left-to-right mark", '\u200e');
+    assertNotClean("right-to-left mark", '\u200f');
+    assertNotClean("line separator", '\u2028');
+    assertNotClean("paragraph separator", '\u2029');
+    assertNotClean("narrow non-breaking space", '\u202f');
+    assertNotClean("medium mathematical space", '\u205f');
+    assertNotClean("ideographic space", '\u3000');
+    assertNotClean("line tabulation", '\u000b');
+    assertNotClean("form feed", '\u000c');
+    assertNotClean("information separator 4", '\u001c');
+    assertNotClean("information separator 3", '\u001d');
+    assertNotClean("information separator 2", '\u001e');
+    assertNotClean("information separator 1", '\u001f');
+  }
+
+  private void assertNotClean(String name, char c) throws JSONException {
+    assertEquals("The character " + name + " is not whitespace according to the JSON spec.", c,
+        new JSONTokener(new String(new char[] {c, 'A'})).nextClean());
+  }
+
+  public void testNextString() throws JSONException {
+    assertEquals("", new JSONTokener("'").nextString('\''));
+    assertEquals("", new JSONTokener("\"").nextString('\"'));
+    assertEquals("ABC", new JSONTokener("ABC'DEF").nextString('\''));
+    assertEquals("ABC", new JSONTokener("ABC'''DEF").nextString('\''));
+
+    // nextString permits slash-escaping of arbitrary characters!
+    assertEquals("ABC", new JSONTokener("A\\B\\C'DEF").nextString('\''));
+
+    JSONTokener tokener = new JSONTokener(" 'abc' 'def' \"ghi\"");
+    tokener.next();
+    assertEquals('\'', tokener.next());
+    assertEquals("abc", tokener.nextString('\''));
+    tokener.next();
+    assertEquals('\'', tokener.next());
+    assertEquals("def", tokener.nextString('\''));
+    tokener.next();
+    assertEquals('"', tokener.next());
+    assertEquals("ghi", tokener.nextString('\"'));
+    assertFalse(tokener.more());
+  }
+
+  public void testNextStringNoDelimiter() throws JSONException {
+    try {
+      new JSONTokener("").nextString('\'');
+      fail();
+    } catch (JSONException ignored) {
+    }
+
+    JSONTokener tokener = new JSONTokener(" 'abc");
+    tokener.next();
+    tokener.next();
+    try {
+      tokener.next('\'');
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  public void testNextStringEscapedQuote() throws JSONException {
+    try {
+      new JSONTokener("abc\\").nextString('"');
+      fail();
+    } catch (JSONException ignored) {
+    }
+
+    // we're mixing Java escaping like \" and JavaScript escaping like \\\"
+    // which makes these tests extra tricky to read!
+    assertEquals("abc\"def", new JSONTokener("abc\\\"def\"ghi").nextString('"'));
+    assertEquals("abc\\def", new JSONTokener("abc\\\\def\"ghi").nextString('"'));
+    assertEquals("abc/def", new JSONTokener("abc\\/def\"ghi").nextString('"'));
+    assertEquals("abc\bdef", new JSONTokener("abc\\bdef\"ghi").nextString('"'));
+    assertEquals("abc\fdef", new JSONTokener("abc\\fdef\"ghi").nextString('"'));
+    assertEquals("abc\ndef", new JSONTokener("abc\\ndef\"ghi").nextString('"'));
+    assertEquals("abc\rdef", new JSONTokener("abc\\rdef\"ghi").nextString('"'));
+    assertEquals("abc\tdef", new JSONTokener("abc\\tdef\"ghi").nextString('"'));
+  }
+
+  public void testNextStringUnicodeEscaped() throws JSONException {
+    // we're mixing Java escaping like \\ and JavaScript escaping like \\u
+    assertEquals("abc def", new JSONTokener("abc\\u0020def\"ghi").nextString('"'));
+    assertEquals("abcU0020def", new JSONTokener("abc\\U0020def\"ghi").nextString('"'));
+
+    // JSON requires 4 hex characters after a unicode escape
+    try {
+      new JSONTokener("abc\\u002\"").nextString('"');
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      new JSONTokener("abc\\u").nextString('"');
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      new JSONTokener("abc\\u    \"").nextString('"');
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals("abc\"def", new JSONTokener("abc\\u0022def\"ghi").nextString('"'));
+    try {
+      new JSONTokener("abc\\u000G\"").nextString('"');
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  public void testNextStringNonQuote() throws JSONException {
+    assertEquals("AB", new JSONTokener("ABC").nextString('C'));
+    assertEquals("ABCD", new JSONTokener("AB\\CDC").nextString('C'));
+    assertEquals("AB\nC", new JSONTokener("AB\\nCn").nextString('n'));
+  }
+
+  public void testNextTo() throws JSONException {
+    assertEquals("ABC", new JSONTokener("ABCDEFG").nextTo("DHI"));
+    assertEquals("ABCDEF", new JSONTokener("ABCDEF").nextTo(""));
+
+    JSONTokener tokener = new JSONTokener("ABC\rDEF\nGHI\r\nJKL");
+    assertEquals("ABC", tokener.nextTo("M"));
+    assertEquals('\r', tokener.next());
+    assertEquals("DEF", tokener.nextTo("M"));
+    assertEquals('\n', tokener.next());
+    assertEquals("GHI", tokener.nextTo("M"));
+    assertEquals('\r', tokener.next());
+    assertEquals('\n', tokener.next());
+    assertEquals("JKL", tokener.nextTo("M"));
+
+    tokener = new JSONTokener("ABCDEFGHI");
+    assertEquals("ABC", tokener.nextTo("DEF"));
+    assertEquals("", tokener.nextTo("DEF"));
+    assertEquals('D', tokener.next());
+    assertEquals("", tokener.nextTo("DEF"));
+    assertEquals('E', tokener.next());
+    assertEquals("", tokener.nextTo("DEF"));
+    assertEquals('F', tokener.next());
+    assertEquals("GHI", tokener.nextTo("DEF"));
+    assertEquals("", tokener.nextTo("DEF"));
+
+    tokener = new JSONTokener(" \t \fABC \t DEF");
+    assertEquals("ABC", tokener.nextTo("DEF"));
+    assertEquals('D', tokener.next());
+
+    tokener = new JSONTokener(" \t \fABC \n DEF");
+    assertEquals("ABC", tokener.nextTo("\n"));
+    assertEquals("", tokener.nextTo("\n"));
+
+    tokener = new JSONTokener("");
+    try {
+      tokener.nextTo(null);
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+  }
+
+  public void testNextToTrimming() {
+    assertEquals("ABC", new JSONTokener("\t ABC \tDEF").nextTo("DE"));
+    assertEquals("ABC", new JSONTokener("\t ABC \tDEF").nextTo('D'));
+  }
+
+  public void testNextToTrailing() {
+    assertEquals("ABC DEF", new JSONTokener("\t ABC DEF \t").nextTo("G"));
+    assertEquals("ABC DEF", new JSONTokener("\t ABC DEF \t").nextTo('G'));
+  }
+
+  public void testNextToDoesntStopOnNull() {
+    String message = "nextTo() shouldn't stop after \\0 characters";
+    JSONTokener tokener = new JSONTokener(" \0\t \fABC \n DEF");
+    assertEquals(message, "ABC", tokener.nextTo("D"));
+    assertEquals(message, '\n', tokener.next());
+    assertEquals(message, "", tokener.nextTo("D"));
+  }
+
+  public void testNextToConsumesNull() {
+    String message = "nextTo shouldn't consume \\0.";
+    JSONTokener tokener = new JSONTokener("ABC\0DEF");
+    assertEquals(message, "ABC", tokener.nextTo("\0"));
+    assertEquals(message, '\0', tokener.next());
+    assertEquals(message, "DEF", tokener.nextTo("\0"));
+  }
+
+  public void testSkipPast() {
+    JSONTokener tokener = new JSONTokener("ABCDEF");
+    tokener.skipPast("ABC");
+    assertEquals('D', tokener.next());
+    tokener.skipPast("EF");
+    assertEquals('\0', tokener.next());
+
+    tokener = new JSONTokener("ABCDEF");
+    tokener.skipPast("ABCDEF");
+    assertEquals('\0', tokener.next());
+
+    tokener = new JSONTokener("ABCDEF");
+    tokener.skipPast("G");
+    assertEquals('\0', tokener.next());
+
+    tokener = new JSONTokener("ABC\0ABC");
+    tokener.skipPast("ABC");
+    assertEquals('\0', tokener.next());
+    assertEquals('A', tokener.next());
+
+    tokener = new JSONTokener("\0ABC");
+    tokener.skipPast("ABC");
+    assertEquals('\0', tokener.next());
+
+    tokener = new JSONTokener("ABC\nDEF");
+    tokener.skipPast("DEF");
+    assertEquals('\0', tokener.next());
+
+    tokener = new JSONTokener("ABC");
+    tokener.skipPast("ABCDEF");
+    assertEquals('\0', tokener.next());
+
+    tokener = new JSONTokener("ABCDABCDABCD");
+    tokener.skipPast("ABC");
+    assertEquals('D', tokener.next());
+    tokener.skipPast("ABC");
+    assertEquals('D', tokener.next());
+    tokener.skipPast("ABC");
+    assertEquals('D', tokener.next());
+
+    tokener = new JSONTokener("");
+    try {
+      tokener.skipPast(null);
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+  }
+
+  public void testSkipTo() {
+    JSONTokener tokener = new JSONTokener("ABCDEF");
+    tokener.skipTo('A');
+    assertEquals('A', tokener.next());
+    tokener.skipTo('D');
+    assertEquals('D', tokener.next());
+    tokener.skipTo('G');
+    assertEquals('E', tokener.next());
+    tokener.skipTo('A');
+    assertEquals('F', tokener.next());
+
+    tokener = new JSONTokener("ABC\nDEF");
+    tokener.skipTo('F');
+    assertEquals('F', tokener.next());
+
+    tokener = new JSONTokener("ABCfDEF");
+    tokener.skipTo('F');
+    assertEquals('F', tokener.next());
+
+    tokener = new JSONTokener("ABC/* DEF */");
+    tokener.skipTo('D');
+    assertEquals('D', tokener.next());
+  }
+
+  public void testSkipToStopsOnNull() {
+    JSONTokener tokener = new JSONTokener("ABC\0DEF");
+    tokener.skipTo('F');
+    assertEquals("skipTo shouldn't stop when it sees '\\0'", 'F', tokener.next());
+  }
+
+  public void testBomIgnoredAsFirstCharacterOfDocument() throws JSONException {
+    JSONTokener tokener = new JSONTokener("\ufeff[]");
+    JSONArray array = (JSONArray) tokener.nextValue();
+    assertEquals(0, array.length());
+  }
+
+  public void testBomTreatedAsCharacterInRestOfDocument() throws JSONException {
+    JSONTokener tokener = new JSONTokener("[\ufeff]");
+    JSONArray array = (JSONArray) tokener.nextValue();
+    assertEquals(1, array.length());
+  }
+
+  public void testDehexchar() {
+    assertEquals(0, JSONTokener.dehexchar('0'));
+    assertEquals(1, JSONTokener.dehexchar('1'));
+    assertEquals(2, JSONTokener.dehexchar('2'));
+    assertEquals(3, JSONTokener.dehexchar('3'));
+    assertEquals(4, JSONTokener.dehexchar('4'));
+    assertEquals(5, JSONTokener.dehexchar('5'));
+    assertEquals(6, JSONTokener.dehexchar('6'));
+    assertEquals(7, JSONTokener.dehexchar('7'));
+    assertEquals(8, JSONTokener.dehexchar('8'));
+    assertEquals(9, JSONTokener.dehexchar('9'));
+    assertEquals(10, JSONTokener.dehexchar('A'));
+    assertEquals(11, JSONTokener.dehexchar('B'));
+    assertEquals(12, JSONTokener.dehexchar('C'));
+    assertEquals(13, JSONTokener.dehexchar('D'));
+    assertEquals(14, JSONTokener.dehexchar('E'));
+    assertEquals(15, JSONTokener.dehexchar('F'));
+    assertEquals(10, JSONTokener.dehexchar('a'));
+    assertEquals(11, JSONTokener.dehexchar('b'));
+    assertEquals(12, JSONTokener.dehexchar('c'));
+    assertEquals(13, JSONTokener.dehexchar('d'));
+    assertEquals(14, JSONTokener.dehexchar('e'));
+    assertEquals(15, JSONTokener.dehexchar('f'));
+
+    for (int c = 0; c <= 0xFFFF; c++) {
+      if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) {
+        continue;
+      }
+      assertEquals("dehexchar " + c, -1, JSONTokener.dehexchar((char) c));
+    }
+  }
 }


[16/51] [abbrv] geode git commit: GEODE-2142: spotless

Posted by ds...@apache.org.
GEODE-2142: spotless


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/eac0bb8c
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/eac0bb8c
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/eac0bb8c

Branch: refs/heads/feature/GEM-1195
Commit: eac0bb8c8e20cae892680a3a39b790c0e05bf4cf
Parents: 7c8794c
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Feb 17 15:43:49 2017 -0800
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Mon Feb 27 07:18:55 2017 -0800

----------------------------------------------------------------------
 .../internal/cli/result/AbstractResultData.java |    7 +-
 geode-json/src/main/java/org/json/JSON.java     |  176 +-
 .../src/main/java/org/json/JSONArray.java       | 1458 ++++++-----
 .../src/main/java/org/json/JSONException.java   |   59 +-
 .../src/main/java/org/json/JSONObject.java      |  378 +--
 .../src/main/java/org/json/JSONString.java      |   17 +-
 .../src/main/java/org/json/JSONStringer.java    |  779 +++---
 .../src/main/java/org/json/JSONTokener.java     | 1149 +++++----
 geode-json/src/test/java/org/json/FileTest.java |  407 ++-
 .../src/test/java/org/json/JSONArrayTest.java   | 1171 +++++----
 .../java/org/json/JSONFunctionTestObject.java   |   18 +-
 .../src/test/java/org/json/JSONObjectTest.java  | 2314 +++++++++---------
 .../test/java/org/json/JSONStringerTest.java    |  735 +++---
 .../src/test/java/org/json/JSONTokenerTest.java | 1199 +++++----
 .../src/test/java/org/json/ParsingTest.java     |  535 ++--
 .../src/test/java/org/json/SelfUseTest.java     |  465 ++--
 16 files changed, 5350 insertions(+), 5517 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
index 81ab511..f453ec6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
@@ -175,8 +175,9 @@ public abstract class AbstractResultData implements ResultData {
       sectionData.put(FILE_TYPE_FIELD, fileType);
       sectionData.put(FILE_MESSAGE, message);
       DeflaterInflaterData deflaterInflaterData = CliUtil.compressBytes(data);
-      sectionData.put(FILE_DATA_FIELD, Base64.getEncoder().encodeToString(deflaterInflaterData.getData()));
-      sectionData.put(DATA_LENGTH_FIELD,deflaterInflaterData.getDataLength());
+      sectionData.put(FILE_DATA_FIELD,
+          Base64.getEncoder().encodeToString(deflaterInflaterData.getData()));
+      sectionData.put(DATA_LENGTH_FIELD, deflaterInflaterData.getDataLength());
     } catch (GfJsonException e) {
       throw new ResultDataException(e.getMessage());
     }
@@ -231,7 +232,7 @@ public abstract class AbstractResultData implements ResultData {
       String fileDataString = (String) object.get(FILE_DATA_FIELD);
       int fileDataLength = (int) object.get(DATA_LENGTH_FIELD);
       byte[] byteArray = Base64.getDecoder().decode(fileDataString);
-      byte[] uncompressBytes = CliUtil.uncompressBytes(byteArray,fileDataLength).getData();
+      byte[] uncompressBytes = CliUtil.uncompressBytes(byteArray, fileDataLength).getData();
 
       boolean isGfshVM = CliUtil.isGfshVM();
       File fileToDumpData = new File(fileName);

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/main/java/org/json/JSON.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSON.java b/geode-json/src/main/java/org/json/JSON.java
index 1b32e69..7105cab 100755
--- a/geode-json/src/main/java/org/json/JSON.java
+++ b/geode-json/src/main/java/org/json/JSON.java
@@ -1,116 +1,112 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
 
 class JSON {
-    /**
-     * Returns the input if it is a JSON-permissible value; throws otherwise.
-     */
-    static double checkDouble(double d) throws JSONException {
-        if (Double.isInfinite(d) || Double.isNaN(d)) {
-            throw new JSONException("Forbidden numeric value: " + d);
-        }
-        return d;
+  /**
+   * Returns the input if it is a JSON-permissible value; throws otherwise.
+   */
+  static double checkDouble(double d) throws JSONException {
+    if (Double.isInfinite(d) || Double.isNaN(d)) {
+      throw new JSONException("Forbidden numeric value: " + d);
     }
+    return d;
+  }
 
-    static Boolean toBoolean(Object value) {
-        if (value instanceof Boolean) {
-            return (Boolean) value;
-        } else if (value instanceof String) {
-            String stringValue = (String) value;
-            if ("true".equalsIgnoreCase(stringValue)) {
-                return true;
-            } else if ("false".equalsIgnoreCase(stringValue)) {
-                return false;
-            }
-        }
-        return null;
+  static Boolean toBoolean(Object value) {
+    if (value instanceof Boolean) {
+      return (Boolean) value;
+    } else if (value instanceof String) {
+      String stringValue = (String) value;
+      if ("true".equalsIgnoreCase(stringValue)) {
+        return true;
+      } else if ("false".equalsIgnoreCase(stringValue)) {
+        return false;
+      }
     }
+    return null;
+  }
 
-    static Double toDouble(Object value) {
-        if (value instanceof Double) {
-            return (Double) value;
-        } else if (value instanceof Number) {
-            return ((Number) value).doubleValue();
-        } else if (value instanceof String) {
-            try {
-                return Double.valueOf((String) value);
-            } catch (NumberFormatException ignored) {
-            }
-        }
-        return null;
+  static Double toDouble(Object value) {
+    if (value instanceof Double) {
+      return (Double) value;
+    } else if (value instanceof Number) {
+      return ((Number) value).doubleValue();
+    } else if (value instanceof String) {
+      try {
+        return Double.valueOf((String) value);
+      } catch (NumberFormatException ignored) {
+      }
     }
+    return null;
+  }
 
-    static Integer toInteger(Object value) {
-        if (value instanceof Integer) {
-            return (Integer) value;
-        } else if (value instanceof Number) {
-            return ((Number) value).intValue();
-        } else if (value instanceof String) {
-            try {
-                return (int) Double.parseDouble((String) value);
-            } catch (NumberFormatException ignored) {
-            }
-        }
-        return null;
+  static Integer toInteger(Object value) {
+    if (value instanceof Integer) {
+      return (Integer) value;
+    } else if (value instanceof Number) {
+      return ((Number) value).intValue();
+    } else if (value instanceof String) {
+      try {
+        return (int) Double.parseDouble((String) value);
+      } catch (NumberFormatException ignored) {
+      }
     }
+    return null;
+  }
 
-    static Long toLong(Object value) {
-        if (value instanceof Long) {
-            return (Long) value;
-        } else if (value instanceof Number) {
-            return ((Number) value).longValue();
-        } else if (value instanceof String) {
-            try {
-                return (long) Double.parseDouble((String) value);
-            } catch (NumberFormatException ignored) {
-            }
-        }
-        return null;
+  static Long toLong(Object value) {
+    if (value instanceof Long) {
+      return (Long) value;
+    } else if (value instanceof Number) {
+      return ((Number) value).longValue();
+    } else if (value instanceof String) {
+      try {
+        return (long) Double.parseDouble((String) value);
+      } catch (NumberFormatException ignored) {
+      }
     }
+    return null;
+  }
 
-    static String toString(Object value) {
-        if (value instanceof String) {
-            return (String) value;
-        } else if (value != null) {
-            return String.valueOf(value);
-        }
-        return null;
+  static String toString(Object value) {
+    if (value instanceof String) {
+      return (String) value;
+    } else if (value != null) {
+      return String.valueOf(value);
     }
+    return null;
+  }
 
-    public static JSONException typeMismatch(Object indexOrName, Object actual,
-            String requiredType) throws JSONException {
-        if (actual == null) {
-            throw new JSONException("Value at " + indexOrName + " is null.");
-        } else {
-            throw new JSONException("Value " + actual + " at " + indexOrName
-                    + " of type " + actual.getClass().getName()
-                    + " cannot be converted to " + requiredType);
-        }
+  public static JSONException typeMismatch(Object indexOrName, Object actual, String requiredType)
+      throws JSONException {
+    if (actual == null) {
+      throw new JSONException("Value at " + indexOrName + " is null.");
+    } else {
+      throw new JSONException("Value " + actual + " at " + indexOrName + " of type "
+          + actual.getClass().getName() + " cannot be converted to " + requiredType);
     }
+  }
 
-    public static JSONException typeMismatch(Object actual, String requiredType)
-            throws JSONException {
-        if (actual == null) {
-            throw new JSONException("Value is null.");
-        } else {
-            throw new JSONException("Value " + actual
-                    + " of type " + actual.getClass().getName()
-                    + " cannot be converted to " + requiredType);
-        }
+  public static JSONException typeMismatch(Object actual, String requiredType)
+      throws JSONException {
+    if (actual == null) {
+      throw new JSONException("Value is null.");
+    } else {
+      throw new JSONException("Value " + actual + " of type " + actual.getClass().getName()
+          + " cannot be converted to " + requiredType);
     }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/main/java/org/json/JSONArray.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONArray.java b/geode-json/src/main/java/org/json/JSONArray.java
index 074624d..c961139 100755
--- a/geode-json/src/main/java/org/json/JSONArray.java
+++ b/geode-json/src/main/java/org/json/JSONArray.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -24,736 +22,726 @@ import java.util.List;
 // Note: this class was written without inspecting the non-free org.json sourcecode.
 
 /**
- * A dense indexed sequence of values. Values may be any mix of
- * {@link JSONObject JSONObjects}, other {@link JSONArray JSONArrays}, Strings,
- * Booleans, Integers, Longs, Doubles, {@code null} or {@link JSONObject#NULL}.
- * Values may not be {@link Double#isNaN() NaNs}, {@link Double#isInfinite()
- * infinities}, or of any type not listed here.
+ * A dense indexed sequence of values. Values may be any mix of {@link JSONObject JSONObjects},
+ * other {@link JSONArray JSONArrays}, Strings, Booleans, Integers, Longs, Doubles, {@code null} or
+ * {@link JSONObject#NULL}. Values may not be {@link Double#isNaN() NaNs},
+ * {@link Double#isInfinite() infinities}, or of any type not listed here.
  *
- * {@code JSONArray} has the same type coercion behavior and
- * optional/mandatory accessors as {@link JSONObject}. See that class'
- * documentation for details.
+ * {@code JSONArray} has the same type coercion behavior and optional/mandatory accessors as
+ * {@link JSONObject}. See that class' documentation for details.
  *
- * <strong>Warning:</strong> this class represents null in two incompatible
- * ways: the standard Java {@code null} reference, and the sentinel value {@link
- * JSONObject#NULL}. In particular, {@code get} fails if the requested index
- * holds the null reference, but succeeds if it holds {@code JSONObject.NULL}.
+ * <strong>Warning:</strong> this class represents null in two incompatible ways: the standard Java
+ * {@code null} reference, and the sentinel value {@link JSONObject#NULL}. In particular,
+ * {@code get} fails if the requested index holds the null reference, but succeeds if it holds
+ * {@code JSONObject.NULL}.
  *
- * Instances of this class are not thread safe. Although this class is
- * non-final, it was not designed for inheritance and should not be subclassed.
- * In particular, self-use by overridable methods is not specified. See
- * <i>Effective Java</i> Item 17, "Design and Document or inheritance or else
- * prohibit it" for further information.
+ * Instances of this class are not thread safe. Although this class is non-final, it was not
+ * designed for inheritance and should not be subclassed. In particular, self-use by overridable
+ * methods is not specified. See <i>Effective Java</i> Item 17, "Design and Document or inheritance
+ * or else prohibit it" for further information.
  */
 public class JSONArray {
 
-    private final List<Object> values;
-
-    /**
-     * Creates a {@code JSONArray} with no values.
-     */
-    public JSONArray() {
-        values = new ArrayList<Object>();
-    }
-
-    /**
-     * Creates a new {@code JSONArray} by copying all values from the given
-     * collection.
-     *
-     * @param copyFrom a collection whose values are of supported types.
-     *                 Unsupported values are not permitted and will yield an array in an
-     *                 inconsistent state.
-     */
-    /* Accept a raw type for API compatibility */
-    public JSONArray(Collection<?> copyFrom) {
-        this();
-        if (copyFrom != null) {
-            for (Object aCopyFrom : copyFrom) {
-                put(JSONObject.wrap(aCopyFrom));
-            }
-        }
-    }
-
-    /**
-     * Creates a new {@code JSONArray} with values from the next array in the
-     * tokener.
-     *
-     * @param readFrom a tokener whose nextValue() method will yield a
-     *                 {@code JSONArray}.
-     * @throws JSONException if the parse fails or doesn't yield a
-     *                       {@code JSONArray}.
-     */
-    public JSONArray(JSONTokener readFrom) throws JSONException {
-        /*
-         * Getting the parser to populate this could get tricky. Instead, just
-         * parse to temporary JSONArray and then steal the data from that.
-         */
-        Object object = readFrom.nextValue();
-        if (object instanceof JSONArray) {
-            values = ((JSONArray) object).values;
-        } else {
-            throw JSON.typeMismatch(object, "JSONArray");
-        }
-    }
-
-    /**
-     * Creates a new {@code JSONArray} with values from the JSON string.
-     *
-     * @param json a JSON-encoded string containing an array.
-     * @throws JSONException if the parse fails or doesn't yield a {@code
-     *                       JSONArray}.
-     */
-    public JSONArray(String json) throws JSONException {
-        this(new JSONTokener(json));
-    }
-
-    /**
-     * Creates a new {@code JSONArray} with values from the given primitive array.
-     *
-     * @param array The values to use.
-     * @throws JSONException if any of the values are non-finite double values (i.e. NaN or infinite)
-     */
-    public JSONArray(Object array) throws JSONException {
-        if (!array.getClass().isArray()) {
-            throw new JSONException("Not a primitive array: " + array.getClass());
-        }
-        final int length = Array.getLength(array);
-        values = new ArrayList<Object>(length);
-        for (int i = 0; i < length; ++i) {
-            put(JSONObject.wrap(Array.get(array, i)));
-        }
-    }
-
-    /**
-     * @return Returns the number of values in this array.
-     */
-    public int length() {
-        return values.size();
-    }
-
-    /**
-     * Appends {@code value} to the end of this array.
-     *
-     * @param value The value to append.
-     * @return this array.
-     */
-    public JSONArray put(boolean value) {
-        values.add(value);
-        return this;
-    }
-
-    /**
-     * Appends {@code value} to the end of this array.
-     *
-     * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
-     *              {@link Double#isInfinite() infinities}.
-     * @return this array.
-     * @throws JSONException If the value is unacceptable.
-     */
-    public JSONArray put(double value) throws JSONException {
-        values.add(JSON.checkDouble(value));
-        return this;
-    }
-
-    /**
-     * Appends {@code value} to the end of this array.
-     *
-     * @param value The value to append.
-     * @return this array.
-     */
-    public JSONArray put(int value) {
-        values.add(value);
-        return this;
-    }
-
-    /**
-     * Appends {@code value} to the end of this array.
-     *
-     * @param value The value to append.
-     * @return this array.
-     */
-    public JSONArray put(long value) {
-        values.add(value);
-        return this;
-    }
-
-    /**
-     * Appends {@code value} wrapped by {@link JSONArray} to the end of this array.
-     *
-     * @param value any collection.
-     * @return this array.
-     */
-    public JSONArray put(Collection<?> value) {
-        if (value == null) {
-            return put((Object)null);
-        }
-        values.add(new JSONArray(value));
-        return this;
-    }
-
-    /**
-     * Appends {@code value} to the end of this array.
-     *
-     * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
-     *              Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May
-     *              not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
-     *              infinities}. Unsupported values are not permitted and will cause the
-     *              array to be in an inconsistent state.
-     * @return this array.
-     */
-    public JSONArray put(Object value) {
-        values.add(value);
-        return this;
-    }
-
-    /**
-     * Same as {@link #put}, with added validity checks.
-     *
-     * @param value The value to append.
-     */
-    void checkedPut(Object value) throws JSONException {
-        if (value instanceof Number) {
-            JSON.checkDouble(((Number) value).doubleValue());
-        }
-
-        put(value);
-    }
-
-    /**
-     * Sets the value at {@code index} to {@code value}, null padding this array
-     * to the required length if necessary. If a value already exists at {@code
-     * index}, it will be replaced.
-     *
-     * @param index Where to put the value.
-     * @param value The value to set.
-     * @return this array.
-     * @throws JSONException This should never happen.
-     */
-    public JSONArray put(int index, boolean value) throws JSONException {
-        return put(index, (Boolean) value);
-    }
-
-    /**
-     * Sets the value at {@code index} to {@code value}, null padding this array
-     * to the required length if necessary. If a value already exists at {@code
-     * index}, it will be replaced.
-     *
-     * @param index Where to put the value.
-     * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
-     *              {@link Double#isInfinite() infinities}.
-     * @return this array.
-     * @throws JSONException If the value is not a finite value.
-     */
-    public JSONArray put(int index, double value) throws JSONException {
-        return put(index, (Double) value);
-    }
-
-    /**
-     * Sets the value at {@code index} to {@code value}, null padding this array
-     * to the required length if necessary. If a value already exists at {@code
-     * index}, it will be replaced.
-     *
-     * @param index Where to put the value.
-     * @param value The value to set.
-     * @return this array.
-     * @throws JSONException Should never actually happen.
-     */
-    public JSONArray put(int index, int value) throws JSONException {
-        return put(index, (Integer) value);
-    }
-
-    /**
-     * Sets the value at {@code index} to {@code value}, null padding this array
-     * to the required length if necessary. If a value already exists at {@code
-     * index}, it will be replaced.
-     *
-     * @param index Where to put the value.
-     * @param value The value to set.
-     * @return this array.
-     * @throws JSONException Should never actually happen.
-     */
-    public JSONArray put(int index, long value) throws JSONException {
-        return put(index, (Long) value);
-    }
-
-    /**
-     * Sets the value at {@code index} to {@code value} wrapped into {@link JSONArray},
-     * null padding this array to the required length if necessary. If a value already
-     * exists at {@code index}, it will be replaced.
-     *
-     * @param index Where to put the value.
-     * @param value The value to set.
-     * @return this array.
-     * @throws JSONException Should never actually happen.
-     */
-    public JSONArray put(int index, Collection<?> value) throws JSONException {
-        if (value == null) {
-            return put(index, (Object)null);
-        }
-        return put(index, new JSONArray(value));
-    }
-
-    /**
-     * Sets the value at {@code index} to {@code value}, null padding this array
-     * to the required length if necessary. If a value already exists at {@code
-     * index}, it will be replaced.
-     *
-     * @param index Where to put the value.
-     * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
-     *              Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May
-     *              not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
-     *              infinities}.
-     * @return this array.
-     * @throws JSONException If the value cannot be represented as a finite double value.
-     */
-    public JSONArray put(int index, Object value) throws JSONException {
-        if (value instanceof Number) {
-            // deviate from the original by checking all Numbers, not just floats & doubles
-            JSON.checkDouble(((Number) value).doubleValue());
-        }
-        while (values.size() <= index) {
-            values.add(null);
-        }
-        values.set(index, value);
-        return this;
-    }
-
-    /**
-     * Returns true if this array has no value at {@code index}, or if its value
-     * is the {@code null} reference or {@link JSONObject#NULL}.
-     *
-     * @param index Which value to check.
-     * @return true if the value is null.
-     */
-    public boolean isNull(int index) {
-        Object value = opt(index);
-        return value == null || value == JSONObject.NULL;
-    }
-
-    /**
-     * Returns the value at {@code index}.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     * @throws JSONException if this array has no value at {@code index}, or if
-     *                       that value is the {@code null} reference. This method returns
-     *                       normally if the value is {@code JSONObject#NULL}.
-     */
-    public Object get(int index) throws JSONException {
-        try {
-            Object value = values.get(index);
-            if (value == null) {
-                throw new JSONException("Value at " + index + " is null.");
-            }
-            return value;
-        } catch (IndexOutOfBoundsException e) {
-            throw new JSONException("Index " + index + " out of range [0.." + values.size() + ")");
-        }
-    }
-
-    /**
-     * Returns the value at {@code index}, or null if the array has no value
-     * at {@code index}.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     */
-    public Object opt(int index) {
-        if (index < 0 || index >= values.size()) {
-            return null;
-        }
-        return values.get(index);
-    }
-
-    /**
-     * Removes and returns the value at {@code index}, or null if the array has no value
-     * at {@code index}.
-     *
-     * @param index Which value to remove.
-     * @return The value previously at the specified location.
-     */
-    public Object remove(int index) {
-        if (index < 0 || index >= values.size()) {
-            return null;
-        }
-        return values.remove(index);
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a boolean or can
-     * be coerced to a boolean.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     * @throws JSONException if the value at {@code index} doesn't exist or
-     *                       cannot be coerced to a boolean.
-     */
-    public boolean getBoolean(int index) throws JSONException {
-        Object object = get(index);
-        Boolean result = JSON.toBoolean(object);
-        if (result == null) {
-            throw JSON.typeMismatch(index, object, "boolean");
-        }
-        return result;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a boolean or can
-     * be coerced to a boolean. Returns false otherwise.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     */
-    public boolean optBoolean(int index) {
-        return optBoolean(index, false);
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a boolean or can
-     * be coerced to a boolean. Returns {@code fallback} otherwise.
-     *
-     * @param index    Which value to get.
-     * @param fallback the fallback value to return if no value exists.
-     * @return the value at the specified location or the fallback value.
-     */
-    public boolean optBoolean(int index, boolean fallback) {
-        Object object = opt(index);
-        Boolean result = JSON.toBoolean(object);
-        return result != null ? result : fallback;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a double or can
-     * be coerced to a double.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     * @throws JSONException if the value at {@code index} doesn't exist or
-     *                       cannot be coerced to a double.
-     */
-    public double getDouble(int index) throws JSONException {
-        Object object = get(index);
-        Double result = JSON.toDouble(object);
-        if (result == null) {
-            throw JSON.typeMismatch(index, object, "double");
-        }
-        return result;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a double or can
-     * be coerced to a double. Returns {@code NaN} otherwise.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     */
-    public double optDouble(int index) {
-        return optDouble(index, Double.NaN);
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a double or can
-     * be coerced to a double. Returns {@code fallback} otherwise.
-     *
-     * @param index    Which value to get.
-     * @param fallback The fallback value to use if no value is at the specified location.
-     * @return the value at the specified location or the fallback value.
-     */
-    public double optDouble(int index, double fallback) {
-        Object object = opt(index);
-        Double result = JSON.toDouble(object);
-        return result != null ? result : fallback;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is an int or
-     * can be coerced to an int.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     * @throws JSONException if the value at {@code index} doesn't exist or
-     *                       cannot be coerced to a int.
-     */
-    public int getInt(int index) throws JSONException {
-        Object object = get(index);
-        Integer result = JSON.toInteger(object);
-        if (result == null) {
-            throw JSON.typeMismatch(index, object, "int");
-        }
-        return result;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is an int or
-     * can be coerced to an int. Returns 0 otherwise.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     */
-    public int optInt(int index) {
-        return optInt(index, 0);
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is an int or
-     * can be coerced to an int. Returns {@code fallback} otherwise.
-     *
-     * @param index    Which value to get.
-     * @param fallback The fallback value to use if no value is at the specified location.
-     * @return the value at the specified location or the fallback value.
-     */
-    public int optInt(int index, int fallback) {
-        Object object = opt(index);
-        Integer result = JSON.toInteger(object);
-        return result != null ? result : fallback;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a long or
-     * can be coerced to a long.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     * @throws JSONException if the value at {@code index} doesn't exist or
-     *                       cannot be coerced to a long.
-     */
-    public long getLong(int index) throws JSONException {
-        Object object = get(index);
-        Long result = JSON.toLong(object);
-        if (result == null) {
-            throw JSON.typeMismatch(index, object, "long");
-        }
-        return result;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a long or
-     * can be coerced to a long. Returns 0 otherwise.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     */
-    public long optLong(int index) {
-        return optLong(index, 0L);
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a long or
-     * can be coerced to a long. Returns {@code fallback} otherwise.
-     *
-     * @param index    Which value to get.
-     * @param fallback The fallback value to use if no value is at the specified location.
-     * @return the value at the specified location or the fallback value.
-     */
-    public long optLong(int index, long fallback) {
-        Object object = opt(index);
-        Long result = JSON.toLong(object);
-        return result != null ? result : fallback;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists, coercing it if
-     * necessary.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     * @throws JSONException if no such value exists.
-     */
-    public String getString(int index) throws JSONException {
-        Object object = get(index);
-        String result = JSON.toString(object);
-        if (result == null) {
-            throw JSON.typeMismatch(index, object, "String");
-        }
-        return result;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists, coercing it if
-     * necessary. Returns the empty string if no such value exists.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     */
-    public String optString(int index) {
-        return optString(index, "");
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists, coercing it if
-     * necessary. Returns {@code fallback} if no such value exists.
-     *
-     * @param index    Which value to get.
-     * @param fallback The fallback value to use if no value is at the specified location.
-     * @return the value at the specified location or the fallback value.
-     */
-    public String optString(int index, String fallback) {
-        Object object = opt(index);
-        String result = JSON.toString(object);
-        return result != null ? result : fallback;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a {@code
-     * JSONArray}.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     * @throws JSONException if the value doesn't exist or is not a {@code
-     *                       JSONArray}.
-     */
-    public JSONArray getJSONArray(int index) throws JSONException {
-        Object object = get(index);
-        if (object instanceof JSONArray) {
-            return (JSONArray) object;
-        } else {
-            throw JSON.typeMismatch(index, object, "JSONArray");
-        }
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a {@code
-     * JSONArray}. Returns null otherwise.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     */
-    public JSONArray optJSONArray(int index) {
-        Object object = opt(index);
-        return object instanceof JSONArray ? (JSONArray) object : null;
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a {@code
-     * JSONObject}.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     * @throws JSONException if the value doesn't exist or is not a {@code
-     *                       JSONObject}.
-     */
-    public JSONObject getJSONObject(int index) throws JSONException {
-        Object object = get(index);
-        if (object instanceof JSONObject) {
-            return (JSONObject) object;
-        } else {
-            throw JSON.typeMismatch(index, object, "JSONObject");
-        }
-    }
-
-    /**
-     * Returns the value at {@code index} if it exists and is a {@code
-     * JSONObject}. Returns null otherwise.
-     *
-     * @param index Which value to get.
-     * @return the value at the specified location.
-     */
-    public JSONObject optJSONObject(int index) {
-        Object object = opt(index);
-        return object instanceof JSONObject ? (JSONObject) object : null;
-    }
-
-    /**
-     * Returns a new object whose values are the values in this array, and whose
-     * names are the values in {@code names}. Names and values are paired up by
-     * index from 0 through to the shorter array's length. Names that are not
-     * strings will be coerced to strings. This method returns null if either
-     * array is empty.
-     *
-     * @param names The names to apply to the returned values.
-     * @return the newly constructed object.
-     * @throws JSONException Should not be possible.
-     */
-    public JSONObject toJSONObject(JSONArray names) throws JSONException {
-        JSONObject result = new JSONObject();
-        int length = Math.min(names.length(), values.size());
-        if (length == 0) {
-            return null;
-        }
-        for (int i = 0; i < length; i++) {
-            String name = JSON.toString(names.opt(i));
-            result.put(name, opt(i));
-        }
-        return result;
-    }
-
-    /**
-     * Returns a new string by alternating this array's values with {@code
-     * separator}. This array's string values are quoted and have their special
-     * characters escaped. For example, the array containing the strings '12"
-     * pizza', 'taco' and 'soda' joined on '+' returns this:
-     * <pre>"12\" pizza"+"taco"+"soda"</pre>
-     *
-     * @param separator The string used to separate the returned values.
-     * @return the conjoined values.
-     * @throws JSONException Only if there is a coding error.
-     */
-    public String join(String separator) throws JSONException {
-        JSONStringer stringer = new JSONStringer();
-        stringer.open(JSONStringer.Scope.NULL, "");
-        for (int i = 0, size = values.size(); i < size; i++) {
-            if (i > 0) {
-                stringer.out.append(separator);
-            }
-            stringer.value(values.get(i));
-        }
-        stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, "");
-        return stringer.out.toString();
-    }
-
-    /**
-     * Encodes this array as a compact JSON string, such as:
-     * <pre>[94043,90210]</pre>
-     *
-     * @return The string form of this array.
-     */
-    @Override
-    public String toString() {
-        try {
-            JSONStringer stringer = new JSONStringer();
-            writeTo(stringer);
-            return stringer.toString();
-        } catch (JSONException e) {
-            return null;
-        }
-    }
-
-    /**
-     * Encodes this array as a human readable JSON string for debugging, such
-     * as:
-     * <pre>
-     * [
-     *     94043,
-     *     90210
-     * ]</pre>
-     *
-     * @param indentSpaces the number of spaces to indent for each level of
-     *                     nesting.
-     * @return The string form of this array.
-     * @throws JSONException Only if there is a coding error.
-     */
-    public String toString(int indentSpaces) throws JSONException {
-        JSONStringer stringer = new JSONStringer(indentSpaces);
-        writeTo(stringer);
-        return stringer.toString();
-    }
-
-    void writeTo(JSONStringer stringer) throws JSONException {
-        stringer.array();
-        for (Object value : values) {
-            stringer.value(value);
-        }
-        stringer.endArray();
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        return o instanceof JSONArray && ((JSONArray) o).values.equals(values);
-    }
-
-    @Override
-    public int hashCode() {
-        // diverge from the original, which doesn't implement hashCode
-        return values.hashCode();
-    }
+  private final List<Object> values;
+
+  /**
+   * Creates a {@code JSONArray} with no values.
+   */
+  public JSONArray() {
+    values = new ArrayList<Object>();
+  }
+
+  /**
+   * Creates a new {@code JSONArray} by copying all values from the given collection.
+   *
+   * @param copyFrom a collection whose values are of supported types. Unsupported values are not
+   *        permitted and will yield an array in an inconsistent state.
+   */
+  /* Accept a raw type for API compatibility */
+  public JSONArray(Collection<?> copyFrom) {
+    this();
+    if (copyFrom != null) {
+      for (Object aCopyFrom : copyFrom) {
+        put(JSONObject.wrap(aCopyFrom));
+      }
+    }
+  }
+
+  /**
+   * Creates a new {@code JSONArray} with values from the next array in the tokener.
+   *
+   * @param readFrom a tokener whose nextValue() method will yield a {@code JSONArray}.
+   * @throws JSONException if the parse fails or doesn't yield a {@code JSONArray}.
+   */
+  public JSONArray(JSONTokener readFrom) throws JSONException {
+    /*
+     * Getting the parser to populate this could get tricky. Instead, just parse to temporary
+     * JSONArray and then steal the data from that.
+     */
+    Object object = readFrom.nextValue();
+    if (object instanceof JSONArray) {
+      values = ((JSONArray) object).values;
+    } else {
+      throw JSON.typeMismatch(object, "JSONArray");
+    }
+  }
+
+  /**
+   * Creates a new {@code JSONArray} with values from the JSON string.
+   *
+   * @param json a JSON-encoded string containing an array.
+   * @throws JSONException if the parse fails or doesn't yield a {@code
+   *                       JSONArray}.
+   */
+  public JSONArray(String json) throws JSONException {
+    this(new JSONTokener(json));
+  }
+
+  /**
+   * Creates a new {@code JSONArray} with values from the given primitive array.
+   *
+   * @param array The values to use.
+   * @throws JSONException if any of the values are non-finite double values (i.e. NaN or infinite)
+   */
+  public JSONArray(Object array) throws JSONException {
+    if (!array.getClass().isArray()) {
+      throw new JSONException("Not a primitive array: " + array.getClass());
+    }
+    final int length = Array.getLength(array);
+    values = new ArrayList<Object>(length);
+    for (int i = 0; i < length; ++i) {
+      put(JSONObject.wrap(Array.get(array, i)));
+    }
+  }
+
+  /**
+   * @return Returns the number of values in this array.
+   */
+  public int length() {
+    return values.size();
+  }
+
+  /**
+   * Appends {@code value} to the end of this array.
+   *
+   * @param value The value to append.
+   * @return this array.
+   */
+  public JSONArray put(boolean value) {
+    values.add(value);
+    return this;
+  }
+
+  /**
+   * Appends {@code value} to the end of this array.
+   *
+   * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}.
+   * @return this array.
+   * @throws JSONException If the value is unacceptable.
+   */
+  public JSONArray put(double value) throws JSONException {
+    values.add(JSON.checkDouble(value));
+    return this;
+  }
+
+  /**
+   * Appends {@code value} to the end of this array.
+   *
+   * @param value The value to append.
+   * @return this array.
+   */
+  public JSONArray put(int value) {
+    values.add(value);
+    return this;
+  }
+
+  /**
+   * Appends {@code value} to the end of this array.
+   *
+   * @param value The value to append.
+   * @return this array.
+   */
+  public JSONArray put(long value) {
+    values.add(value);
+    return this;
+  }
+
+  /**
+   * Appends {@code value} wrapped by {@link JSONArray} to the end of this array.
+   *
+   * @param value any collection.
+   * @return this array.
+   */
+  public JSONArray put(Collection<?> value) {
+    if (value == null) {
+      return put((Object) null);
+    }
+    values.add(new JSONArray(value));
+    return this;
+  }
+
+  /**
+   * Appends {@code value} to the end of this array.
+   *
+   * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, Integer, Long, Double,
+   *        {@link JSONObject#NULL}, or {@code null}. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}. Unsupported values are not permitted and will
+   *        cause the array to be in an inconsistent state.
+   * @return this array.
+   */
+  public JSONArray put(Object value) {
+    values.add(value);
+    return this;
+  }
+
+  /**
+   * Same as {@link #put}, with added validity checks.
+   *
+   * @param value The value to append.
+   */
+  void checkedPut(Object value) throws JSONException {
+    if (value instanceof Number) {
+      JSON.checkDouble(((Number) value).doubleValue());
+    }
+
+    put(value);
+  }
+
+  /**
+   * Sets the value at {@code index} to {@code value}, null padding this array to the required
+   * length if necessary. If a value already exists at {@code
+   * index}, it will be replaced.
+   *
+   * @param index Where to put the value.
+   * @param value The value to set.
+   * @return this array.
+   * @throws JSONException This should never happen.
+   */
+  public JSONArray put(int index, boolean value) throws JSONException {
+    return put(index, (Boolean) value);
+  }
+
+  /**
+   * Sets the value at {@code index} to {@code value}, null padding this array to the required
+   * length if necessary. If a value already exists at {@code
+   * index}, it will be replaced.
+   *
+   * @param index Where to put the value.
+   * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}.
+   * @return this array.
+   * @throws JSONException If the value is not a finite value.
+   */
+  public JSONArray put(int index, double value) throws JSONException {
+    return put(index, (Double) value);
+  }
+
+  /**
+   * Sets the value at {@code index} to {@code value}, null padding this array to the required
+   * length if necessary. If a value already exists at {@code
+   * index}, it will be replaced.
+   *
+   * @param index Where to put the value.
+   * @param value The value to set.
+   * @return this array.
+   * @throws JSONException Should never actually happen.
+   */
+  public JSONArray put(int index, int value) throws JSONException {
+    return put(index, (Integer) value);
+  }
+
+  /**
+   * Sets the value at {@code index} to {@code value}, null padding this array to the required
+   * length if necessary. If a value already exists at {@code
+   * index}, it will be replaced.
+   *
+   * @param index Where to put the value.
+   * @param value The value to set.
+   * @return this array.
+   * @throws JSONException Should never actually happen.
+   */
+  public JSONArray put(int index, long value) throws JSONException {
+    return put(index, (Long) value);
+  }
+
+  /**
+   * Sets the value at {@code index} to {@code value} wrapped into {@link JSONArray}, null padding
+   * this array to the required length if necessary. If a value already exists at {@code index}, it
+   * will be replaced.
+   *
+   * @param index Where to put the value.
+   * @param value The value to set.
+   * @return this array.
+   * @throws JSONException Should never actually happen.
+   */
+  public JSONArray put(int index, Collection<?> value) throws JSONException {
+    if (value == null) {
+      return put(index, (Object) null);
+    }
+    return put(index, new JSONArray(value));
+  }
+
+  /**
+   * Sets the value at {@code index} to {@code value}, null padding this array to the required
+   * length if necessary. If a value already exists at {@code
+   * index}, it will be replaced.
+   *
+   * @param index Where to put the value.
+   * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, Integer, Long, Double,
+   *        {@link JSONObject#NULL}, or {@code null}. May not be {@link Double#isNaN() NaNs} or
+   *        {@link Double#isInfinite() infinities}.
+   * @return this array.
+   * @throws JSONException If the value cannot be represented as a finite double value.
+   */
+  public JSONArray put(int index, Object value) throws JSONException {
+    if (value instanceof Number) {
+      // deviate from the original by checking all Numbers, not just floats & doubles
+      JSON.checkDouble(((Number) value).doubleValue());
+    }
+    while (values.size() <= index) {
+      values.add(null);
+    }
+    values.set(index, value);
+    return this;
+  }
+
+  /**
+   * Returns true if this array has no value at {@code index}, or if its value is the {@code null}
+   * reference or {@link JSONObject#NULL}.
+   *
+   * @param index Which value to check.
+   * @return true if the value is null.
+   */
+  public boolean isNull(int index) {
+    Object value = opt(index);
+    return value == null || value == JSONObject.NULL;
+  }
+
+  /**
+   * Returns the value at {@code index}.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   * @throws JSONException if this array has no value at {@code index}, or if that value is the
+   *         {@code null} reference. This method returns normally if the value is
+   *         {@code JSONObject#NULL}.
+   */
+  public Object get(int index) throws JSONException {
+    try {
+      Object value = values.get(index);
+      if (value == null) {
+        throw new JSONException("Value at " + index + " is null.");
+      }
+      return value;
+    } catch (IndexOutOfBoundsException e) {
+      throw new JSONException("Index " + index + " out of range [0.." + values.size() + ")");
+    }
+  }
+
+  /**
+   * Returns the value at {@code index}, or null if the array has no value at {@code index}.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   */
+  public Object opt(int index) {
+    if (index < 0 || index >= values.size()) {
+      return null;
+    }
+    return values.get(index);
+  }
+
+  /**
+   * Removes and returns the value at {@code index}, or null if the array has no value at
+   * {@code index}.
+   *
+   * @param index Which value to remove.
+   * @return The value previously at the specified location.
+   */
+  public Object remove(int index) {
+    if (index < 0 || index >= values.size()) {
+      return null;
+    }
+    return values.remove(index);
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a boolean or can be coerced to a
+   * boolean.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   * @throws JSONException if the value at {@code index} doesn't exist or cannot be coerced to a
+   *         boolean.
+   */
+  public boolean getBoolean(int index) throws JSONException {
+    Object object = get(index);
+    Boolean result = JSON.toBoolean(object);
+    if (result == null) {
+      throw JSON.typeMismatch(index, object, "boolean");
+    }
+    return result;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a boolean or can be coerced to a
+   * boolean. Returns false otherwise.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   */
+  public boolean optBoolean(int index) {
+    return optBoolean(index, false);
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a boolean or can be coerced to a
+   * boolean. Returns {@code fallback} otherwise.
+   *
+   * @param index Which value to get.
+   * @param fallback the fallback value to return if no value exists.
+   * @return the value at the specified location or the fallback value.
+   */
+  public boolean optBoolean(int index, boolean fallback) {
+    Object object = opt(index);
+    Boolean result = JSON.toBoolean(object);
+    return result != null ? result : fallback;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a double or can be coerced to a double.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   * @throws JSONException if the value at {@code index} doesn't exist or cannot be coerced to a
+   *         double.
+   */
+  public double getDouble(int index) throws JSONException {
+    Object object = get(index);
+    Double result = JSON.toDouble(object);
+    if (result == null) {
+      throw JSON.typeMismatch(index, object, "double");
+    }
+    return result;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a double or can be coerced to a double.
+   * Returns {@code NaN} otherwise.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   */
+  public double optDouble(int index) {
+    return optDouble(index, Double.NaN);
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a double or can be coerced to a double.
+   * Returns {@code fallback} otherwise.
+   *
+   * @param index Which value to get.
+   * @param fallback The fallback value to use if no value is at the specified location.
+   * @return the value at the specified location or the fallback value.
+   */
+  public double optDouble(int index, double fallback) {
+    Object object = opt(index);
+    Double result = JSON.toDouble(object);
+    return result != null ? result : fallback;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is an int or can be coerced to an int.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   * @throws JSONException if the value at {@code index} doesn't exist or cannot be coerced to a
+   *         int.
+   */
+  public int getInt(int index) throws JSONException {
+    Object object = get(index);
+    Integer result = JSON.toInteger(object);
+    if (result == null) {
+      throw JSON.typeMismatch(index, object, "int");
+    }
+    return result;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is an int or can be coerced to an int.
+   * Returns 0 otherwise.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   */
+  public int optInt(int index) {
+    return optInt(index, 0);
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is an int or can be coerced to an int.
+   * Returns {@code fallback} otherwise.
+   *
+   * @param index Which value to get.
+   * @param fallback The fallback value to use if no value is at the specified location.
+   * @return the value at the specified location or the fallback value.
+   */
+  public int optInt(int index, int fallback) {
+    Object object = opt(index);
+    Integer result = JSON.toInteger(object);
+    return result != null ? result : fallback;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a long or can be coerced to a long.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   * @throws JSONException if the value at {@code index} doesn't exist or cannot be coerced to a
+   *         long.
+   */
+  public long getLong(int index) throws JSONException {
+    Object object = get(index);
+    Long result = JSON.toLong(object);
+    if (result == null) {
+      throw JSON.typeMismatch(index, object, "long");
+    }
+    return result;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a long or can be coerced to a long.
+   * Returns 0 otherwise.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   */
+  public long optLong(int index) {
+    return optLong(index, 0L);
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a long or can be coerced to a long.
+   * Returns {@code fallback} otherwise.
+   *
+   * @param index Which value to get.
+   * @param fallback The fallback value to use if no value is at the specified location.
+   * @return the value at the specified location or the fallback value.
+   */
+  public long optLong(int index, long fallback) {
+    Object object = opt(index);
+    Long result = JSON.toLong(object);
+    return result != null ? result : fallback;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists, coercing it if necessary.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   * @throws JSONException if no such value exists.
+   */
+  public String getString(int index) throws JSONException {
+    Object object = get(index);
+    String result = JSON.toString(object);
+    if (result == null) {
+      throw JSON.typeMismatch(index, object, "String");
+    }
+    return result;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists, coercing it if necessary. Returns the empty
+   * string if no such value exists.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   */
+  public String optString(int index) {
+    return optString(index, "");
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists, coercing it if necessary. Returns
+   * {@code fallback} if no such value exists.
+   *
+   * @param index Which value to get.
+   * @param fallback The fallback value to use if no value is at the specified location.
+   * @return the value at the specified location or the fallback value.
+   */
+  public String optString(int index, String fallback) {
+    Object object = opt(index);
+    String result = JSON.toString(object);
+    return result != null ? result : fallback;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a {@code
+   * JSONArray}.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   * @throws JSONException if the value doesn't exist or is not a {@code
+   *                       JSONArray}.
+   */
+  public JSONArray getJSONArray(int index) throws JSONException {
+    Object object = get(index);
+    if (object instanceof JSONArray) {
+      return (JSONArray) object;
+    } else {
+      throw JSON.typeMismatch(index, object, "JSONArray");
+    }
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a {@code
+   * JSONArray}. Returns null otherwise.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   */
+  public JSONArray optJSONArray(int index) {
+    Object object = opt(index);
+    return object instanceof JSONArray ? (JSONArray) object : null;
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a {@code
+   * JSONObject}.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   * @throws JSONException if the value doesn't exist or is not a {@code
+   *                       JSONObject}.
+   */
+  public JSONObject getJSONObject(int index) throws JSONException {
+    Object object = get(index);
+    if (object instanceof JSONObject) {
+      return (JSONObject) object;
+    } else {
+      throw JSON.typeMismatch(index, object, "JSONObject");
+    }
+  }
+
+  /**
+   * Returns the value at {@code index} if it exists and is a {@code
+   * JSONObject}. Returns null otherwise.
+   *
+   * @param index Which value to get.
+   * @return the value at the specified location.
+   */
+  public JSONObject optJSONObject(int index) {
+    Object object = opt(index);
+    return object instanceof JSONObject ? (JSONObject) object : null;
+  }
+
+  /**
+   * Returns a new object whose values are the values in this array, and whose names are the values
+   * in {@code names}. Names and values are paired up by index from 0 through to the shorter array's
+   * length. Names that are not strings will be coerced to strings. This method returns null if
+   * either array is empty.
+   *
+   * @param names The names to apply to the returned values.
+   * @return the newly constructed object.
+   * @throws JSONException Should not be possible.
+   */
+  public JSONObject toJSONObject(JSONArray names) throws JSONException {
+    JSONObject result = new JSONObject();
+    int length = Math.min(names.length(), values.size());
+    if (length == 0) {
+      return null;
+    }
+    for (int i = 0; i < length; i++) {
+      String name = JSON.toString(names.opt(i));
+      result.put(name, opt(i));
+    }
+    return result;
+  }
+
+  /**
+   * Returns a new string by alternating this array's values with {@code
+   * separator}. This array's string values are quoted and have their special characters escaped.
+   * For example, the array containing the strings '12" pizza', 'taco' and 'soda' joined on '+'
+   * returns this:
+   * 
+   * <pre>
+   * "12\" pizza" + "taco" + "soda"
+   * </pre>
+   *
+   * @param separator The string used to separate the returned values.
+   * @return the conjoined values.
+   * @throws JSONException Only if there is a coding error.
+   */
+  public String join(String separator) throws JSONException {
+    JSONStringer stringer = new JSONStringer();
+    stringer.open(JSONStringer.Scope.NULL, "");
+    for (int i = 0, size = values.size(); i < size; i++) {
+      if (i > 0) {
+        stringer.out.append(separator);
+      }
+      stringer.value(values.get(i));
+    }
+    stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, "");
+    return stringer.out.toString();
+  }
+
+  /**
+   * Encodes this array as a compact JSON string, such as:
+   * 
+   * <pre>
+   * [94043,90210]
+   * </pre>
+   *
+   * @return The string form of this array.
+   */
+  @Override
+  public String toString() {
+    try {
+      JSONStringer stringer = new JSONStringer();
+      writeTo(stringer);
+      return stringer.toString();
+    } catch (JSONException e) {
+      return null;
+    }
+  }
+
+  /**
+   * Encodes this array as a human readable JSON string for debugging, such as:
+   * 
+   * <pre>
+   * [
+   *     94043,
+   *     90210
+   * ]
+   * </pre>
+   *
+   * @param indentSpaces the number of spaces to indent for each level of nesting.
+   * @return The string form of this array.
+   * @throws JSONException Only if there is a coding error.
+   */
+  public String toString(int indentSpaces) throws JSONException {
+    JSONStringer stringer = new JSONStringer(indentSpaces);
+    writeTo(stringer);
+    return stringer.toString();
+  }
+
+  void writeTo(JSONStringer stringer) throws JSONException {
+    stringer.array();
+    for (Object value : values) {
+      stringer.value(value);
+    }
+    stringer.endArray();
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    return o instanceof JSONArray && ((JSONArray) o).values.equals(values);
+  }
+
+  @Override
+  public int hashCode() {
+    // diverge from the original, which doesn't implement hashCode
+    return values.hashCode();
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/main/java/org/json/JSONException.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONException.java b/geode-json/src/main/java/org/json/JSONException.java
index 1292e86..83fb4b8 100755
--- a/geode-json/src/main/java/org/json/JSONException.java
+++ b/geode-json/src/main/java/org/json/JSONException.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -21,37 +19,40 @@ package org.json;
 /**
  * Thrown to indicate a problem with the JSON API. Such problems include:
  * <ul>
- *   <li>Attempts to parse or construct malformed documents
- *   <li>Use of null as a name
- *   <li>Use of numeric types not available to JSON, such as {@link
- *       Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}.
- *   <li>Lookups using an out of range index or nonexistent name
- *   <li>Type mismatches on lookups
+ * <li>Attempts to parse or construct malformed documents
+ * <li>Use of null as a name
+ * <li>Use of numeric types not available to JSON, such as {@link Double#isNaN() NaNs} or
+ * {@link Double#isInfinite() infinities}.
+ * <li>Lookups using an out of range index or nonexistent name
+ * <li>Type mismatches on lookups
  * </ul>
  *
- * <p>Although this is a checked exception, it is rarely recoverable. Most
- * callers should simply wrap this exception in an unchecked exception and
- * rethrow:
- * <pre>  public JSONArray toJSONObject() {
+ * <p>
+ * Although this is a checked exception, it is rarely recoverable. Most callers should simply wrap
+ * this exception in an unchecked exception and rethrow:
+ * 
+ * <pre>
+ *   public JSONArray toJSONObject() {
  *     try {
  *         JSONObject result = new JSONObject();
  *         ...
  *     } catch (JSONException e) {
  *         throw new RuntimeException(e);
  *     }
- * }</pre>
+ * }
+ * </pre>
  */
 public class JSONException extends RuntimeException {
 
-    public JSONException(String s) {
-        super(s);
-    }
+  public JSONException(String s) {
+    super(s);
+  }
 
-    public JSONException(Throwable cause) {
-        super(cause);
-    }
+  public JSONException(Throwable cause) {
+    super(cause);
+  }
 
-    public JSONException(String message, Throwable cause) {
-        super(message, cause);
-    }
+  public JSONException(String message, Throwable cause) {
+    super(message, cause);
+  }
 }


[02/51] [abbrv] geode git commit: GEODE-2142: Adding JSON library from the https://github.com/tdunning/open-json project

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/java/org/json/JSONObjectTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONObjectTest.java b/geode-json/src/test/java/org/json/JSONObjectTest.java
new file mode 100755
index 0000000..393a2d0
--- /dev/null
+++ b/geode-json/src/test/java/org/json/JSONObjectTest.java
@@ -0,0 +1,1198 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import org.junit.Test;
+
+import java.beans.IntrospectionException;
+import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.*;
+
+/**
+ * This black box test was written without inspecting the non-free org.json sourcecode.
+ */
+public class JSONObjectTest {
+    @Test
+    public void testKeyset() throws Exception {
+        JSONObject x = new JSONObject("{'a':1, 'b':2, 'c':3}");
+        Set<String> k = new TreeSet<String>();
+        for (String kx : Arrays.asList("a", "b", "c")) {
+            k.add(kx);
+        }
+        assertEquals(x.keySet(), k);
+        x = new JSONObject("{}");
+        assertEquals(x.keySet().size(), 0);
+    }
+
+    @Test
+    public void testEmptyObject() throws JSONException {
+        JSONObject object = new JSONObject();
+        assertEquals(0, object.length());
+
+        // bogus (but documented) behaviour: returns null rather than the empty object!
+        assertNull(object.names());
+
+        // returns null rather than an empty array!
+        assertNull(object.toJSONArray(new JSONArray()));
+        assertEquals("{}", object.toString());
+        assertEquals("{}", object.toString(5));
+        try {
+            object.get("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.getBoolean("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.getDouble("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.getInt("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.getJSONArray("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.getJSONObject("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.getLong("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.getString("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertFalse(object.has("foo"));
+        assertTrue(object.isNull("foo")); // isNull also means "is not present"
+        assertNull(object.opt("foo"));
+        assertEquals(false, object.optBoolean("foo"));
+        assertEquals(true, object.optBoolean("foo", true));
+        assertEquals(Double.NaN, object.optDouble("foo"), 0);
+        assertEquals(5.0, object.optDouble("foo", 5.0), 0);
+        assertEquals(0, object.optInt("foo"));
+        assertEquals(5, object.optInt("foo", 5));
+        assertEquals(null, object.optJSONArray("foo"));
+        assertEquals(null, object.optJSONObject("foo"));
+        assertEquals(0, object.optLong("foo"));
+        assertEquals(Long.MAX_VALUE - 1, object.optLong("foo", Long.MAX_VALUE - 1));
+        assertEquals("", object.optString("foo")); // empty string is default!
+        assertEquals("bar", object.optString("foo", "bar"));
+        assertNull(object.remove("foo"));
+    }
+
+    @Test
+    public void testEqualsAndHashCode() throws JSONException {
+        JSONObject a = new JSONObject();
+        JSONObject b = new JSONObject();
+
+        // JSON object doesn't override either equals or hashCode (!)
+        assertFalse(a.equals(b));
+        assertEquals(a.hashCode(), System.identityHashCode(a));
+    }
+
+    @Test
+    public void testGet() throws JSONException {
+        JSONObject object = new JSONObject();
+        Object value = new Object();
+        object.put("foo", value);
+        object.put("bar", new Object());
+        object.put("baz", new Object());
+        assertSame(value, object.get("foo"));
+        try {
+            object.get("FOO");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.put(null, value);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.get(null);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testPut() throws JSONException {
+        JSONObject object = new JSONObject();
+        assertSame(object, object.put("foo", true));
+        object.put("foo", false);
+        assertEquals(false, object.get("foo"));
+
+        object.put("foo", 5.0d);
+        assertEquals(5.0d, object.get("foo"));
+        object.put("foo", 0);
+        assertEquals(0, object.get("foo"));
+        object.put("bar", Long.MAX_VALUE - 1);
+        assertEquals(Long.MAX_VALUE - 1, object.get("bar"));
+        object.put("baz", "x");
+        assertEquals("x", object.get("baz"));
+        object.put("bar", JSONObject.NULL);
+        assertSame(JSONObject.NULL, object.get("bar"));
+    }
+
+    @Test
+    public void testPutNullRemoves() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", "bar");
+        object.put("foo", null);
+        assertEquals(0, object.length());
+        assertFalse(object.has("foo"));
+        try {
+            object.get("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testPutOpt() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", "bar");
+        object.putOpt("foo", null);
+        assertEquals("bar", object.get("foo"));
+        object.putOpt(null, null);
+        assertEquals(1, object.length());
+        object.putOpt(null, "bar");
+        assertEquals(1, object.length());
+    }
+
+    @Test
+    public void testPutOptUnsupportedNumbers() throws JSONException {
+        JSONObject object = new JSONObject();
+        try {
+            object.putOpt("foo", Double.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.putOpt("foo", Double.NEGATIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.putOpt("foo", Double.POSITIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testRemove() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", "bar");
+        assertEquals(null, object.remove(null));
+        assertEquals(null, object.remove(""));
+        assertEquals(null, object.remove("bar"));
+        assertEquals("bar", object.remove("foo"));
+        assertEquals(null, object.remove("foo"));
+    }
+
+    @Test
+    public void testBooleans() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", true);
+        object.put("bar", false);
+        object.put("baz", "true");
+        object.put("quux", "false");
+        assertEquals(4, object.length());
+        assertEquals(true, object.getBoolean("foo"));
+        assertEquals(false, object.getBoolean("bar"));
+        assertEquals(true, object.getBoolean("baz"));
+        assertEquals(false, object.getBoolean("quux"));
+        assertFalse(object.isNull("foo"));
+        assertFalse(object.isNull("quux"));
+        assertTrue(object.has("foo"));
+        assertTrue(object.has("quux"));
+        assertFalse(object.has("missing"));
+        assertEquals(true, object.optBoolean("foo"));
+        assertEquals(false, object.optBoolean("bar"));
+        assertEquals(true, object.optBoolean("baz"));
+        assertEquals(false, object.optBoolean("quux"));
+        assertEquals(false, object.optBoolean("missing"));
+        assertEquals(true, object.optBoolean("foo", true));
+        assertEquals(false, object.optBoolean("bar", true));
+        assertEquals(true, object.optBoolean("baz", true));
+        assertEquals(false, object.optBoolean("quux", true));
+        assertEquals(true, object.optBoolean("missing", true));
+
+        object.put("foo", "truE");
+        object.put("bar", "FALSE");
+        assertEquals(true, object.getBoolean("foo"));
+        assertEquals(false, object.getBoolean("bar"));
+        assertEquals(true, object.optBoolean("foo"));
+        assertEquals(false, object.optBoolean("bar"));
+        assertEquals(true, object.optBoolean("foo", false));
+        assertEquals(false, object.optBoolean("bar", false));
+    }
+
+    // http://code.google.com/p/android/issues/detail?id=16411
+    @Test
+    public void testCoerceStringToBoolean() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", "maybe");
+        try {
+            object.getBoolean("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals(false, object.optBoolean("foo"));
+        assertEquals(true, object.optBoolean("foo", true));
+    }
+
+    @Test
+    public void testNumbers() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", Double.MIN_VALUE);
+        object.put("bar", 9223372036854775806L);
+        object.put("baz", Double.MAX_VALUE);
+        object.put("quux", -0d);
+        assertEquals(4, object.length());
+
+        String toString = object.toString();
+        assertTrue(toString, toString.contains("\"foo\":4.9E-324"));
+        assertTrue(toString, toString.contains("\"bar\":9223372036854775806"));
+        assertTrue(toString, toString.contains("\"baz\":1.7976931348623157E308"));
+
+        // toString() and getString() return different values for -0d!
+        assertTrue(toString, toString.contains("\"quux\":-0}") // no trailing decimal point
+                || toString.contains("\"quux\":-0,"));
+
+        assertEquals(Double.MIN_VALUE, object.get("foo"));
+        assertEquals(9223372036854775806L, object.get("bar"));
+        assertEquals(Double.MAX_VALUE, object.get("baz"));
+        assertEquals(-0d, object.get("quux"));
+        assertEquals(Double.MIN_VALUE, object.getDouble("foo"), 0);
+        assertEquals(9.223372036854776E18, object.getDouble("bar"), 0);
+        assertEquals(Double.MAX_VALUE, object.getDouble("baz"), 0);
+        assertEquals(-0d, object.getDouble("quux"), 0);
+        assertEquals(0, object.getLong("foo"));
+        assertEquals(9223372036854775806L, object.getLong("bar"));
+        assertEquals(Long.MAX_VALUE, object.getLong("baz"));
+        assertEquals(0, object.getLong("quux"));
+        assertEquals(0, object.getInt("foo"));
+        assertEquals(-2, object.getInt("bar"));
+        assertEquals(Integer.MAX_VALUE, object.getInt("baz"));
+        assertEquals(0, object.getInt("quux"));
+        assertEquals(Double.MIN_VALUE, object.opt("foo"));
+        assertEquals(9223372036854775806L, object.optLong("bar"));
+        assertEquals(Double.MAX_VALUE, object.optDouble("baz"), 0);
+        assertEquals(0, object.optInt("quux"));
+        assertEquals(Double.MIN_VALUE, object.opt("foo"));
+        assertEquals(9223372036854775806L, object.optLong("bar"));
+        assertEquals(Double.MAX_VALUE, object.optDouble("baz"), 0);
+        assertEquals(0, object.optInt("quux"));
+        assertEquals(Double.MIN_VALUE, object.optDouble("foo", 5.0d), 0);
+        assertEquals(9223372036854775806L, object.optLong("bar", 1L));
+        assertEquals(Long.MAX_VALUE, object.optLong("baz", 1L));
+        assertEquals(0, object.optInt("quux", -1));
+        assertEquals("4.9E-324", object.getString("foo"));
+        assertEquals("9223372036854775806", object.getString("bar"));
+        assertEquals("1.7976931348623157E308", object.getString("baz"));
+        assertEquals("-0.0", object.getString("quux"));
+    }
+
+    @Test
+    public void testFloats() throws JSONException {
+        JSONObject object = new JSONObject();
+        try {
+            object.put("foo", (Float) Float.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.put("foo", (Float) Float.NEGATIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.put("foo", (Float) Float.POSITIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testOtherNumbers() throws JSONException {
+        Number nan = new Number() {
+            public int intValue() {
+                throw new UnsupportedOperationException();
+            }
+
+            public long longValue() {
+                throw new UnsupportedOperationException();
+            }
+
+            public float floatValue() {
+                throw new UnsupportedOperationException();
+            }
+
+            public double doubleValue() {
+                return Double.NaN;
+            }
+
+            @Override
+            public String toString() {
+                return "x";
+            }
+        };
+
+        JSONObject object = new JSONObject();
+        try {
+            object.put("foo", nan);
+            fail("Object.put() accepted a NaN (via a custom Number class)");
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testForeignObjects() throws JSONException {
+        Object foreign = new Object() {
+            @Override
+            public String toString() {
+                return "x";
+            }
+        };
+
+        // foreign object types are accepted and treated as Strings!
+        JSONObject object = new JSONObject();
+        object.put("foo", foreign);
+        assertEquals("{\"foo\":\"x\"}", object.toString());
+    }
+
+    @Test
+    public void testNullKeys() {
+        try {
+            new JSONObject().put(null, false);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONObject().put(null, 0.0d);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONObject().put(null, 5);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONObject().put(null, 5L);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONObject().put(null, "foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testStrings() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", "true");
+        object.put("bar", "5.5");
+        object.put("baz", "9223372036854775806");
+        object.put("quux", "null");
+        object.put("height", "5\"8' tall");
+
+        assertTrue(object.toString().contains("\"foo\":\"true\""));
+        assertTrue(object.toString().contains("\"bar\":\"5.5\""));
+        assertTrue(object.toString().contains("\"baz\":\"9223372036854775806\""));
+        assertTrue(object.toString().contains("\"quux\":\"null\""));
+        assertTrue(object.toString().contains("\"height\":\"5\\\"8' tall\""));
+
+        assertEquals("true", object.get("foo"));
+        assertEquals("null", object.getString("quux"));
+        assertEquals("5\"8' tall", object.getString("height"));
+        assertEquals("true", object.opt("foo"));
+        assertEquals("5.5", object.optString("bar"));
+        assertEquals("true", object.optString("foo", "x"));
+        assertFalse(object.isNull("foo"));
+
+        assertEquals(true, object.getBoolean("foo"));
+        assertEquals(true, object.optBoolean("foo"));
+        assertEquals(true, object.optBoolean("foo", false));
+        assertEquals(0, object.optInt("foo"));
+        assertEquals(-2, object.optInt("foo", -2));
+
+        assertEquals(5.5d, object.getDouble("bar"), 0);
+        assertEquals(5L, object.getLong("bar"));
+        assertEquals(5, object.getInt("bar"));
+        assertEquals(5, object.optInt("bar", 3));
+
+        // The last digit of the string is a 6 but getLong returns a 7. It's probably parsing as a
+        // double and then converting that to a long. This is consistent with JavaScript.
+        assertEquals(9223372036854775807L, object.getLong("baz"));
+        assertEquals(9.223372036854776E18, object.getDouble("baz"), 0);
+        assertEquals(Integer.MAX_VALUE, object.getInt("baz"));
+
+        assertFalse(object.isNull("quux"));
+        try {
+            object.getDouble("quux");
+            fail();
+        } catch (JSONException e) {
+            // expected
+        }
+        assertEquals(Double.NaN, object.optDouble("quux"), 0);
+        assertEquals(-1.0d, object.optDouble("quux", -1.0d), 0);
+
+        object.put("foo", "TRUE");
+        assertEquals(true, object.getBoolean("foo"));
+    }
+
+    @Test
+    public void testJSONObjects() throws JSONException {
+        JSONObject object = new JSONObject();
+
+        JSONArray a = new JSONArray();
+        JSONObject b = new JSONObject();
+        object.put("foo", a);
+        object.put("bar", b);
+
+        assertSame(a, object.getJSONArray("foo"));
+        assertSame(b, object.getJSONObject("bar"));
+        try {
+            object.getJSONObject("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.getJSONArray("bar");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals(a, object.optJSONArray("foo"));
+        assertEquals(b, object.optJSONObject("bar"));
+        assertEquals(null, object.optJSONArray("bar"));
+        assertEquals(null, object.optJSONObject("foo"));
+    }
+
+    @Test
+    public void testNullCoercionToString() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", JSONObject.NULL);
+        assertEquals("null", object.getString("foo"));
+    }
+
+    @Test
+    public void testArrayCoercion() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", "[true]");
+        try {
+            object.getJSONArray("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testObjectCoercion() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", "{}");
+        try {
+            object.getJSONObject("foo");
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testAccumulateValueChecking() throws JSONException {
+        JSONObject object = new JSONObject();
+        try {
+            object.accumulate("foo", Double.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        object.accumulate("foo", 1);
+        try {
+            object.accumulate("foo", Double.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        object.accumulate("foo", 2);
+        try {
+            object.accumulate("foo", Double.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testToJSONArray() throws JSONException {
+        JSONObject object = new JSONObject();
+        Object value = new Object();
+        object.put("foo", true);
+        object.put("bar", 5.0d);
+        object.put("baz", -0.0d);
+        object.put("quux", value);
+
+        JSONArray names = new JSONArray();
+        names.put("baz");
+        names.put("quux");
+        names.put("foo");
+
+        JSONArray array = object.toJSONArray(names);
+        assertEquals(-0.0d, array.get(0));
+        assertEquals(value, array.get(1));
+        assertEquals(true, array.get(2));
+
+        object.put("foo", false);
+        assertEquals(true, array.get(2));
+    }
+
+    @Test
+    public void testToJSONArrayMissingNames() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", true);
+        object.put("bar", 5.0d);
+        object.put("baz", JSONObject.NULL);
+
+        JSONArray names = new JSONArray();
+        names.put("bar");
+        names.put("foo");
+        names.put("quux");
+        names.put("baz");
+
+        JSONArray array = object.toJSONArray(names);
+        assertEquals(4, array.length());
+
+        assertEquals(5.0d, array.get(0));
+        assertEquals(true, array.get(1));
+        try {
+            array.get(2);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals(JSONObject.NULL, array.get(3));
+    }
+
+    @Test
+    public void testToJSONArrayNull() throws JSONException {
+        JSONObject object = new JSONObject();
+        assertEquals(null, object.toJSONArray(null));
+        object.put("foo", 5);
+        try {
+            object.toJSONArray(null);
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testToJSONArrayEndsUpEmpty() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", 5);
+        JSONArray array = new JSONArray();
+        array.put("bar");
+        assertEquals(1, object.toJSONArray(array).length());
+    }
+
+    @Test
+    public void testToJSONArrayNonString() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", 5);
+        object.put("null", 10);
+        object.put("false", 15);
+
+        JSONArray names = new JSONArray();
+        names.put(JSONObject.NULL);
+        names.put(false);
+        names.put("foo");
+
+        // array elements are converted to strings to do name lookups on the map!
+        JSONArray array = object.toJSONArray(names);
+        assertEquals(3, array.length());
+        assertEquals(10, array.get(0));
+        assertEquals(15, array.get(1));
+        assertEquals(5, array.get(2));
+    }
+
+    @Test
+    public void testPutUnsupportedNumbers() throws JSONException {
+        JSONObject object = new JSONObject();
+        try {
+            object.put("foo", Double.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.put("foo", Double.NEGATIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.put("foo", Double.POSITIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testPutUnsupportedNumbersAsObjects() throws JSONException {
+        JSONObject object = new JSONObject();
+        try {
+            object.put("foo", (Double) Double.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.put("foo", (Double) Double.NEGATIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            object.put("foo", (Double) Double.POSITIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    /**
+     * Although JSONObject is usually defensive about which numbers it accepts,
+     * it doesn't check inputs in its constructor.
+     */
+    @Test
+    public void testCreateWithUnsupportedNumbers() throws JSONException {
+        Map<String, Object> contents = new HashMap<String, Object>();
+        contents.put("foo", Double.NaN);
+        contents.put("bar", Double.NEGATIVE_INFINITY);
+        contents.put("baz", Double.POSITIVE_INFINITY);
+
+        JSONObject object = new JSONObject(contents);
+        assertEquals(Double.NaN, object.get("foo"));
+        assertEquals(Double.NEGATIVE_INFINITY, object.get("bar"));
+        assertEquals(Double.POSITIVE_INFINITY, object.get("baz"));
+    }
+
+    @Test
+    public void testToStringWithUnsupportedNumbers() {
+        // when the object contains an unsupported number, toString returns null!
+        JSONObject object = new JSONObject(Collections.singletonMap("foo", Double.NaN));
+        assertEquals(null, object.toString());
+    }
+
+    @Test
+    public void testMapConstructorCopiesContents() throws JSONException {
+        Map<String, Object> contents = new HashMap<String, Object>();
+        contents.put("foo", 5);
+        JSONObject object = new JSONObject(contents);
+        contents.put("foo", 10);
+        assertEquals(5, object.get("foo"));
+    }
+
+    @Test
+    public void testMapConstructorWithBogusEntries() {
+        Map<Object, Object> contents = new HashMap<Object, Object>();
+        contents.put(5, 5);
+
+        try {
+            new JSONObject(contents);
+            fail("JSONObject constructor doesn't validate its input!");
+        } catch (Exception ignored) {
+        }
+    }
+
+    @Test
+    public void testTokenerConstructor() throws JSONException {
+        JSONObject object = new JSONObject(new JSONTokener("{\"foo\": false}"));
+        assertEquals(1, object.length());
+        assertEquals(false, object.get("foo"));
+    }
+
+    @Test
+    public void testTokenerConstructorWrongType() throws JSONException {
+        try {
+            new JSONObject(new JSONTokener("[\"foo\", false]"));
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testTokenerConstructorNull() throws JSONException {
+        try {
+            new JSONObject((JSONTokener) null);
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+    }
+
+    @Test
+    public void testTokenerConstructorParseFail() {
+        try {
+            new JSONObject(new JSONTokener("{"));
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testStringConstructor() throws JSONException {
+        JSONObject object = new JSONObject("{\"foo\": false}");
+        assertEquals(1, object.length());
+        assertEquals(false, object.get("foo"));
+    }
+
+    @Test
+    public void testStringConstructorWrongType() throws JSONException {
+        try {
+            new JSONObject("[\"foo\", false]");
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testStringConstructorNull() throws JSONException {
+        try {
+            new JSONObject((String) null);
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+    }
+
+    @Test
+    public void testStringConstructorParseFail() {
+        try {
+            new JSONObject("{");
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testCopyConstructor() throws JSONException {
+        JSONObject source = new JSONObject();
+        source.put("a", JSONObject.NULL);
+        source.put("b", false);
+        source.put("c", 5);
+
+        JSONObject copy = new JSONObject(source, new String[]{"a", "c"});
+        assertEquals(2, copy.length());
+        assertEquals(JSONObject.NULL, copy.get("a"));
+        assertEquals(5, copy.get("c"));
+        assertEquals(null, copy.opt("b"));
+    }
+
+    @Test
+    public void testCopyConstructorMissingName() throws JSONException {
+        JSONObject source = new JSONObject();
+        source.put("a", JSONObject.NULL);
+        source.put("b", false);
+        source.put("c", 5);
+
+        JSONObject copy = new JSONObject(source, new String[]{"a", "c", "d"});
+        assertEquals(2, copy.length());
+        assertEquals(JSONObject.NULL, copy.get("a"));
+        assertEquals(5, copy.get("c"));
+        assertEquals(0, copy.optInt("b"));
+    }
+
+    @Test
+    public void testAccumulateMutatesInPlace() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", 5);
+        object.accumulate("foo", 6);
+        JSONArray array = object.getJSONArray("foo");
+        assertEquals("[5,6]", array.toString());
+        object.accumulate("foo", 7);
+        assertEquals("[5,6,7]", array.toString());
+    }
+
+    @Test
+    public void testAccumulateExistingArray() throws JSONException {
+        JSONArray array = new JSONArray();
+        JSONObject object = new JSONObject();
+        object.put("foo", array);
+        object.accumulate("foo", 5);
+        assertEquals("[5]", array.toString());
+    }
+
+    @Test
+    public void testAccumulatePutArray() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.accumulate("foo", 5);
+        assertEquals("{\"foo\":5}", object.toString());
+        object.accumulate("foo", new JSONArray());
+        assertEquals("{\"foo\":[5,[]]}", object.toString());
+    }
+
+    @Test
+    public void testAccumulateNull() {
+        JSONObject object = new JSONObject();
+        try {
+            object.accumulate(null, 5);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testEmptyStringKey() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("", 5);
+        assertEquals(5, object.get(""));
+        assertEquals("{\"\":5}", object.toString());
+    }
+
+    @Test
+    public void testNullValue() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", JSONObject.NULL);
+        object.put("bar", null);
+
+        // there are two ways to represent null; each behaves differently!
+        assertTrue(object.has("foo"));
+        assertFalse(object.has("bar"));
+        assertTrue(object.isNull("foo"));
+        assertTrue(object.isNull("bar"));
+    }
+
+    @Test
+    public void testNullValue_equalsAndHashCode() {
+        //noinspection ObjectEqualsNull
+        assertTrue(JSONObject.NULL.equals(null)); // guaranteed by javadoc
+        // not guaranteed by javadoc, but seems like a good idea
+        assertEquals(Objects.hashCode(null), JSONObject.NULL.hashCode());
+    }
+
+    @Test
+    public void testHas() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", 5);
+        assertTrue(object.has("foo"));
+        assertFalse(object.has("bar"));
+        assertFalse(object.has(null));
+    }
+
+    @Test
+    public void testOptNull() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", "bar");
+        assertEquals(null, object.opt(null));
+        assertEquals(false, object.optBoolean(null));
+        assertEquals(Double.NaN, object.optDouble(null), 0);
+        assertEquals(0, object.optInt(null));
+        assertEquals(0L, object.optLong(null));
+        assertEquals(null, object.optJSONArray(null));
+        assertEquals(null, object.optJSONObject(null));
+        assertEquals("", object.optString(null));
+        assertEquals(true, object.optBoolean(null, true));
+        assertEquals(0.0d, object.optDouble(null, 0.0d), 0);
+        assertEquals(1, object.optInt(null, 1));
+        assertEquals(1L, object.optLong(null, 1L));
+        assertEquals("baz", object.optString(null, "baz"));
+    }
+
+    @Test
+    public void testToStringWithIndentFactor() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", new JSONArray(Arrays.asList(5, 6)));
+        object.put("bar", new JSONObject());
+        String foobar = "{\n" +
+                "     \"foo\": [\n" +
+                "          5,\n" +
+                "          6\n" +
+                "     ],\n" +
+                "     \"bar\": {}\n" +
+                "}";
+        String barfoo = "{\n" +
+                "     \"bar\": {},\n" +
+                "     \"foo\": [\n" +
+                "          5,\n" +
+                "          6\n" +
+                "     ]\n" +
+                "}";
+        String string = object.toString(5);
+        assertTrue(string, foobar.equals(string) || barfoo.equals(string));
+    }
+
+    @Test
+    public void testNames() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", 5);
+        object.put("bar", 6);
+        object.put("baz", 7);
+        JSONArray array = object.names();
+        assertTrue(array.toString().contains("foo"));
+        assertTrue(array.toString().contains("bar"));
+        assertTrue(array.toString().contains("baz"));
+    }
+
+    @Test
+    public void testKeysEmptyObject() {
+        JSONObject object = new JSONObject();
+        assertFalse(object.keys().hasNext());
+        try {
+            object.keys().next();
+            fail();
+        } catch (NoSuchElementException ignored) {
+        }
+    }
+
+    @Test
+    public void testKeys() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", 5);
+        object.put("bar", 6);
+        object.put("foo", 7);
+
+        @SuppressWarnings("unchecked")
+        Iterator<String> keys = object.keys();
+        Set<String> result = new HashSet<String>();
+        assertTrue(keys.hasNext());
+        result.add(keys.next());
+        assertTrue(keys.hasNext());
+        result.add(keys.next());
+        assertFalse(keys.hasNext());
+        assertEquals(new HashSet<String>(Arrays.asList("foo", "bar")), result);
+
+        try {
+            keys.next();
+            fail();
+        } catch (NoSuchElementException ignored) {
+        }
+    }
+
+    @Test
+    public void testMutatingKeysMutatesObject() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", 5);
+        Iterator keys = object.keys();
+        keys.next();
+        keys.remove();
+        assertEquals(0, object.length());
+    }
+
+    @Test
+    public void testQuote() {
+        // covered by JSONStringerTest.testEscaping
+    }
+
+    @Test
+    public void testQuoteNull() throws JSONException {
+        assertEquals("\"\"", JSONObject.quote(null));
+    }
+
+    @Test
+    public void testNumberToString() throws JSONException {
+        assertEquals("5", JSONObject.numberToString(5));
+        assertEquals("-0", JSONObject.numberToString(-0.0d));
+        assertEquals("9223372036854775806", JSONObject.numberToString(9223372036854775806L));
+        assertEquals("4.9E-324", JSONObject.numberToString(Double.MIN_VALUE));
+        assertEquals("1.7976931348623157E308", JSONObject.numberToString(Double.MAX_VALUE));
+        try {
+            JSONObject.numberToString(Double.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            JSONObject.numberToString(Double.NEGATIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            JSONObject.numberToString(Double.POSITIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals("0.001", JSONObject.numberToString(new BigDecimal("0.001")));
+        assertEquals("9223372036854775806",
+                JSONObject.numberToString(new BigInteger("9223372036854775806")));
+        try {
+            JSONObject.numberToString(null);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void test_wrap() throws Exception {
+        assertEquals(JSONObject.NULL, JSONObject.wrap(null));
+
+        JSONArray a = new JSONArray();
+        assertEquals(a, JSONObject.wrap(a));
+
+        JSONObject o = new JSONObject();
+        assertEquals(o, JSONObject.wrap(o));
+
+        assertEquals(JSONObject.NULL, JSONObject.wrap(JSONObject.NULL));
+
+        assertTrue(JSONObject.wrap(new byte[0]) instanceof JSONArray);
+        assertTrue(JSONObject.wrap(new ArrayList<String>()) instanceof JSONArray);
+        assertTrue(JSONObject.wrap(new HashMap<String, String>()) instanceof JSONObject);
+        assertTrue(JSONObject.wrap(0.0) instanceof Double);
+        assertTrue(JSONObject.wrap("hello") instanceof String);
+    }
+
+    // https://code.google.com/p/android/issues/detail?id=55114
+    @Test
+    public void test_toString_listAsMapValue() throws Exception {
+        ArrayList<Object> list = new ArrayList<Object>();
+        list.add("a");
+        list.add(new ArrayList<String>());
+        Map<String, Object> map = new TreeMap<String, Object>();
+        map.put("x", "l");
+        map.put("y", list);
+        assertEquals("{\"x\":\"l\",\"y\":[\"a\",[]]}", new JSONObject(map).toString());
+    }
+
+    @Test
+    public void testAppendExistingInvalidKey() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("foo", 5);
+        try {
+            object.append("foo", 6);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testAppendExistingArray() throws JSONException {
+        JSONArray array = new JSONArray();
+        JSONObject object = new JSONObject();
+        object.put("foo", array);
+        object.append("foo", 5);
+        assertEquals("[5]", array.toString());
+    }
+
+    @Test
+    public void testAppendPutArray() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.append("foo", 5);
+        assertEquals("{\"foo\":[5]}", object.toString());
+        object.append("foo", new JSONArray());
+        assertEquals("{\"foo\":[5,[]]}", object.toString());
+    }
+
+    @Test
+    public void testAppendNull() {
+        JSONObject object = new JSONObject();
+        try {
+            object.append(null, 5);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    // https://code.google.com/p/android/issues/detail?id=103641
+    @Test
+    public void testInvalidUnicodeEscape() {
+        try {
+            new JSONObject("{\"q\":\"\\u\", \"r\":[]}");
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testBeanThings() throws IllegalAccessException, IntrospectionException, InvocationTargetException {
+        Foo f = new Foo();
+        assertEquals("{\"a\":1,\"b\":1,\"c\":\"c\",\"d\":[{\"e\":\"echo\"}]}", new JSONObject(f).toString());
+    }
+
+    @Test
+    public void testGetNames() throws Exception {
+        assertArrayEquals(new String[]{"a", "b", "c", "d"}, JSONObject.getNames(new JSONObject(new Foo())));
+    }
+
+    private static class Foo {
+        public double getA() {
+            return 1.0;
+        }
+
+        public int getB() {
+            return 1;
+        }
+
+        public String getC() {
+            return "c";
+        }
+
+        public List<Bar> getD() {
+            ArrayList<Bar> r = new ArrayList<Bar>();
+            r.add(new Bar());
+            return r;
+        }
+    }
+
+    private static class Bar {
+        public String getE() {
+            return "echo";
+        }
+    }
+
+    @Test
+    public void testEnumWrapper() throws Exception {
+        Object y = JSONObject.wrap(E.A);
+        assertEquals("A", y);
+        assertTrue(y instanceof String);
+    }
+
+    enum E {
+        A {
+            int key() {
+                return 1;
+            }
+        }, B {
+            int key() {
+                return 2;
+            }
+        };
+        int key() {
+            return -1;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/java/org/json/JSONStringerTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONStringerTest.java b/geode-json/src/test/java/org/json/JSONStringerTest.java
new file mode 100755
index 0000000..7c7362d
--- /dev/null
+++ b/geode-json/src/test/java/org/json/JSONStringerTest.java
@@ -0,0 +1,421 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import org.junit.Test;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.*;
+
+/**
+ * This black box test was written without inspecting the non-free org.json sourcecode.
+ */
+public class JSONStringerTest {
+
+    @Test
+    public void testJSONFunctionHackTest() {
+        JSONStringer stringer = new JSONStringer();
+        stringer.object();
+        stringer.key("key");
+        stringer.value(new JSONFunctionTestObject("window.test('foo' + \"bar\")"));
+        stringer.endObject();
+        assertEquals("{\"key\":window.test('foo' + \"bar\")}", stringer.toString());
+    }
+
+    @Test
+    public void testEmptyStringer() {
+        // why isn't this the empty string?
+        assertNull(new JSONStringer().toString());
+    }
+
+    @Test
+    public void testValueJSONNull() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.array();
+        stringer.value(JSONObject.NULL);
+        stringer.endArray();
+        assertEquals("[null]", stringer.toString());
+    }
+
+    @Test
+    public void testEmptyObject() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.object();
+        stringer.endObject();
+        assertEquals("{}", stringer.toString());
+    }
+
+    @Test
+    public void testEmptyArray() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.array();
+        stringer.endArray();
+        assertEquals("[]", stringer.toString());
+    }
+
+    @Test
+    public void testArray() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.array();
+        stringer.value(false);
+        stringer.value(5.0);
+        stringer.value(5L);
+        stringer.value("five");
+        stringer.value(null);
+        stringer.endArray();
+        assertEquals("[false,5,5,\"five\",null]", stringer.toString());
+    }
+
+    @Test
+    public void testValueObjectMethods() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.array();
+        stringer.value(Boolean.FALSE);
+        stringer.value(Double.valueOf(5.0));
+        stringer.value(Long.valueOf(5L));
+        stringer.endArray();
+        assertEquals("[false,5,5]", stringer.toString());
+    }
+
+    @Test
+    public void testKeyValue() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.object();
+        stringer.key("a").value(false);
+        stringer.key("b").value(5.0);
+        stringer.key("c").value(5L);
+        stringer.key("d").value("five");
+        stringer.key("e").value(null);
+        stringer.endObject();
+        assertEquals("{\"a\":false," +
+                "\"b\":5," +
+                "\"c\":5," +
+                "\"d\":\"five\"," +
+                "\"e\":null}", stringer.toString());
+    }
+
+    /**
+     * Test what happens when extreme values are emitted. Such values are likely
+     * to be rounded during parsing.
+     */
+    @Test
+    public void testNumericRepresentations() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.array();
+        stringer.value(Long.MAX_VALUE);
+        stringer.value(Double.MIN_VALUE);
+        stringer.endArray();
+        assertEquals("[9223372036854775807,4.9E-324]", stringer.toString());
+    }
+
+    @Test
+    public void testWeirdNumbers() throws JSONException {
+        try {
+            new JSONStringer().array().value(Double.NaN);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().array().value(Double.NEGATIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().array().value(Double.POSITIVE_INFINITY);
+            fail();
+        } catch (JSONException ignored) {
+        }
+
+        JSONStringer stringer = new JSONStringer();
+        stringer.array();
+        stringer.value(-0.0d);
+        stringer.value(0.0d);
+        stringer.endArray();
+        assertEquals("[-0,0]", stringer.toString());
+    }
+
+    @Test
+    public void testMismatchedScopes() {
+        try {
+            new JSONStringer().key("a");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().value("a");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().endObject();
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().endArray();
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().array().endObject();
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().object().endArray();
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().object().key("a").key("a");
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONStringer().object().value(false);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testNullKey() {
+        try {
+            new JSONStringer().object().key(null);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testRepeatedKey() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.object();
+        stringer.key("a").value(true);
+        stringer.key("a").value(false);
+        stringer.endObject();
+        // JSONStringer doesn't attempt to detect duplicates
+        assertEquals("{\"a\":true,\"a\":false}", stringer.toString());
+    }
+
+    @Test
+    public void testEmptyKey() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.object();
+        stringer.key("").value(false);
+        stringer.endObject();
+        assertEquals("{\"\":false}", stringer.toString()); // legit behaviour!
+    }
+
+    @Test
+    public void testEscaping() throws JSONException {
+        assertEscapedAllWays("a", "a");
+        assertEscapedAllWays("a\\\"", "a\"");
+        assertEscapedAllWays("\\\"", "\"");
+        assertEscapedAllWays(":", ":");
+        assertEscapedAllWays(",", ",");
+        assertEscapedAllWays("\\b", "\b");
+        assertEscapedAllWays("\\f", "\f");
+        assertEscapedAllWays("\\n", "\n");
+        assertEscapedAllWays("\\r", "\r");
+        assertEscapedAllWays("\\t", "\t");
+        assertEscapedAllWays(" ", " ");
+        assertEscapedAllWays("\\\\", "\\");
+        assertEscapedAllWays("{", "{");
+        assertEscapedAllWays("}", "}");
+        assertEscapedAllWays("[", "[");
+        assertEscapedAllWays("]", "]");
+        assertEscapedAllWays("\\u0000", "\0");
+        assertEscapedAllWays("\\u0019", "\u0019");
+        assertEscapedAllWays(" ", "\u0020");
+        assertEscapedAllWays("<\\/foo>", "</foo>");
+    }
+
+    private void assertEscapedAllWays(String escaped, String original) throws JSONException {
+        assertEquals("{\"" + escaped + "\":false}",
+                new JSONStringer().object().key(original).value(false).endObject().toString());
+        assertEquals("{\"a\":\"" + escaped + "\"}",
+                new JSONStringer().object().key("a").value(original).endObject().toString());
+        assertEquals("[\"" + escaped + "\"]",
+                new JSONStringer().array().value(original).endArray().toString());
+        assertEquals("\"" + escaped + "\"", JSONObject.quote(original));
+    }
+
+    @Test
+    public void testJSONArrayAsValue() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put(false);
+        JSONStringer stringer = new JSONStringer();
+        stringer.array();
+        stringer.value(array);
+        stringer.endArray();
+        assertEquals("[[false]]", stringer.toString());
+    }
+
+    @Test
+    public void testJSONObjectAsValue() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("a", false);
+        JSONStringer stringer = new JSONStringer();
+        stringer.object();
+        stringer.key("b").value(object);
+        stringer.endObject();
+        assertEquals("{\"b\":{\"a\":false}}", stringer.toString());
+    }
+
+    @Test
+    public void testArrayNestingMaxDepthSupports20() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        for (int i = 0; i < 20; i++) {
+            stringer.array();
+        }
+        for (int i = 0; i < 20; i++) {
+            stringer.endArray();
+        }
+        assertEquals("[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]", stringer.toString());
+
+        stringer = new JSONStringer();
+        for (int i = 0; i < 20; i++) {
+            stringer.array();
+        }
+    }
+
+    @Test
+    public void testObjectNestingMaxDepthSupports20() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        for (int i = 0; i < 20; i++) {
+            stringer.object();
+            stringer.key("a");
+        }
+        stringer.value(false);
+        for (int i = 0; i < 20; i++) {
+            stringer.endObject();
+        }
+        assertEquals("{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":" +
+                "{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":false" +
+                "}}}}}}}}}}}}}}}}}}}}", stringer.toString());
+
+        stringer = new JSONStringer();
+        for (int i = 0; i < 20; i++) {
+            stringer.object();
+            stringer.key("a");
+        }
+    }
+
+    @Test
+    public void testMixedMaxDepthSupports20() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        for (int i = 0; i < 20; i += 2) {
+            stringer.array();
+            stringer.object();
+            stringer.key("a");
+        }
+        stringer.value(false);
+        for (int i = 0; i < 20; i += 2) {
+            stringer.endObject();
+            stringer.endArray();
+        }
+        assertEquals("[{\"a\":[{\"a\":[{\"a\":[{\"a\":[{\"a\":" +
+                "[{\"a\":[{\"a\":[{\"a\":[{\"a\":[{\"a\":false" +
+                "}]}]}]}]}]}]}]}]}]}]", stringer.toString());
+
+        stringer = new JSONStringer();
+        for (int i = 0; i < 20; i += 2) {
+            stringer.array();
+            stringer.object();
+            stringer.key("a");
+        }
+    }
+
+    @Test
+    public void testMaxDepthWithArrayValue() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put(false);
+
+        JSONStringer stringer = new JSONStringer();
+        for (int i = 0; i < 20; i++) {
+            stringer.array();
+        }
+        stringer.value(array);
+        for (int i = 0; i < 20; i++) {
+            stringer.endArray();
+        }
+        assertEquals("[[[[[[[[[[[[[[[[[[[[[false]]]]]]]]]]]]]]]]]]]]]", stringer.toString());
+    }
+
+    @Test
+    public void testMaxDepthWithObjectValue() throws JSONException {
+        JSONObject object = new JSONObject();
+        object.put("a", false);
+        JSONStringer stringer = new JSONStringer();
+        for (int i = 0; i < 20; i++) {
+            stringer.object();
+            stringer.key("b");
+        }
+        stringer.value(object);
+        for (int i = 0; i < 20; i++) {
+            stringer.endObject();
+        }
+        assertEquals("{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":" +
+                "{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":{\"b\":" +
+                "{\"a\":false}}}}}}}}}}}}}}}}}}}}}", stringer.toString());
+    }
+
+    @Test
+    public void testMultipleRoots() throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.array();
+        stringer.endArray();
+        try {
+            stringer.object();
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testEnums() {
+        JSONObject x = new JSONObject();
+        x.put("a", TimeUnit.SECONDS);
+        x.put("b", "xyx");
+        JSONStringer s = new JSONStringer();
+        s.array();
+        s.value(x);
+        s.endArray();
+        assertEquals("[{\"a\":\"SECONDS\",\"b\":\"xyx\"}]", s.toString());
+    }
+
+    @Test
+    public void testJsonString() {
+        JSONObject x = new JSONObject();
+        x.put("a", new Goo());
+        JSONStringer s = new JSONStringer();
+        s.array();
+        s.value(x);
+        s.endArray();
+        // note lack of quotes
+        assertEquals("[{\"a\":fffooo}]", s.toString());
+    }
+
+    private static class Goo implements JSONString {
+        @Override
+        public String toJSONString() {
+            return "fffooo";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/java/org/json/JSONTokenerTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONTokenerTest.java b/geode-json/src/test/java/org/json/JSONTokenerTest.java
new file mode 100755
index 0000000..9975177
--- /dev/null
+++ b/geode-json/src/test/java/org/json/JSONTokenerTest.java
@@ -0,0 +1,621 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+/**
+ * This black box test was written without inspecting the non-free org.json sourcecode.
+ */
+public class JSONTokenerTest extends TestCase {
+
+    public void testNulls() throws JSONException {
+        // JSONTokener accepts null, only to fail later on almost all APIs!
+        new JSONTokener((String) null).back();
+
+        try {
+            new JSONTokener((String) null).more();
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).next();
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).next(3);
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).next('A');
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).nextClean();
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).nextString('"');
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).nextTo('A');
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).nextTo("ABC");
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).nextValue();
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).skipPast("ABC");
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        try {
+            new JSONTokener((String) null).skipTo('A');
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+
+        //noinspection ThrowableResultOfMethodCallIgnored
+        assertEquals("foo! at character 0 of null",
+                new JSONTokener((String) null).syntaxError("foo!").getMessage());
+
+        assertEquals(" at character 0 of null", new JSONTokener((String) null).toString());
+    }
+
+    public void testEmptyString() throws JSONException {
+        JSONTokener backTokener = new JSONTokener("");
+        backTokener.back();
+        assertEquals(" at character 0 of ", backTokener.toString());
+        assertFalse(new JSONTokener("").more());
+        assertEquals('\0', new JSONTokener("").next());
+        try {
+            new JSONTokener("").next(3);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONTokener("").next('A');
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals('\0', new JSONTokener("").nextClean());
+        try {
+            new JSONTokener("").nextString('"');
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals("", new JSONTokener("").nextTo('A'));
+        assertEquals("", new JSONTokener("").nextTo("ABC"));
+        try {
+            new JSONTokener("").nextValue();
+            fail();
+        } catch (JSONException ignored) {
+        }
+        new JSONTokener("").skipPast("ABC");
+        assertEquals('\0', new JSONTokener("").skipTo('A'));
+        //noinspection ThrowableResultOfMethodCallIgnored
+        assertEquals("foo! at character 0 of ",
+                new JSONTokener("").syntaxError("foo!").getMessage());
+        assertEquals(" at character 0 of ", new JSONTokener("").toString());
+    }
+
+    public void testCharacterNavigation() throws JSONException {
+        JSONTokener abcdeTokener = new JSONTokener("ABCDE");
+        assertEquals('A', abcdeTokener.next());
+        assertEquals('B', abcdeTokener.next('B'));
+        assertEquals("CD", abcdeTokener.next(2));
+        try {
+            abcdeTokener.next(2);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals('E', abcdeTokener.nextClean());
+        assertEquals('\0', abcdeTokener.next());
+        assertFalse(abcdeTokener.more());
+        abcdeTokener.back();
+        assertTrue(abcdeTokener.more());
+        assertEquals('E', abcdeTokener.next());
+    }
+
+    public void testBackNextAndMore() throws JSONException {
+        JSONTokener abcTokener = new JSONTokener("ABC");
+        assertTrue(abcTokener.more());
+        abcTokener.next();
+        abcTokener.next();
+        assertTrue(abcTokener.more());
+        abcTokener.next();
+        assertFalse(abcTokener.more());
+        abcTokener.back();
+        assertTrue(abcTokener.more());
+        abcTokener.next();
+        assertFalse(abcTokener.more());
+        abcTokener.back();
+        abcTokener.back();
+        abcTokener.back();
+        abcTokener.back(); // you can back up before the beginning of a String!
+        assertEquals('A', abcTokener.next());
+    }
+
+    public void testNextMatching() throws JSONException {
+        JSONTokener abcdTokener = new JSONTokener("ABCD");
+        assertEquals('A', abcdTokener.next('A'));
+        try {
+            abcdTokener.next('C'); // although it failed, this op consumes a character of input
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals('C', abcdTokener.next('C'));
+        assertEquals('D', abcdTokener.next('D'));
+        try {
+            abcdTokener.next('E');
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    public void testNextN() throws JSONException {
+        JSONTokener abcdeTokener = new JSONTokener("ABCDEF");
+        assertEquals("", abcdeTokener.next(0));
+        try {
+            abcdeTokener.next(7);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals("ABC", abcdeTokener.next(3));
+        try {
+            abcdeTokener.next(4);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    public void testNextNWithAllRemaining() throws JSONException {
+        JSONTokener tokener = new JSONTokener("ABCDEF");
+        tokener.next(3);
+        try {
+            tokener.next(3);
+        } catch (JSONException e) {
+            AssertionFailedError error = new AssertionFailedError("off-by-one error?");
+            error.initCause(e);
+            throw error;
+        }
+    }
+
+    public void testNext0() throws JSONException {
+        JSONTokener tokener = new JSONTokener("ABCDEF");
+        tokener.next(5);
+        tokener.next();
+        try {
+            tokener.next(0);
+        } catch (JSONException e) {
+            Error error = new AssertionFailedError("Returning an empty string should be valid");
+            error.initCause(e);
+            throw error;
+        }
+    }
+
+    public void testNextCleanComments() throws JSONException {
+        JSONTokener tokener = new JSONTokener(
+                "  A  /*XX*/B/*XX//XX\n//XX\nXX*/C//X//X//X\nD/*X*///X\n");
+        assertEquals('A', tokener.nextClean());
+        assertEquals('B', tokener.nextClean());
+        assertEquals('C', tokener.nextClean());
+        assertEquals('D', tokener.nextClean());
+        assertEquals('\0', tokener.nextClean());
+    }
+
+    public void testNextCleanNestedCStyleComments() throws JSONException {
+        JSONTokener tokener = new JSONTokener("A /* B /* C */ D */ E");
+        assertEquals('A', tokener.nextClean());
+        assertEquals('D', tokener.nextClean());
+        assertEquals('*', tokener.nextClean());
+        assertEquals('/', tokener.nextClean());
+        assertEquals('E', tokener.nextClean());
+    }
+
+    /**
+     * Some applications rely on parsing '#' to lead an end-of-line comment.
+     * http://b/2571423
+     */
+    public void testNextCleanHashComments() throws JSONException {
+        JSONTokener tokener = new JSONTokener("A # B */ /* C */ \nD #");
+        assertEquals('A', tokener.nextClean());
+        assertEquals('D', tokener.nextClean());
+        assertEquals('\0', tokener.nextClean());
+    }
+
+    public void testNextCleanCommentsTrailingSingleSlash() throws JSONException {
+        JSONTokener tokener = new JSONTokener(" / S /");
+        assertEquals('/', tokener.nextClean());
+        assertEquals('S', tokener.nextClean());
+        assertEquals('/', tokener.nextClean());
+        assertEquals("nextClean doesn't consume a trailing slash",
+                '\0', tokener.nextClean());
+    }
+
+    public void testNextCleanTrailingOpenComment() throws JSONException {
+        try {
+            new JSONTokener("  /* ").nextClean();
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals('\0', new JSONTokener("  // ").nextClean());
+    }
+
+    public void testNextCleanNewlineDelimiters() throws JSONException {
+        assertEquals('B', new JSONTokener("  // \r\n  B ").nextClean());
+        assertEquals('B', new JSONTokener("  // \n  B ").nextClean());
+        assertEquals('B', new JSONTokener("  // \r  B ").nextClean());
+    }
+
+    public void testNextCleanSkippedWhitespace() throws JSONException {
+        assertEquals("character tabulation", 'A', new JSONTokener("\tA").nextClean());
+        assertEquals("line feed",            'A', new JSONTokener("\nA").nextClean());
+        assertEquals("carriage return",      'A', new JSONTokener("\rA").nextClean());
+        assertEquals("space",                'A', new JSONTokener(" A").nextClean());
+    }
+
+    /**
+     * Tests which characters tokener treats as ignorable whitespace. See Kevin Bourrillion's
+     * <a href="https://spreadsheets.google.com/pub?key=pd8dAQyHbdewRsnE5x5GzKQ">list
+     * of whitespace characters</a>.
+     */
+    public void testNextCleanRetainedWhitespace() throws JSONException {
+        assertNotClean("null",                      '\u0000');
+        assertNotClean("next line",                 '\u0085');
+        assertNotClean("non-breaking space",        '\u00a0');
+        assertNotClean("ogham space mark",          '\u1680');
+        assertNotClean("mongolian vowel separator", '\u180e');
+        assertNotClean("en quad",                   '\u2000');
+        assertNotClean("em quad",                   '\u2001');
+        assertNotClean("en space",                  '\u2002');
+        assertNotClean("em space",                  '\u2003');
+        assertNotClean("three-per-em space",        '\u2004');
+        assertNotClean("four-per-em space",         '\u2005');
+        assertNotClean("six-per-em space",          '\u2006');
+        assertNotClean("figure space",              '\u2007');
+        assertNotClean("punctuation space",         '\u2008');
+        assertNotClean("thin space",                '\u2009');
+        assertNotClean("hair space",                '\u200a');
+        assertNotClean("zero-width space",          '\u200b');
+        assertNotClean("left-to-right mark",        '\u200e');
+        assertNotClean("right-to-left mark",        '\u200f');
+        assertNotClean("line separator",            '\u2028');
+        assertNotClean("paragraph separator",       '\u2029');
+        assertNotClean("narrow non-breaking space", '\u202f');
+        assertNotClean("medium mathematical space", '\u205f');
+        assertNotClean("ideographic space",         '\u3000');
+        assertNotClean("line tabulation",           '\u000b');
+        assertNotClean("form feed",                 '\u000c');
+        assertNotClean("information separator 4",   '\u001c');
+        assertNotClean("information separator 3",   '\u001d');
+        assertNotClean("information separator 2",   '\u001e');
+        assertNotClean("information separator 1",   '\u001f');
+    }
+
+    private void assertNotClean(String name, char c) throws JSONException {
+        assertEquals("The character " + name + " is not whitespace according to the JSON spec.",
+                c, new JSONTokener(new String(new char[] { c, 'A' })).nextClean());
+    }
+
+    public void testNextString() throws JSONException {
+        assertEquals("", new JSONTokener("'").nextString('\''));
+        assertEquals("", new JSONTokener("\"").nextString('\"'));
+        assertEquals("ABC", new JSONTokener("ABC'DEF").nextString('\''));
+        assertEquals("ABC", new JSONTokener("ABC'''DEF").nextString('\''));
+
+        // nextString permits slash-escaping of arbitrary characters!
+        assertEquals("ABC", new JSONTokener("A\\B\\C'DEF").nextString('\''));
+
+        JSONTokener tokener = new JSONTokener(" 'abc' 'def' \"ghi\"");
+        tokener.next();
+        assertEquals('\'', tokener.next());
+        assertEquals("abc", tokener.nextString('\''));
+        tokener.next();
+        assertEquals('\'', tokener.next());
+        assertEquals("def", tokener.nextString('\''));
+        tokener.next();
+        assertEquals('"', tokener.next());
+        assertEquals("ghi", tokener.nextString('\"'));
+        assertFalse(tokener.more());
+    }
+
+    public void testNextStringNoDelimiter() throws JSONException {
+        try {
+            new JSONTokener("").nextString('\'');
+            fail();
+        } catch (JSONException ignored) {
+        }
+
+        JSONTokener tokener = new JSONTokener(" 'abc");
+        tokener.next();
+        tokener.next();
+        try {
+            tokener.next('\'');
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    public void testNextStringEscapedQuote() throws JSONException {
+        try {
+            new JSONTokener("abc\\").nextString('"');
+            fail();
+        } catch (JSONException ignored) {
+        }
+
+        // we're mixing Java escaping like \" and JavaScript escaping like \\\"
+        // which makes these tests extra tricky to read!
+        assertEquals("abc\"def", new JSONTokener("abc\\\"def\"ghi").nextString('"'));
+        assertEquals("abc\\def", new JSONTokener("abc\\\\def\"ghi").nextString('"'));
+        assertEquals("abc/def", new JSONTokener("abc\\/def\"ghi").nextString('"'));
+        assertEquals("abc\bdef", new JSONTokener("abc\\bdef\"ghi").nextString('"'));
+        assertEquals("abc\fdef", new JSONTokener("abc\\fdef\"ghi").nextString('"'));
+        assertEquals("abc\ndef", new JSONTokener("abc\\ndef\"ghi").nextString('"'));
+        assertEquals("abc\rdef", new JSONTokener("abc\\rdef\"ghi").nextString('"'));
+        assertEquals("abc\tdef", new JSONTokener("abc\\tdef\"ghi").nextString('"'));
+    }
+
+    public void testNextStringUnicodeEscaped() throws JSONException {
+        // we're mixing Java escaping like \\ and JavaScript escaping like \\u
+        assertEquals("abc def", new JSONTokener("abc\\u0020def\"ghi").nextString('"'));
+        assertEquals("abcU0020def", new JSONTokener("abc\\U0020def\"ghi").nextString('"'));
+
+        // JSON requires 4 hex characters after a unicode escape
+        try {
+            new JSONTokener("abc\\u002\"").nextString('"');
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONTokener("abc\\u").nextString('"');
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            new JSONTokener("abc\\u    \"").nextString('"');
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals("abc\"def", new JSONTokener("abc\\u0022def\"ghi").nextString('"'));
+        try {
+            new JSONTokener("abc\\u000G\"").nextString('"');
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    public void testNextStringNonQuote() throws JSONException {
+        assertEquals("AB", new JSONTokener("ABC").nextString('C'));
+        assertEquals("ABCD", new JSONTokener("AB\\CDC").nextString('C'));
+        assertEquals("AB\nC", new JSONTokener("AB\\nCn").nextString('n'));
+    }
+
+    public void testNextTo() throws JSONException {
+        assertEquals("ABC", new JSONTokener("ABCDEFG").nextTo("DHI"));
+        assertEquals("ABCDEF", new JSONTokener("ABCDEF").nextTo(""));
+
+        JSONTokener tokener = new JSONTokener("ABC\rDEF\nGHI\r\nJKL");
+        assertEquals("ABC", tokener.nextTo("M"));
+        assertEquals('\r', tokener.next());
+        assertEquals("DEF", tokener.nextTo("M"));
+        assertEquals('\n', tokener.next());
+        assertEquals("GHI", tokener.nextTo("M"));
+        assertEquals('\r', tokener.next());
+        assertEquals('\n', tokener.next());
+        assertEquals("JKL", tokener.nextTo("M"));
+
+        tokener = new JSONTokener("ABCDEFGHI");
+        assertEquals("ABC", tokener.nextTo("DEF"));
+        assertEquals("", tokener.nextTo("DEF"));
+        assertEquals('D', tokener.next());
+        assertEquals("", tokener.nextTo("DEF"));
+        assertEquals('E', tokener.next());
+        assertEquals("", tokener.nextTo("DEF"));
+        assertEquals('F', tokener.next());
+        assertEquals("GHI", tokener.nextTo("DEF"));
+        assertEquals("", tokener.nextTo("DEF"));
+
+        tokener = new JSONTokener(" \t \fABC \t DEF");
+        assertEquals("ABC", tokener.nextTo("DEF"));
+        assertEquals('D', tokener.next());
+
+        tokener = new JSONTokener(" \t \fABC \n DEF");
+        assertEquals("ABC", tokener.nextTo("\n"));
+        assertEquals("", tokener.nextTo("\n"));
+
+        tokener = new JSONTokener("");
+        try {
+            tokener.nextTo(null);
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+    }
+
+    public void testNextToTrimming() {
+        assertEquals("ABC", new JSONTokener("\t ABC \tDEF").nextTo("DE"));
+        assertEquals("ABC", new JSONTokener("\t ABC \tDEF").nextTo('D'));
+    }
+
+    public void testNextToTrailing() {
+        assertEquals("ABC DEF", new JSONTokener("\t ABC DEF \t").nextTo("G"));
+        assertEquals("ABC DEF", new JSONTokener("\t ABC DEF \t").nextTo('G'));
+    }
+
+    public void testNextToDoesntStopOnNull() {
+        String message = "nextTo() shouldn't stop after \\0 characters";
+        JSONTokener tokener = new JSONTokener(" \0\t \fABC \n DEF");
+        assertEquals(message, "ABC", tokener.nextTo("D"));
+        assertEquals(message, '\n', tokener.next());
+        assertEquals(message, "", tokener.nextTo("D"));
+    }
+
+    public void testNextToConsumesNull() {
+        String message = "nextTo shouldn't consume \\0.";
+        JSONTokener tokener = new JSONTokener("ABC\0DEF");
+        assertEquals(message, "ABC", tokener.nextTo("\0"));
+        assertEquals(message, '\0', tokener.next());
+        assertEquals(message, "DEF", tokener.nextTo("\0"));
+    }
+
+    public void testSkipPast() {
+        JSONTokener tokener = new JSONTokener("ABCDEF");
+        tokener.skipPast("ABC");
+        assertEquals('D', tokener.next());
+        tokener.skipPast("EF");
+        assertEquals('\0', tokener.next());
+
+        tokener = new JSONTokener("ABCDEF");
+        tokener.skipPast("ABCDEF");
+        assertEquals('\0', tokener.next());
+
+        tokener = new JSONTokener("ABCDEF");
+        tokener.skipPast("G");
+        assertEquals('\0', tokener.next());
+
+        tokener = new JSONTokener("ABC\0ABC");
+        tokener.skipPast("ABC");
+        assertEquals('\0', tokener.next());
+        assertEquals('A', tokener.next());
+
+        tokener = new JSONTokener("\0ABC");
+        tokener.skipPast("ABC");
+        assertEquals('\0', tokener.next());
+
+        tokener = new JSONTokener("ABC\nDEF");
+        tokener.skipPast("DEF");
+        assertEquals('\0', tokener.next());
+
+        tokener = new JSONTokener("ABC");
+        tokener.skipPast("ABCDEF");
+        assertEquals('\0', tokener.next());
+
+        tokener = new JSONTokener("ABCDABCDABCD");
+        tokener.skipPast("ABC");
+        assertEquals('D', tokener.next());
+        tokener.skipPast("ABC");
+        assertEquals('D', tokener.next());
+        tokener.skipPast("ABC");
+        assertEquals('D', tokener.next());
+
+        tokener = new JSONTokener("");
+        try {
+            tokener.skipPast(null);
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+    }
+
+    public void testSkipTo() {
+        JSONTokener tokener = new JSONTokener("ABCDEF");
+        tokener.skipTo('A');
+        assertEquals('A', tokener.next());
+        tokener.skipTo('D');
+        assertEquals('D', tokener.next());
+        tokener.skipTo('G');
+        assertEquals('E', tokener.next());
+        tokener.skipTo('A');
+        assertEquals('F', tokener.next());
+
+        tokener = new JSONTokener("ABC\nDEF");
+        tokener.skipTo('F');
+        assertEquals('F', tokener.next());
+
+        tokener = new JSONTokener("ABCfDEF");
+        tokener.skipTo('F');
+        assertEquals('F', tokener.next());
+
+        tokener = new JSONTokener("ABC/* DEF */");
+        tokener.skipTo('D');
+        assertEquals('D', tokener.next());
+    }
+
+    public void testSkipToStopsOnNull() {
+        JSONTokener tokener = new JSONTokener("ABC\0DEF");
+        tokener.skipTo('F');
+        assertEquals("skipTo shouldn't stop when it sees '\\0'", 'F', tokener.next());
+    }
+
+    public void testBomIgnoredAsFirstCharacterOfDocument() throws JSONException {
+        JSONTokener tokener = new JSONTokener("\ufeff[]");
+        JSONArray array = (JSONArray) tokener.nextValue();
+        assertEquals(0, array.length());
+    }
+
+    public void testBomTreatedAsCharacterInRestOfDocument() throws JSONException {
+        JSONTokener tokener = new JSONTokener("[\ufeff]");
+        JSONArray array = (JSONArray) tokener.nextValue();
+        assertEquals(1, array.length());
+    }
+
+    public void testDehexchar() {
+        assertEquals( 0, JSONTokener.dehexchar('0'));
+        assertEquals( 1, JSONTokener.dehexchar('1'));
+        assertEquals( 2, JSONTokener.dehexchar('2'));
+        assertEquals( 3, JSONTokener.dehexchar('3'));
+        assertEquals( 4, JSONTokener.dehexchar('4'));
+        assertEquals( 5, JSONTokener.dehexchar('5'));
+        assertEquals( 6, JSONTokener.dehexchar('6'));
+        assertEquals( 7, JSONTokener.dehexchar('7'));
+        assertEquals( 8, JSONTokener.dehexchar('8'));
+        assertEquals( 9, JSONTokener.dehexchar('9'));
+        assertEquals(10, JSONTokener.dehexchar('A'));
+        assertEquals(11, JSONTokener.dehexchar('B'));
+        assertEquals(12, JSONTokener.dehexchar('C'));
+        assertEquals(13, JSONTokener.dehexchar('D'));
+        assertEquals(14, JSONTokener.dehexchar('E'));
+        assertEquals(15, JSONTokener.dehexchar('F'));
+        assertEquals(10, JSONTokener.dehexchar('a'));
+        assertEquals(11, JSONTokener.dehexchar('b'));
+        assertEquals(12, JSONTokener.dehexchar('c'));
+        assertEquals(13, JSONTokener.dehexchar('d'));
+        assertEquals(14, JSONTokener.dehexchar('e'));
+        assertEquals(15, JSONTokener.dehexchar('f'));
+
+        for (int c = 0; c <= 0xFFFF; c++) {
+            if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) {
+                continue;
+            }
+            assertEquals("dehexchar " + c, -1, JSONTokener.dehexchar((char) c));
+        }
+    }
+}


[03/51] [abbrv] geode git commit: GEODE-2142: Adding JSON library from the https://github.com/tdunning/open-json project

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/main/java/org/json/JSONStringer.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONStringer.java b/geode-json/src/main/java/org/json/JSONStringer.java
new file mode 100755
index 0000000..db1121e
--- /dev/null
+++ b/geode-json/src/main/java/org/json/JSONStringer.java
@@ -0,0 +1,470 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+// Note: this class was written without inspecting the non-free org.json sourcecode.
+
+/**
+ * Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most
+ * application developers should use those methods directly and disregard this
+ * API. For example:<pre>
+ * JSONObject object = ...
+ * String json = object.toString();</pre>
+ *
+ * <p>Stringers only encode well-formed JSON strings. In particular:
+ * <ul>
+ * <li>The stringer must have exactly one top-level array or object.
+ * <li>Lexical scopes must be balanced: every call to {@link #array} must
+ * have a matching call to {@link #endArray} and every call to {@link
+ * #object} must have a matching call to {@link #endObject}.
+ * <li>Arrays may not contain keys (property names).
+ * <li>Objects must alternate keys (property names) and values.
+ * <li>Values are inserted with either literal {@link #value(Object) value}
+ * calls, or by nesting arrays or objects.
+ * </ul>
+ * Calls that would result in a malformed JSON string will fail with a
+ * {@link JSONException}.
+ *
+ * <p>This class provides no facility for pretty-printing (ie. indenting)
+ * output. To encode indented output, use {@link JSONObject#toString(int)} or
+ * {@link JSONArray#toString(int)}.
+ *
+ * <p>Some implementations of the API support at most 20 levels of nesting.
+ * Attempts to create more than 20 levels of nesting may fail with a {@link
+ * JSONException}.
+ *
+ * <p>Each stringer may be used to encode a single top level value. Instances of
+ * this class are not thread safe. Although this class is nonfinal, it was not
+ * designed for inheritance and should not be subclassed. In particular,
+ * self-use by overrideable methods is not specified. See <i>Effective Java</i>
+ * Item 17, "Design and Document or inheritance or else prohibit it" for further
+ * information.
+ */
+public class JSONStringer {
+
+    /**
+     * The output data, containing at most one top-level array or object.
+     */
+    final StringBuilder out = new StringBuilder();
+
+    /**
+     * Lexical scoping elements within this stringer, necessary to insert the
+     * appropriate separator characters (ie. commas and colons) and to detect
+     * nesting errors.
+     */
+    enum Scope {
+
+        /**
+         * An array with no elements requires no separators or newlines before
+         * it is closed.
+         */
+        EMPTY_ARRAY,
+
+        /**
+         * A array with at least one value requires a comma and newline before
+         * the next element.
+         */
+        NONEMPTY_ARRAY,
+
+        /**
+         * An object with no keys or values requires no separators or newlines
+         * before it is closed.
+         */
+        EMPTY_OBJECT,
+
+        /**
+         * An object whose most recent element is a key. The next element must
+         * be a value.
+         */
+        DANGLING_KEY,
+
+        /**
+         * An object with at least one name/value pair requires a comma and
+         * newline before the next element.
+         */
+        NONEMPTY_OBJECT,
+
+        /**
+         * A special bracketless array needed by JSONStringer.join() and
+         * JSONObject.quote() only. Not used for JSON encoding.
+         */
+        NULL,
+    }
+
+    /**
+     * Unlike the original implementation, this stack isn't limited to 20
+     * levels of nesting.
+     */
+    private final List<Scope> stack = new ArrayList<Scope>();
+
+    /**
+     * A string containing a full set of spaces for a single level of
+     * indentation, or null for no pretty printing.
+     */
+    private final String indent;
+
+    public JSONStringer() {
+        indent = null;
+    }
+
+    JSONStringer(int indentSpaces) {
+        char[] indentChars = new char[indentSpaces];
+        Arrays.fill(indentChars, ' ');
+        indent = new String(indentChars);
+    }
+
+    /**
+     * Begins encoding a new array. Each call to this method must be paired with
+     * a call to {@link #endArray}.
+     *
+     * @return this stringer.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONStringer array() throws JSONException {
+        return open(Scope.EMPTY_ARRAY, "[");
+    }
+
+    /**
+     * Ends encoding the current array.
+     *
+     * @return this stringer.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONStringer endArray() throws JSONException {
+        return close(Scope.EMPTY_ARRAY, Scope.NONEMPTY_ARRAY, "]");
+    }
+
+    /**
+     * Begins encoding a new object. Each call to this method must be paired
+     * with a call to {@link #endObject}.
+     *
+     * @return this stringer.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONStringer object() throws JSONException {
+        return open(Scope.EMPTY_OBJECT, "{");
+    }
+
+    /**
+     * Ends encoding the current object.
+     *
+     * @return this stringer.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONStringer endObject() throws JSONException {
+        return close(Scope.EMPTY_OBJECT, Scope.NONEMPTY_OBJECT, "}");
+    }
+
+    /**
+     * Enters a new scope by appending any necessary whitespace and the given
+     * bracket.
+     */
+    JSONStringer open(Scope empty, String openBracket) throws JSONException {
+        if (stack.isEmpty() && out.length() > 0) {
+            throw new JSONException("Nesting problem: multiple top-level roots");
+        }
+        beforeValue();
+        stack.add(empty);
+        out.append(openBracket);
+        return this;
+    }
+
+    /**
+     * Closes the current scope by appending any necessary whitespace and the
+     * given bracket.
+     */
+    JSONStringer close(Scope empty, Scope nonempty, String closeBracket) throws JSONException {
+        Scope context = peek();
+        if (context != nonempty && context != empty) {
+            throw new JSONException("Nesting problem");
+        }
+
+        stack.remove(stack.size() - 1);
+        if (context == nonempty) {
+            newline();
+        }
+        out.append(closeBracket);
+        return this;
+    }
+
+    /**
+     * Returns the value on the top of the stack.
+     */
+    private Scope peek() throws JSONException {
+        if (stack.isEmpty()) {
+            throw new JSONException("Nesting problem");
+        }
+        return stack.get(stack.size() - 1);
+    }
+
+    /**
+     * Replace the value on the top of the stack with the given value.
+     */
+    private void replaceTop(Scope topOfStack) {
+        stack.set(stack.size() - 1, topOfStack);
+    }
+
+    /**
+     * Encodes {@code value}.
+     *
+     * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
+     *              Integer, Long, Double or null. May not be {@link Double#isNaN() NaNs}
+     *              or {@link Double#isInfinite() infinities}.
+     * @return this stringer.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONStringer value(Object value) throws JSONException {
+        if (stack.isEmpty()) {
+            throw new JSONException("Nesting problem");
+        }
+
+        if (value instanceof JSONArray) {
+            ((JSONArray) value).writeTo(this);
+            return this;
+
+        } else if (value instanceof JSONObject) {
+            ((JSONObject) value).writeTo(this);
+            return this;
+        }
+
+        beforeValue();
+
+        if (value instanceof JSONString) {
+          out.append(((JSONString) value).toJSONString());
+          return this;
+        }
+
+        if (value == null
+              || value instanceof Boolean
+              || value == JSONObject.NULL) {
+            out.append(value);
+
+        } else if (value instanceof Number) {
+            out.append(JSONObject.numberToString((Number) value));
+
+        } else {
+            // Hack to make it possible that the value is not surrounded by quotes. (Used for JavaScript function calls)
+            // Example: { "name": "testkey", "value": window.myfunction() }
+            if (value.getClass().getSimpleName().contains("JSONFunction")) {
+                // note that no escaping of quotes (or anything else) is done in this case.
+                // that is fine because the only way to get to this point is to
+                // explicitly put a special kind of object into the JSON data structure.
+                out.append(value);
+            } else {
+                string(value.toString());
+            }
+        }
+
+        return this;
+    }
+
+    /**
+     * Encodes {@code value} to this stringer.
+     *
+     * @param value The value to encode.
+     * @return this stringer.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONStringer value(boolean value) throws JSONException {
+        if (stack.isEmpty()) {
+            throw new JSONException("Nesting problem");
+        }
+        beforeValue();
+        out.append(value);
+        return this;
+    }
+
+    /**
+     * Encodes {@code value} to this stringer.
+     *
+     * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
+     *              {@link Double#isInfinite() infinities}.
+     * @return this stringer.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONStringer value(double value) throws JSONException {
+        if (stack.isEmpty()) {
+            throw new JSONException("Nesting problem");
+        }
+        beforeValue();
+        out.append(JSONObject.numberToString(value));
+        return this;
+    }
+
+    /**
+     * Encodes {@code value} to this stringer.
+     *
+     * @param value The value to encode.
+     * @return this stringer.
+     * @throws JSONException If we have an internal error. Shouldn't happen.
+     */
+    public JSONStringer value(long value) throws JSONException {
+        if (stack.isEmpty()) {
+            throw new JSONException("Nesting problem");
+        }
+        beforeValue();
+        out.append(value);
+        return this;
+    }
+
+    private void string(String value) {
+        out.append("\"");
+        char currentChar = 0;
+
+        for (int i = 0, length = value.length(); i < length; i++) {
+            char previousChar = currentChar;
+            currentChar = value.charAt(i);
+
+            /*
+             * From RFC 4627, "All Unicode characters may be placed within the
+             * quotation marks except for the characters that must be escaped:
+             * quotation mark, reverse solidus, and the control characters
+             * (U+0000 through U+001F)."
+             */
+            switch (currentChar) {
+                case '"':
+                case '\\':
+                    out.append('\\').append(currentChar);
+                    break;
+
+                case '/':
+                    // it makes life easier for HTML embedding of javascript if we escape </ sequences
+                    if (previousChar == '<') {
+                        out.append('\\');
+                    }
+                    out.append(currentChar);
+                    break;
+
+                case '\t':
+                    out.append("\\t");
+                    break;
+
+                case '\b':
+                    out.append("\\b");
+                    break;
+
+                case '\n':
+                    out.append("\\n");
+                    break;
+
+                case '\r':
+                    out.append("\\r");
+                    break;
+
+                case '\f':
+                    out.append("\\f");
+                    break;
+
+                default:
+                    if (currentChar <= 0x1F) {
+                        out.append(String.format("\\u%04x", (int) currentChar));
+                    } else {
+                        out.append(currentChar);
+                    }
+                    break;
+            }
+
+        }
+        out.append("\"");
+    }
+
+    private void newline() {
+        if (indent == null) {
+            return;
+        }
+
+        out.append("\n");
+        for (int i = 0; i < stack.size(); i++) {
+            out.append(indent);
+        }
+    }
+
+    /**
+     * Encodes the key (property name) to this stringer.
+     *
+     * @param name the name of the forthcoming value. May not be null.
+     * @return this stringer.
+     * @throws JSONException on internal errors, shouldn't happen.
+     */
+    public JSONStringer key(String name) throws JSONException {
+        if (name == null) {
+            throw new JSONException("Names must be non-null");
+        }
+        beforeKey();
+        string(name);
+        return this;
+    }
+
+    /**
+     * Inserts any necessary separators and whitespace before a name. Also
+     * adjusts the stack to expect the key's value.
+     */
+    private void beforeKey() throws JSONException {
+        Scope context = peek();
+        if (context == Scope.NONEMPTY_OBJECT) { // first in object
+            out.append(',');
+        } else if (context != Scope.EMPTY_OBJECT) { // not in an object!
+            throw new JSONException("Nesting problem");
+        }
+        newline();
+        replaceTop(Scope.DANGLING_KEY);
+    }
+
+    /**
+     * Inserts any necessary separators and whitespace before a literal value,
+     * inline array, or inline object. Also adjusts the stack to expect either a
+     * closing bracket or another element.
+     */
+    private void beforeValue() throws JSONException {
+        if (stack.isEmpty()) {
+            return;
+        }
+
+        Scope context = peek();
+        if (context == Scope.EMPTY_ARRAY) { // first in array
+            replaceTop(Scope.NONEMPTY_ARRAY);
+            newline();
+        } else if (context == Scope.NONEMPTY_ARRAY) { // another in array
+            out.append(',');
+            newline();
+        } else if (context == Scope.DANGLING_KEY) { // value for key
+            out.append(indent == null ? ":" : ": ");
+            replaceTop(Scope.NONEMPTY_OBJECT);
+        } else if (context != Scope.NULL) {
+            throw new JSONException("Nesting problem");
+        }
+    }
+
+    /**
+     * Returns the encoded JSON string.
+     *
+     * <p>If invoked with unterminated arrays or unclosed objects, this method's
+     * return value is undefined.
+     *
+     * <p><strong>Warning:</strong> although it contradicts the general contract
+     * of {@link Object#toString}, this method returns null if the stringer
+     * contains no data.
+     */
+    @Override
+    public String toString() {
+        return out.length() == 0 ? null : out.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/main/java/org/json/JSONTokener.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONTokener.java b/geode-json/src/main/java/org/json/JSONTokener.java
new file mode 100755
index 0000000..59eb4bc
--- /dev/null
+++ b/geode-json/src/main/java/org/json/JSONTokener.java
@@ -0,0 +1,658 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+// Note: this class was written without inspecting the non-free org.json sourcecode.
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * Parses a JSON (<a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>)
+ * encoded string into the corresponding object. Most clients of
+ * this class will use only need the {@link #JSONTokener(String) constructor}
+ * and {@link #nextValue} method. Example usage: <pre>
+ * String json = "{"
+ *         + "  \"query\": \"Pizza\", "
+ *         + "  \"locations\": [ 94043, 90210 ] "
+ *         + "}";
+ *
+ * JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
+ * String query = object.getString("query");
+ * JSONArray locations = object.getJSONArray("locations");</pre>
+ *
+ * <p>For best interoperability and performance use JSON that complies with
+ * RFC 4627, such as that generated by {@link JSONStringer}. For legacy reasons
+ * this parser is lenient, so a successful parse does not indicate that the
+ * input string was valid JSON. All of the following syntax errors will be
+ * ignored:
+ * <ul>
+ * <li>End of line comments starting with {@code //} or {@code #} and ending
+ * with a newline character.
+ * <li>C-style comments starting with {@code /*} and ending with
+ * {@code *}{@code /}. Such comments may not be nested.
+ * <li>Strings that are unquoted or {@code 'single quoted'}.
+ * <li>Hexadecimal integers prefixed with {@code 0x} or {@code 0X}.
+ * <li>Octal integers prefixed with {@code 0}.
+ * <li>Array elements separated by {@code ;}.
+ * <li>Unnecessary array separators. These are interpreted as if null was the
+ * omitted value.
+ * <li>Key-value pairs separated by {@code =} or {@code =>}.
+ * <li>Key-value pairs separated by {@code ;}.
+ * </ul>
+ *
+ * <p>Each tokener may be used to parse a single JSON string. Instances of this
+ * class are not thread safe. Although this class is nonfinal, it was not
+ * designed for inheritance and should not be subclassed. In particular,
+ * self-use by overrideable methods is not specified. See <i>Effective Java</i>
+ * Item 17, "Design and Document or inheritance or else prohibit it" for further
+ * information.
+ */
+public class JSONTokener {
+
+    /**
+     * The input JSON.
+     */
+    private final String in;
+
+    /**
+     * The index of the next character to be returned by {@link #next}. When
+     * the input is exhausted, this equals the input's length.
+     */
+    private int pos;
+
+    /**
+     * @param in JSON encoded string. Null is not permitted and will yield a
+     *           tokener that throws {@code NullPointerExceptions} when methods are
+     *           called.
+     */
+    public JSONTokener(String in) {
+        // consume an optional byte order mark (BOM) if it exists
+        if (in != null && in.startsWith("\ufeff")) {
+            in = in.substring(1);
+        }
+        this.in = in;
+    }
+
+    public JSONTokener(Reader input) throws IOException {
+        StringBuilder s = new StringBuilder();
+        char[] readBuf = new char[102400];
+        int n = input.read(readBuf);
+        while (n >= 0) {
+            s.append(readBuf, 0, n);
+            n = input.read(readBuf);
+        }
+        in = s.toString();
+        pos = 0;
+    }
+
+    /**
+     * Returns the next value from the input.
+     *
+     * @return a {@link JSONObject}, {@link JSONArray}, String, Boolean,
+     * Integer, Long, Double or {@link JSONObject#NULL}.
+     * @throws JSONException if the input is malformed.
+     */
+    public Object nextValue() throws JSONException {
+        int c = nextCleanInternal();
+        switch (c) {
+            case -1:
+                throw syntaxError("End of input");
+
+            case '{':
+                return readObject();
+
+            case '[':
+                return readArray();
+
+            case '\'':
+            case '"':
+                return nextString((char) c);
+
+            default:
+                pos--;
+                return readLiteral();
+        }
+    }
+
+    private int nextCleanInternal() throws JSONException {
+        while (pos < in.length()) {
+            int c = in.charAt(pos++);
+            switch (c) {
+                case '\t':
+                case ' ':
+                case '\n':
+                case '\r':
+                    continue;
+
+                case '/':
+                    if (pos == in.length()) {
+                        return c;
+                    }
+
+                    char peek = in.charAt(pos);
+                    switch (peek) {
+                        case '*':
+                            // skip a /* c-style comment */
+                            pos++;
+                            int commentEnd = in.indexOf("*/", pos);
+                            if (commentEnd == -1) {
+                                throw syntaxError("Unterminated comment");
+                            }
+                            pos = commentEnd + 2;
+                            continue;
+
+                        case '/':
+                            // skip a // end-of-line comment
+                            pos++;
+                            skipToEndOfLine();
+                            continue;
+
+                        default:
+                            return c;
+                    }
+
+                case '#':
+                    /*
+                     * Skip a # hash end-of-line comment. The JSON RFC doesn't
+                     * specify this behavior, but it's required to parse
+                     * existing documents. See http://b/2571423.
+                     */
+                    skipToEndOfLine();
+                    continue;
+
+                default:
+                    return c;
+            }
+        }
+
+        return -1;
+    }
+
+    /**
+     * Advances the position until after the next newline character. If the line
+     * is terminated by "\r\n", the '\n' must be consumed as whitespace by the
+     * caller.
+     */
+    private void skipToEndOfLine() {
+        for (; pos < in.length(); pos++) {
+            char c = in.charAt(pos);
+            if (c == '\r' || c == '\n') {
+                pos++;
+                break;
+            }
+        }
+    }
+
+    /**
+     * Returns the string up to but not including {@code quote}, unescaping any
+     * character escape sequences encountered along the way. The opening quote
+     * should have already been read. This consumes the closing quote, but does
+     * not include it in the returned string.
+     *
+     * @param quote either ' or ".
+     * @return The unescaped string.
+     * @throws JSONException if the string isn't terminated by a closing quote correctly.
+     */
+    public String nextString(char quote) throws JSONException {
+        /*
+         * For strings that are free of escape sequences, we can just extract
+         * the result as a substring of the input. But if we encounter an escape
+         * sequence, we need to use a StringBuilder to compose the result.
+         */
+        StringBuilder builder = null;
+
+        /* the index of the first character not yet appended to the builder. */
+        int start = pos;
+
+        while (pos < in.length()) {
+            int c = in.charAt(pos++);
+            if (c == quote) {
+                if (builder == null) {
+                    // a new string avoids leaking memory
+                    //noinspection RedundantStringConstructorCall
+                    return new String(in.substring(start, pos - 1));
+                } else {
+                    builder.append(in, start, pos - 1);
+                    return builder.toString();
+                }
+            }
+
+            if (c == '\\') {
+                if (pos == in.length()) {
+                    throw syntaxError("Unterminated escape sequence");
+                }
+                if (builder == null) {
+                    builder = new StringBuilder();
+                }
+                builder.append(in, start, pos - 1);
+                builder.append(readEscapeCharacter());
+                start = pos;
+            }
+        }
+
+        throw syntaxError("Unterminated string");
+    }
+
+    /**
+     * Unescapes the character identified by the character or characters that
+     * immediately follow a backslash. The backslash '\' should have already
+     * been read. This supports both unicode escapes "u000A" and two-character
+     * escapes "\n".
+     */
+    private char readEscapeCharacter() throws JSONException {
+        char escaped = in.charAt(pos++);
+        switch (escaped) {
+            case 'u':
+                if (pos + 4 > in.length()) {
+                    throw syntaxError("Unterminated escape sequence");
+                }
+                String hex = in.substring(pos, pos + 4);
+                pos += 4;
+                try {
+                    return (char) Integer.parseInt(hex, 16);
+                } catch (NumberFormatException nfe) {
+                    throw syntaxError("Invalid escape sequence: " + hex);
+                }
+
+            case 't':
+                return '\t';
+
+            case 'b':
+                return '\b';
+
+            case 'n':
+                return '\n';
+
+            case 'r':
+                return '\r';
+
+            case 'f':
+                return '\f';
+
+            case '\'':
+            case '"':
+            case '\\':
+            default:
+                return escaped;
+        }
+    }
+
+    /**
+     * Reads a null, boolean, numeric or unquoted string literal value. Numeric
+     * values will be returned as an Integer, Long, or Double, in that order of
+     * preference.
+     */
+    private Object readLiteral() throws JSONException {
+        String literal = nextToInternal("{}[]/\\:,=;# \t\f");
+
+        if (literal.length() == 0) {
+            throw syntaxError("Expected literal value");
+        } else if ("null".equalsIgnoreCase(literal)) {
+            return JSONObject.NULL;
+        } else if ("true".equalsIgnoreCase(literal)) {
+            return Boolean.TRUE;
+        } else if ("false".equalsIgnoreCase(literal)) {
+            return Boolean.FALSE;
+        }
+
+        /* try to parse as an integral type... */
+        if (literal.indexOf('.') == -1) {
+            int base = 10;
+            String number = literal;
+            if (number.startsWith("0x") || number.startsWith("0X")) {
+                number = number.substring(2);
+                base = 16;
+            } else if (number.startsWith("0") && number.length() > 1) {
+                number = number.substring(1);
+                base = 8;
+            }
+            try {
+                long longValue = Long.parseLong(number, base);
+                if (longValue <= Integer.MAX_VALUE && longValue >= Integer.MIN_VALUE) {
+                    return (int) longValue;
+                } else {
+                    return longValue;
+                }
+            } catch (NumberFormatException e) {
+                /*
+                 * This only happens for integral numbers greater than
+                 * Long.MAX_VALUE, numbers in exponential form (5e-10) and
+                 * unquoted strings. Fall through to try floating point.
+                 */
+            }
+        }
+
+        /* ...next try to parse as a floating point... */
+        try {
+            return Double.valueOf(literal);
+        } catch (NumberFormatException ignored) {
+        }
+
+        /* ... finally give up. We have an unquoted string */
+        //noinspection RedundantStringConstructorCall
+        return new String(literal); // a new string avoids leaking memory
+    }
+
+    /**
+     * Returns the string up to but not including any of the given characters or
+     * a newline character. This does not consume the excluded character.
+     */
+    private String nextToInternal(String excluded) {
+        int start = pos;
+        for (; pos < in.length(); pos++) {
+            char c = in.charAt(pos);
+            if (c == '\r' || c == '\n' || excluded.indexOf(c) != -1) {
+                return in.substring(start, pos);
+            }
+        }
+        return in.substring(start);
+    }
+
+    /**
+     * Reads a sequence of key/value pairs and the trailing closing brace '}' of
+     * an object. The opening brace '{' should have already been read.
+     */
+    private JSONObject readObject() throws JSONException {
+        JSONObject result = new JSONObject();
+
+        /* Peek to see if this is the empty object. */
+        int first = nextCleanInternal();
+        if (first == '}') {
+            return result;
+        } else if (first != -1) {
+            pos--;
+        }
+
+        while (true) {
+            Object name = nextValue();
+            if (!(name instanceof String)) {
+                if (name == null) {
+                    throw syntaxError("Names cannot be null");
+                } else {
+                    throw syntaxError("Names must be strings, but " + name
+                            + " is of type " + name.getClass().getName());
+                }
+            }
+
+            /*
+             * Expect the name/value separator to be either a colon ':', an
+             * equals sign '=', or an arrow "=>". The last two are bogus but we
+             * include them because that's what the original implementation did.
+             */
+            int separator = nextCleanInternal();
+            if (separator != ':' && separator != '=') {
+                throw syntaxError("Expected ':' after " + name);
+            }
+            if (pos < in.length() && in.charAt(pos) == '>') {
+                pos++;
+            }
+
+            result.put((String) name, nextValue());
+
+            switch (nextCleanInternal()) {
+                case '}':
+                    return result;
+                case ';':
+                case ',':
+                    continue;
+                default:
+                    throw syntaxError("Unterminated object");
+            }
+        }
+    }
+
+    /**
+     * Reads a sequence of values and the trailing closing brace ']' of an
+     * array. The opening brace '[' should have already been read. Note that
+     * "[]" yields an empty array, but "[,]" returns a two-element array
+     * equivalent to "[null,null]".
+     */
+    private JSONArray readArray() throws JSONException {
+        JSONArray result = new JSONArray();
+
+        /* to cover input that ends with ",]". */
+        boolean hasTrailingSeparator = false;
+
+        while (true) {
+            switch (nextCleanInternal()) {
+                case -1:
+                    throw syntaxError("Unterminated array");
+                case ']':
+                    if (hasTrailingSeparator) {
+                        result.put(null);
+                    }
+                    return result;
+                case ',':
+                case ';':
+                    /* A separator without a value first means "null". */
+                    result.put(null);
+                    hasTrailingSeparator = true;
+                    continue;
+                default:
+                    pos--;
+            }
+
+            result.put(nextValue());
+
+            switch (nextCleanInternal()) {
+                case ']':
+                    return result;
+                case ',':
+                case ';':
+                    hasTrailingSeparator = true;
+                    continue;
+                default:
+                    throw syntaxError("Unterminated array");
+            }
+        }
+    }
+
+    /**
+     * Returns an exception containing the given message plus the current
+     * position and the entire input string.
+     *
+     * @param message The message we want to include.
+     * @return An exception that we can throw.
+     */
+    public JSONException syntaxError(String message) {
+        return new JSONException(message + this);
+    }
+
+    /**
+     * Returns the current position and the entire input string.
+     */
+    @Override
+    public String toString() {
+        // consistent with the original implementation
+        return " at character " + pos + " of " + in;
+    }
+
+    /*
+     * Legacy APIs.
+     *
+     * None of the methods below are on the critical path of parsing JSON
+     * documents. They exist only because they were exposed by the original
+     * implementation and may be used by some clients.
+     */
+
+    /**
+     * Returns true until the input has been exhausted.
+     *
+     * @return true if more input exists.
+     */
+    public boolean more() {
+        return pos < in.length();
+    }
+
+    /**
+     * Returns the next available character, or the null character '\0' if all
+     * input has been exhausted. The return value of this method is ambiguous
+     * for JSON strings that contain the character '\0'.
+     *
+     * @return the next character.
+     */
+    public char next() {
+        return pos < in.length() ? in.charAt(pos++) : '\0';
+    }
+
+    /**
+     * Returns the next available character if it equals {@code c}. Otherwise an
+     * exception is thrown.
+     *
+     * @param c The character we are looking for.
+     * @return the next character.
+     * @throws JSONException If the next character isn't {@code c}
+     */
+    public char next(char c) throws JSONException {
+        char result = next();
+        if (result != c) {
+            throw syntaxError("Expected " + c + " but was " + result);
+        }
+        return result;
+    }
+
+    /**
+     * Returns the next character that is not whitespace and does not belong to
+     * a comment. If the input is exhausted before such a character can be
+     * found, the null character '\0' is returned. The return value of this
+     * method is ambiguous for JSON strings that contain the character '\0'.
+     *
+     * @return The next non-whitespace character.
+     * @throws JSONException Should not be possible.
+     */
+    public char nextClean() throws JSONException {
+        int nextCleanInt = nextCleanInternal();
+        return nextCleanInt == -1 ? '\0' : (char) nextCleanInt;
+    }
+
+    /**
+     * Returns the next {@code length} characters of the input.
+     *
+     * <p>The returned string shares its backing character array with this
+     * tokener's input string. If a reference to the returned string may be held
+     * indefinitely, you should use {@code new String(result)} to copy it first
+     * to avoid memory leaks.
+     *
+     * @param length The desired number of characters to return.
+     * @return The next few characters.
+     * @throws JSONException if the remaining input is not long enough to
+     *                       satisfy this request.
+     */
+    public String next(int length) throws JSONException {
+        if (pos + length > in.length()) {
+            throw syntaxError(length + " is out of bounds");
+        }
+        String result = in.substring(pos, pos + length);
+        pos += length;
+        return result;
+    }
+
+    /**
+     * Returns the {@link String#trim trimmed} string holding the characters up
+     * to but not including the first of:
+     * <ul>
+     * <li>any character in {@code excluded}
+     * <li>a newline character '\n'
+     * <li>a carriage return '\r'
+     * </ul>
+     *
+     * <p>The returned string shares its backing character array with this
+     * tokener's input string. If a reference to the returned string may be held
+     * indefinitely, you should use {@code new String(result)} to copy it first
+     * to avoid memory leaks.
+     *
+     * @param excluded The limiting string where the search should stop.
+     * @return a possibly-empty string
+     */
+    public String nextTo(String excluded) {
+        if (excluded == null) {
+            throw new NullPointerException("excluded == null");
+        }
+        return nextToInternal(excluded).trim();
+    }
+
+    /**
+     * Equivalent to {@code nextTo(String.valueOf(excluded))}.
+     *
+     * @param excluded The limiting character.
+     * @return a possibly-empty string
+     */
+    public String nextTo(char excluded) {
+        return nextToInternal(String.valueOf(excluded)).trim();
+    }
+
+    /**
+     * Advances past all input up to and including the next occurrence of
+     * {@code thru}. If the remaining input doesn't contain {@code thru}, the
+     * input is exhausted.
+     *
+     * @param thru The string to skip over.
+     */
+    public void skipPast(String thru) {
+        int thruStart = in.indexOf(thru, pos);
+        pos = thruStart == -1 ? in.length() : (thruStart + thru.length());
+    }
+
+    /**
+     * Advances past all input up to but not including the next occurrence of
+     * {@code to}. If the remaining input doesn't contain {@code to}, the input
+     * is unchanged.
+     *
+     * @param to The character we want to skip to.
+     * @return The value of {@code to} or null.
+     */
+    public char skipTo(char to) {
+        int index = in.indexOf(to, pos);
+        if (index != -1) {
+            pos = index;
+            return to;
+        } else {
+            return '\0';
+        }
+    }
+
+    /**
+     * Unreads the most recent character of input. If no input characters have
+     * been read, the input is unchanged.
+     */
+    public void back() {
+        if (--pos == -1) {
+            pos = 0;
+        }
+    }
+
+    /**
+     * Returns the integer [0..15] value for the given hex character, or -1
+     * for non-hex input.
+     *
+     * @param hex a character in the ranges [0-9], [A-F] or [a-f]. Any other
+     *            character will yield a -1 result.
+     * @return The decoded integer.
+     */
+    public static int dehexchar(char hex) {
+        if (hex >= '0' && hex <= '9') {
+            return hex - '0';
+        } else if (hex >= 'A' && hex <= 'F') {
+            return hex - 'A' + 10;
+        } else if (hex >= 'a' && hex <= 'f') {
+            return hex - 'a' + 10;
+        } else {
+            return -1;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/java/org/json/FileTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/FileTest.java b/geode-json/src/test/java/org/json/FileTest.java
new file mode 100755
index 0000000..dae910b
--- /dev/null
+++ b/geode-json/src/test/java/org/json/FileTest.java
@@ -0,0 +1,287 @@
+package org.json;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Set;
+
+public class FileTest {
+    @Test
+    public void testFile() throws IOException, JSONException {
+        String ref = "[\n" +
+                "  {\n" +
+                "    \"_id\": \"58309f3bd307b72ae49a9b23\",\n" +
+                "    \"index\": 0,\n" +
+                "    \"guid\": \"5764ebd8-b333-469e-8d83-4eb5658f1566\",\n" +
+                "    \"isActive\": true,\n" +
+                "    \"balance\": \"$1,099.93\",\n" +
+                "    \"picture\": \"http://placehold.it/32x32\",\n" +
+                "    \"age\": 37,\n" +
+                "    \"eyeColor\": \"blue\",\n" +
+                "    \"name\": \"Barrera Wilkerson\",\n" +
+                "    \"gender\": \"male\",\n" +
+                "    \"company\": \"VURBO\",\n" +
+                "    \"email\": \"barrerawilkerson@vurbo.com\",\n" +
+                "    \"phone\": \"+1 (817) 429-2473\",\n" +
+                "    \"address\": \"522 Vanderveer Street, Detroit, Wyoming, 4320\",\n" +
+                "    \"about\": \"Et officia aute ullamco magna adipisicing non ut cupidatat cupidatat aliquip. Tempor occaecat ex ad dolore aliquip mollit ea esse ipsum. Est incididunt sunt commodo duis est. Reprehenderit in ut reprehenderit ad culpa ea fugiat et est adipisicing aliquip. Id mollit voluptate qui pariatur officia.\\r\\n\",\n" +
+                "    \"registered\": \"2016-06-29T08:54:14 +07:00\",\n" +
+                "    \"latitude\": -87.548434,\n" +
+                "    \"longitude\": 64.251242,\n" +
+                "    \"tags\": [\n" +
+                "      \"aliqua\",\n" +
+                "      \"ex\",\n" +
+                "      \"sit\",\n" +
+                "      \"magna\",\n" +
+                "      \"dolor\",\n" +
+                "      \"laborum\",\n" +
+                "      \"non\"\n" +
+                "    ],\n" +
+                "    \"friends\": [\n" +
+                "      {\n" +
+                "        \"id\": 0,\n" +
+                "        \"name\": \"Byers Pratt\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 1,\n" +
+                "        \"name\": \"Kennedy Contreras\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 2,\n" +
+                "        \"name\": \"Frazier Monroe\"\n" +
+                "      }\n" +
+                "    ],\n" +
+                "    \"greeting\": \"Hello, Barrera Wilkerson! You have 3 unread messages.\",\n" +
+                "    \"favoriteFruit\": \"banana\"\n" +
+                "  },\n" +
+                "  {\n" +
+                "    \"_id\": \"58309f3b1f506440093a41d1\",\n" +
+                "    \"index\": 1,\n" +
+                "    \"guid\": \"de1a6cc9-f8b3-426e-b68a-cc30e1fff3c1\",\n" +
+                "    \"isActive\": false,\n" +
+                "    \"balance\": \"$3,397.60\",\n" +
+                "    \"picture\": \"http://placehold.it/32x32\",\n" +
+                "    \"age\": 32,\n" +
+                "    \"eyeColor\": \"blue\",\n" +
+                "    \"name\": \"Trisha Morris\",\n" +
+                "    \"gender\": \"female\",\n" +
+                "    \"company\": \"AMTAP\",\n" +
+                "    \"email\": \"trishamorris@amtap.com\",\n" +
+                "    \"phone\": \"+1 (805) 423-3375\",\n" +
+                "    \"address\": \"495 Tampa Court, Libertytown, New Hampshire, 5177\",\n" +
+                "    \"about\": \"Elit culpa Lorem dolor sit laborum ut ullamco ullamco nostrud reprehenderit adipisicing eiusmod. Aliqua quis dolor esse sint. Dolore in excepteur laborum anim ut consectetur. Nisi officia est eu ex ex id. Ipsum duis ullamco ad ut labore dolor. In amet tempor deserunt ullamco velit eu fugiat.\\r\\n\",\n" +
+                "    \"registered\": \"2015-02-08T06:14:19 +08:00\",\n" +
+                "    \"latitude\": -81.956277,\n" +
+                "    \"longitude\": 143.685584,\n" +
+                "    \"tags\": [\n" +
+                "      \"cillum\",\n" +
+                "      \"ullamco\",\n" +
+                "      \"magna\",\n" +
+                "      \"cillum\",\n" +
+                "      \"voluptate\",\n" +
+                "      \"magna\",\n" +
+                "      \"exercitation\"\n" +
+                "    ],\n" +
+                "    \"friends\": [\n" +
+                "      {\n" +
+                "        \"id\": 0,\n" +
+                "        \"name\": \"Fuentes Stout\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 1,\n" +
+                "        \"name\": \"Violet Vargas\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 2,\n" +
+                "        \"name\": \"Schmidt Wilder\"\n" +
+                "      }\n" +
+                "    ],\n" +
+                "    \"greeting\": \"Hello, Trisha Morris! You have 4 unread messages.\",\n" +
+                "    \"favoriteFruit\": \"strawberry\"\n" +
+                "  },\n" +
+                "  {\n" +
+                "    \"_id\": \"58309f3beaef2f31339b3755\",\n" +
+                "    \"index\": 2,\n" +
+                "    \"guid\": \"0bf387b7-abc2-4828-becc-1269928f7c3d\",\n" +
+                "    \"isActive\": false,\n" +
+                "    \"balance\": \"$1,520.64\",\n" +
+                "    \"picture\": \"http://placehold.it/32x32\",\n" +
+                "    \"age\": 37,\n" +
+                "    \"eyeColor\": \"blue\",\n" +
+                "    \"name\": \"Deanna Santiago\",\n" +
+                "    \"gender\": \"female\",\n" +
+                "    \"company\": \"MEGALL\",\n" +
+                "    \"email\": \"deannasantiago@megall.com\",\n" +
+                "    \"phone\": \"+1 (916) 511-2291\",\n" +
+                "    \"address\": \"919 Fayette Street, Homestead, Utah, 8669\",\n" +
+                "    \"about\": \"Sit amet ex quis velit irure Lorem non quis aliquip dolor pariatur nulla Lorem officia. Deserunt officia sit velit labore sint nostrud elit aliquip labore ullamco consectetur id amet. Ullamco duis commodo sit incididunt. Fugiat consectetur ad incididunt officia. Sint cillum minim laborum laboris id cillum est exercitation in eiusmod qui.\\r\\n\",\n" +
+                "    \"registered\": \"2015-11-18T08:39:28 +08:00\",\n" +
+                "    \"latitude\": 79.105701,\n" +
+                "    \"longitude\": -146.901754,\n" +
+                "    \"tags\": [\n" +
+                "      \"non\",\n" +
+                "      \"ullamco\",\n" +
+                "      \"cillum\",\n" +
+                "      \"ipsum\",\n" +
+                "      \"amet\",\n" +
+                "      \"aliqua\",\n" +
+                "      \"aliquip\"\n" +
+                "    ],\n" +
+                "    \"friends\": [\n" +
+                "      {\n" +
+                "        \"id\": 0,\n" +
+                "        \"name\": \"Hanson Anderson\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 1,\n" +
+                "        \"name\": \"Pollard Soto\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 2,\n" +
+                "        \"name\": \"Barlow Campbell\"\n" +
+                "      }\n" +
+                "    ],\n" +
+                "    \"greeting\": \"Hello, Deanna Santiago! You have 7 unread messages.\",\n" +
+                "    \"favoriteFruit\": \"apple\"\n" +
+                "  },\n" +
+                "  {\n" +
+                "    \"_id\": \"58309f3b49a68ad01346f27f\",\n" +
+                "    \"index\": 3,\n" +
+                "    \"guid\": \"d29c0dcc-48fb-4ca4-a63b-b47c0e6d6398\",\n" +
+                "    \"isActive\": false,\n" +
+                "    \"balance\": \"$2,069.96\",\n" +
+                "    \"picture\": \"http://placehold.it/32x32\",\n" +
+                "    \"age\": 29,\n" +
+                "    \"eyeColor\": \"green\",\n" +
+                "    \"name\": \"Brooks Gates\",\n" +
+                "    \"gender\": \"male\",\n" +
+                "    \"company\": \"TERRAGEN\",\n" +
+                "    \"email\": \"brooksgates@terragen.com\",\n" +
+                "    \"phone\": \"+1 (875) 483-2224\",\n" +
+                "    \"address\": \"562 Noll Street, Kipp, Louisiana, 7659\",\n" +
+                "    \"about\": \"Reprehenderit laboris mollit nulla commodo quis laborum commodo. Laborum aliquip laboris officia minim ipsum laborum ipsum reprehenderit quis laboris est sint culpa. Culpa magna aute mollit exercitation.\\r\\n\",\n" +
+                "    \"registered\": \"2016-05-04T10:34:38 +07:00\",\n" +
+                "    \"latitude\": 72.77079,\n" +
+                "    \"longitude\": -134.291768,\n" +
+                "    \"tags\": [\n" +
+                "      \"est\",\n" +
+                "      \"sunt\",\n" +
+                "      \"laboris\",\n" +
+                "      \"ea\",\n" +
+                "      \"proident\",\n" +
+                "      \"aute\",\n" +
+                "      \"excepteur\"\n" +
+                "    ],\n" +
+                "    \"friends\": [\n" +
+                "      {\n" +
+                "        \"id\": 0,\n" +
+                "        \"name\": \"Roxanne Morgan\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 1,\n" +
+                "        \"name\": \"Tamara Kelly\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 2,\n" +
+                "        \"name\": \"Cleveland Bush\"\n" +
+                "      }\n" +
+                "    ],\n" +
+                "    \"greeting\": \"Hello, Brooks Gates! You have 1 unread messages.\",\n" +
+                "    \"favoriteFruit\": \"banana\"\n" +
+                "  },\n" +
+                "  {\n" +
+                "    \"_id\": \"58309f3be746700e9af9a645\",\n" +
+                "    \"index\": 4,\n" +
+                "    \"guid\": \"54382bd6-c476-469d-9e1c-e546f959db51\",\n" +
+                "    \"isActive\": true,\n" +
+                "    \"balance\": \"$2,012.57\",\n" +
+                "    \"picture\": \"http://placehold.it/32x32\",\n" +
+                "    \"age\": 40,\n" +
+                "    \"eyeColor\": \"brown\",\n" +
+                "    \"name\": \"Jackie Thomas\",\n" +
+                "    \"gender\": \"female\",\n" +
+                "    \"company\": \"HINWAY\",\n" +
+                "    \"email\": \"jackiethomas@hinway.com\",\n" +
+                "    \"phone\": \"+1 (843) 470-2096\",\n" +
+                "    \"address\": \"910 Emerson Place, Gwynn, Federated States Of Micronesia, 4688\",\n" +
+                "    \"about\": \"Id cupidatat laboris elit est eiusmod esse nostrud. Ex commodo nisi voluptate est nisi laborum officia sint incididunt pariatur qui deserunt ullamco. Fugiat proident magna ipsum sit sint id adipisicing sit nostrud labore sit officia. Eiusmod exercitation non enim excepteur amet irure ullamco consectetur cupidatat proident Lorem reprehenderit aliquip. Veniam esse dolor Lorem incididunt proident officia enim in incididunt culpa. Mollit voluptate commodo aliquip anim ipsum nostrud ut labore enim labore qui do minim incididunt. Quis irure proident voluptate nisi qui sunt aute duis irure.\\r\\n\",\n" +
+                "    \"registered\": \"2014-08-03T09:21:43 +07:00\",\n" +
+                "    \"latitude\": 84.871256,\n" +
+                "    \"longitude\": 2.043339,\n" +
+                "    \"tags\": [\n" +
+                "      \"tempor\",\n" +
+                "      \"ut\",\n" +
+                "      \"deserunt\",\n" +
+                "      \"esse\",\n" +
+                "      \"nostrud\",\n" +
+                "      \"dolore\",\n" +
+                "      \"ex\"\n" +
+                "    ],\n" +
+                "    \"friends\": [\n" +
+                "      {\n" +
+                "        \"id\": 0,\n" +
+                "        \"name\": \"Lois Walters\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 1,\n" +
+                "        \"name\": \"Brewer Buchanan\"\n" +
+                "      },\n" +
+                "      {\n" +
+                "        \"id\": 2,\n" +
+                "        \"name\": \"Mccormick Fleming\"\n" +
+                "      }\n" +
+                "    ],\n" +
+                "    \"greeting\": \"Hello, Jackie Thomas! You have 2 unread messages.\",\n" +
+                "    \"favoriteFruit\": \"banana\"\n" +
+                "  }\n" +
+                "]";
+
+        JSONArray x1 = (JSONArray) new JSONTokener(new InputStreamReader(this.getClass().getResourceAsStream("/sample-01.json"))).nextValue();
+        JSONArray x2 = (JSONArray) new JSONTokener(ref).nextValue();
+
+        Assert.assertTrue(jsonEquals(x1, x2));
+    }
+
+    private boolean jsonEquals(JSONArray x1, JSONArray x2) throws JSONException {
+        if (x1.length() != x2.length()) {
+            return false;
+        }
+
+        for (int i = 0; i < x1.length(); i++) {
+            Object element1 = x1.get(i);
+            Object element2 = x2.get(i);
+            if (!jsonEquals(element1, element2)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private boolean jsonEquals(JSONObject x1, JSONObject x2) throws JSONException {
+        if (x1.length() != x2.length()) {
+            return false;
+        }
+        Set<String> names = x1.keySet();
+        for (String name : names) {
+            if (!jsonEquals(x1.get(name), x2.get(name))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private boolean jsonEquals(Object element1, Object element2) throws JSONException {
+        if (!element1.getClass().equals(element2.getClass())) {
+            return false;
+        }
+        if (element1 instanceof JSONObject) {
+            return jsonEquals((JSONObject) element1, (JSONObject) element2);
+        }
+        if (element1 instanceof JSONArray) {
+            return jsonEquals((JSONArray) element1, (JSONArray) element2);
+        }
+        return element1.equals(element2);
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/java/org/json/JSONArrayTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONArrayTest.java b/geode-json/src/test/java/org/json/JSONArrayTest.java
new file mode 100755
index 0000000..8f6632b
--- /dev/null
+++ b/geode-json/src/test/java/org/json/JSONArrayTest.java
@@ -0,0 +1,608 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+/**
+ * This black box test was written without inspecting the non-free org.json sourcecode.
+ */
+public class JSONArrayTest {
+    @Test
+    public void testEmptyArray() throws JSONException {
+        JSONArray array = new JSONArray();
+        assertEquals(0, array.length());
+        assertEquals("", array.join(" AND "));
+        try {
+            array.get(0);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            array.getBoolean(0);
+            fail();
+        } catch (JSONException ignored) {
+        }
+
+        assertEquals("[]", array.toString());
+        assertEquals("[]", array.toString(4));
+
+        // out of bounds is co-opted with defaulting
+        assertTrue(array.isNull(0));
+        assertNull(array.opt(0));
+        assertFalse(array.optBoolean(0));
+        assertTrue(array.optBoolean(0, true));
+
+        // bogus (but documented) behaviour: returns null rather than an empty object!
+        assertNull(array.toJSONObject(new JSONArray()));
+    }
+
+    @Test
+    public void testEqualsAndHashCode() throws JSONException {
+        JSONArray a = new JSONArray();
+        JSONArray b = new JSONArray();
+        assertTrue(a.equals(b));
+        assertEquals("equals() not consistent with hashCode()", a.hashCode(), b.hashCode());
+
+        a.put(true);
+        a.put(false);
+        b.put(true);
+        b.put(false);
+        assertTrue(a.equals(b));
+        assertEquals(a.hashCode(), b.hashCode());
+
+        b.put(true);
+        assertFalse(a.equals(b));
+        assertTrue(a.hashCode() != b.hashCode());
+    }
+
+    @Test
+    public void testBooleans() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put(true);
+        array.put(false);
+        array.put(2, false);
+        array.put(3, false);
+        array.put(2, true);
+        assertEquals("[true,false,true,false]", array.toString());
+        assertEquals(4, array.length());
+        assertEquals(Boolean.TRUE, array.get(0));
+        assertEquals(Boolean.FALSE, array.get(1));
+        assertEquals(Boolean.TRUE, array.get(2));
+        assertEquals(Boolean.FALSE, array.get(3));
+        assertFalse(array.isNull(0));
+        assertFalse(array.isNull(1));
+        assertFalse(array.isNull(2));
+        assertFalse(array.isNull(3));
+        assertEquals(true, array.optBoolean(0));
+        assertEquals(false, array.optBoolean(1, true));
+        assertEquals(true, array.optBoolean(2, false));
+        assertEquals(false, array.optBoolean(3));
+        assertEquals("true", array.getString(0));
+        assertEquals("false", array.getString(1));
+        assertEquals("true", array.optString(2));
+        assertEquals("false", array.optString(3, "x"));
+        assertEquals("[\n     true,\n     false,\n     true,\n     false\n]", array.toString(5));
+
+        JSONArray other = new JSONArray();
+        other.put(true);
+        other.put(false);
+        other.put(true);
+        other.put(false);
+        assertTrue(array.equals(other));
+        other.put(true);
+        assertFalse(array.equals(other));
+
+        other = new JSONArray();
+        other.put("true");
+        other.put("false");
+        other.put("truE");
+        other.put("FALSE");
+        assertFalse(array.equals(other));
+        assertFalse(other.equals(array));
+        assertEquals(true, other.getBoolean(0));
+        assertEquals(false, other.optBoolean(1, true));
+        assertEquals(true, other.optBoolean(2));
+        assertEquals(false, other.getBoolean(3));
+    }
+
+    // http://code.google.com/p/android/issues/detail?id=16411
+    @Test
+    public void testCoerceStringToBoolean() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put("maybe");
+        try {
+            array.getBoolean(0);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals(false, array.optBoolean(0));
+        assertEquals(true, array.optBoolean(0, true));
+    }
+
+    @Test
+    public void testNulls() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put(3, null);
+        array.put(0, JSONObject.NULL);
+        assertEquals(4, array.length());
+        assertEquals("[null,null,null,null]", array.toString());
+
+        // there's 2 ways to represent null; each behaves differently!
+        assertEquals(JSONObject.NULL, array.get(0));
+        try {
+            array.get(1);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            array.get(2);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            array.get(3);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals(JSONObject.NULL, array.opt(0));
+        assertEquals(null, array.opt(1));
+        assertEquals(null, array.opt(2));
+        assertEquals(null, array.opt(3));
+        assertTrue(array.isNull(0));
+        assertTrue(array.isNull(1));
+        assertTrue(array.isNull(2));
+        assertTrue(array.isNull(3));
+        assertEquals("null", array.optString(0));
+        assertEquals("", array.optString(1));
+        assertEquals("", array.optString(2));
+        assertEquals("", array.optString(3));
+    }
+
+    /**
+     * Our behaviour is questioned by this bug:
+     * http://code.google.com/p/android/issues/detail?id=7257
+     */
+    @Test
+    public void testParseNullYieldsJSONObjectNull() throws JSONException {
+        JSONArray array = new JSONArray("[\"null\",null]");
+        array.put(null);
+        assertEquals("null", array.get(0));
+        assertEquals(JSONObject.NULL, array.get(1));
+        try {
+            array.get(2);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        assertEquals("null", array.getString(0));
+        assertEquals("null", array.getString(1));
+        try {
+            array.getString(2);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testNumbers() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put(Double.MIN_VALUE);
+        array.put(9223372036854775806L);
+        array.put(Double.MAX_VALUE);
+        array.put(-0d);
+        assertEquals(4, array.length());
+
+        // toString() and getString(int) return different values for -0d
+        assertEquals("[4.9E-324,9223372036854775806,1.7976931348623157E308,-0]", array.toString());
+
+        assertEquals(Double.MIN_VALUE, array.get(0));
+        assertEquals(9223372036854775806L, array.get(1));
+        assertEquals(Double.MAX_VALUE, array.get(2));
+        assertEquals(-0d, array.get(3));
+        assertEquals(Double.MIN_VALUE, array.getDouble(0), 0);
+        assertEquals(9.223372036854776E18, array.getDouble(1), 0);
+        assertEquals(Double.MAX_VALUE, array.getDouble(2), 0);
+        assertEquals(-0d, array.getDouble(3), 0);
+        assertEquals(0, array.getLong(0));
+        assertEquals(9223372036854775806L, array.getLong(1));
+        assertEquals(Long.MAX_VALUE, array.getLong(2));
+        assertEquals(0, array.getLong(3));
+        assertEquals(0, array.getInt(0));
+        assertEquals(-2, array.getInt(1));
+        assertEquals(Integer.MAX_VALUE, array.getInt(2));
+        assertEquals(0, array.getInt(3));
+        assertEquals(Double.MIN_VALUE, array.opt(0));
+        assertEquals(Double.MIN_VALUE, array.optDouble(0), 0);
+        assertEquals(0, array.optLong(0, 1L));
+        assertEquals(0, array.optInt(0, 1));
+        assertEquals("4.9E-324", array.getString(0));
+        assertEquals("9223372036854775806", array.getString(1));
+        assertEquals("1.7976931348623157E308", array.getString(2));
+        assertEquals("-0.0", array.getString(3));
+
+        JSONArray other = new JSONArray();
+        other.put(Double.MIN_VALUE);
+        other.put(9223372036854775806L);
+        other.put(Double.MAX_VALUE);
+        other.put(-0d);
+        assertTrue(array.equals(other));
+        other.put(0, 0L);
+        assertFalse(array.equals(other));
+    }
+
+    @Test
+    public void testStrings() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put("true");
+        array.put("5.5");
+        array.put("9223372036854775806");
+        array.put("null");
+        array.put("5\"8' tall");
+        assertEquals(5, array.length());
+        assertEquals("[\"true\",\"5.5\",\"9223372036854775806\",\"null\",\"5\\\"8' tall\"]",
+                array.toString());
+
+        // although the documentation doesn't mention it, join() escapes text and wraps
+        // strings in quotes
+        assertEquals("\"true\" \"5.5\" \"9223372036854775806\" \"null\" \"5\\\"8' tall\"",
+                array.join(" "));
+
+        assertEquals("true", array.get(0));
+        assertEquals("null", array.getString(3));
+        assertEquals("5\"8' tall", array.getString(4));
+        assertEquals("true", array.opt(0));
+        assertEquals("5.5", array.optString(1));
+        assertEquals("9223372036854775806", array.optString(2, null));
+        assertEquals("null", array.optString(3, "-1"));
+        assertFalse(array.isNull(0));
+        assertFalse(array.isNull(3));
+
+        assertEquals(true, array.getBoolean(0));
+        assertEquals(true, array.optBoolean(0));
+        assertEquals(true, array.optBoolean(0, false));
+        assertEquals(0, array.optInt(0));
+        assertEquals(-2, array.optInt(0, -2));
+
+        assertEquals(5.5d, array.getDouble(1), 0);
+        assertEquals(5L, array.getLong(1));
+        assertEquals(5, array.getInt(1));
+        assertEquals(5, array.optInt(1, 3));
+
+        // The last digit of the string is a 6 but getLong returns a 7. It's probably parsing as a
+        // double and then converting that to a long. This is consistent with JavaScript.
+        assertEquals(9223372036854775807L, array.getLong(2));
+        assertEquals(9.223372036854776E18, array.getDouble(2), 0);
+        assertEquals(Integer.MAX_VALUE, array.getInt(2));
+
+        assertFalse(array.isNull(3));
+        try {
+            array.getDouble(3);
+            fail();
+        } catch (JSONException e) {
+            // expected
+        }
+        assertEquals(Double.NaN, array.optDouble(3), 0);
+        assertEquals(-1.0d, array.optDouble(3, -1.0d), 0);
+    }
+
+    @Test
+    public void testJoin() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put(null);
+        assertEquals("null", array.join(" & "));
+        array.put("\"");
+        assertEquals("null & \"\\\"\"", array.join(" & "));
+        array.put(5);
+        assertEquals("null & \"\\\"\" & 5", array.join(" & "));
+        array.put(true);
+        assertEquals("null & \"\\\"\" & 5 & true", array.join(" & "));
+        array.put(new JSONArray(Arrays.asList(true, false)));
+        assertEquals("null & \"\\\"\" & 5 & true & [true,false]", array.join(" & "));
+        array.put(new JSONObject(Collections.singletonMap("x", 6)));
+        assertEquals("null & \"\\\"\" & 5 & true & [true,false] & {\"x\":6}", array.join(" & "));
+    }
+
+    @Test
+    public void testJoinWithNull() throws JSONException {
+        JSONArray array = new JSONArray(Arrays.asList(5, 6));
+        assertEquals("5null6", array.join(null));
+    }
+
+    @Test
+    public void testJoinWithSpecialCharacters() throws JSONException {
+        JSONArray array = new JSONArray(Arrays.asList(5, 6));
+        assertEquals("5\"6", array.join("\""));
+    }
+
+    @Test
+    public void testToJSONObject() throws JSONException {
+        JSONArray keys = new JSONArray();
+        keys.put("a");
+        keys.put("b");
+
+        JSONArray values = new JSONArray();
+        values.put(5.5d);
+        values.put(false);
+
+        JSONObject object = values.toJSONObject(keys);
+        assertEquals(5.5d, object.get("a"));
+        assertEquals(false, object.get("b"));
+
+        keys.put(0, "a");
+        values.put(0, 11.0d);
+        assertEquals(5.5d, object.get("a"));
+    }
+
+    @Test
+    public void testToJSONObjectWithNulls() throws JSONException {
+        JSONArray keys = new JSONArray();
+        keys.put("a");
+        keys.put("b");
+
+        JSONArray values = new JSONArray();
+        values.put(5.5d);
+        values.put(null);
+
+        // null values are stripped!
+        JSONObject object = values.toJSONObject(keys);
+        assertEquals(1, object.length());
+        assertFalse(object.has("b"));
+        assertEquals("{\"a\":5.5}", object.toString());
+    }
+
+    @Test
+    public void testToJSONObjectMoreNamesThanValues() throws JSONException {
+        JSONArray keys = new JSONArray();
+        keys.put("a");
+        keys.put("b");
+        JSONArray values = new JSONArray();
+        values.put(5.5d);
+        JSONObject object = values.toJSONObject(keys);
+        assertEquals(1, object.length());
+        assertEquals(5.5d, object.get("a"));
+    }
+
+    @Test
+    public void testToJSONObjectMoreValuesThanNames() throws JSONException {
+        JSONArray keys = new JSONArray();
+        keys.put("a");
+        JSONArray values = new JSONArray();
+        values.put(5.5d);
+        values.put(11.0d);
+        JSONObject object = values.toJSONObject(keys);
+        assertEquals(1, object.length());
+        assertEquals(5.5d, object.get("a"));
+    }
+
+    @Test
+    public void testToJSONObjectNullKey() throws JSONException {
+        JSONArray keys = new JSONArray();
+        keys.put(JSONObject.NULL);
+        JSONArray values = new JSONArray();
+        values.put(5.5d);
+        JSONObject object = values.toJSONObject(keys);
+        assertEquals(1, object.length());
+        assertEquals(5.5d, object.get("null"));
+    }
+
+    @Test
+    public void testPutUnsupportedNumbers() throws JSONException {
+        JSONArray array = new JSONArray();
+
+        try {
+            array.put(Double.NaN);
+            fail();
+        } catch (JSONException e) {
+            // expected
+        }
+        try {
+            array.put(0, Double.NEGATIVE_INFINITY);
+            fail();
+        } catch (JSONException e) {
+            // expected
+        }
+        try {
+            array.put(0, Double.POSITIVE_INFINITY);
+            fail();
+        } catch (JSONException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testPutUnsupportedNumbersAsObject() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put(Double.valueOf(Double.NaN));
+        array.put(Double.valueOf(Double.NEGATIVE_INFINITY));
+        array.put(Double.valueOf(Double.POSITIVE_INFINITY));
+        assertEquals(null, array.toString());
+    }
+
+    /**
+     * Although JSONArray is usually defensive about which numbers it accepts,
+     * it doesn't check inputs in its constructor.
+     */
+    @Test
+    public void testCreateWithUnsupportedNumbers() throws JSONException {
+        JSONArray array = new JSONArray(Arrays.asList(5.5, Double.NaN));
+        assertEquals(2, array.length());
+        assertEquals(5.5, array.getDouble(0), 0);
+        assertEquals(Double.NaN, array.getDouble(1), 0);
+    }
+
+    @Test
+    public void testToStringWithUnsupportedNumbers() throws JSONException {
+        // when the array contains an unsupported number, toString returns null!
+        JSONArray array = new JSONArray(Arrays.asList(5.5, Double.NaN));
+        assertNull(array.toString());
+    }
+
+    @Test
+    public void testListConstructorCopiesContents() throws JSONException {
+        // have to use asList instead of Collections.singleton() to allow mutation
+        //noinspection ArraysAsListWithZeroOrOneArgument
+        List<Object> contents = Arrays.<Object>asList(5);
+        JSONArray array = new JSONArray(contents);
+        contents.set(0, 10);
+        assertEquals(5, array.get(0));
+    }
+
+    @Test
+    public void testTokenerConstructor() throws JSONException {
+        JSONArray object = new JSONArray(new JSONTokener("[false]"));
+        assertEquals(1, object.length());
+        assertEquals(false, object.get(0));
+    }
+
+    @Test
+    public void testTokenerConstructorWrongType() throws JSONException {
+        try {
+            new JSONArray(new JSONTokener("{\"foo\": false}"));
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testTokenerConstructorNull() throws JSONException {
+        try {
+            new JSONArray((JSONTokener) null);
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+    }
+
+    @Test
+    public void testTokenerConstructorParseFail() {
+        try {
+            new JSONArray(new JSONTokener("["));
+            fail();
+        } catch (JSONException ignored) {
+        } catch (StackOverflowError e) {
+            fail("Stack overflowed on input: \"[\"");
+        }
+    }
+
+    @Test
+    public void testStringConstructor() throws JSONException {
+        JSONArray object = new JSONArray("[false]");
+        assertEquals(1, object.length());
+        assertEquals(false, object.get(0));
+    }
+
+    @Test
+    public void testStringConstructorWrongType() throws JSONException {
+        try {
+            new JSONArray("{\"foo\": false}");
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void testStringConstructorNull() throws JSONException {
+        try {
+            new JSONArray((String) null);
+            fail();
+        } catch (NullPointerException ignored) {
+        }
+    }
+
+    @Test
+    public void testStringConstructorParseFail() {
+        try {
+            new JSONArray("[");
+            fail();
+        } catch (JSONException ignored) {
+        } catch (StackOverflowError e) {
+            fail("Stack overflowed on input: \"[\"");
+        }
+    }
+
+    @Test
+    public void testCreate() throws JSONException {
+        JSONArray array = new JSONArray(Arrays.asList(5.5, true));
+        assertEquals(2, array.length());
+        assertEquals(5.5, array.getDouble(0), 0.0);
+        assertEquals(true, array.get(1));
+        assertEquals("[5.5,true]", array.toString());
+    }
+
+    @Test
+    public void testAccessOutOfBounds() throws JSONException {
+        JSONArray array = new JSONArray();
+        array.put("foo");
+        assertEquals(null, array.opt(3));
+        assertEquals(null, array.opt(-3));
+        assertEquals("", array.optString(3));
+        assertEquals("", array.optString(-3));
+        try {
+            array.get(3);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            array.get(-3);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            array.getString(3);
+            fail();
+        } catch (JSONException ignored) {
+        }
+        try {
+            array.getString(-3);
+            fail();
+        } catch (JSONException ignored) {
+        }
+    }
+
+    @Test
+    public void test_remove() throws Exception {
+        JSONArray a = new JSONArray();
+        assertEquals(null, a.remove(-1));
+        assertEquals(null, a.remove(0));
+
+        a.put("hello");
+        assertEquals(null, a.remove(-1));
+        assertEquals(null, a.remove(1));
+        assertEquals("hello", a.remove(0));
+        assertEquals(null, a.remove(0));
+    }
+
+    enum MyEnum { A, B, C }
+
+    // https://code.google.com/p/android/issues/detail?id=62539
+    // but changed in open-json to return toString for all enums
+    @Test
+    public void testEnums() throws Exception {
+        // This works because it's in java.* and any class in there falls back to toString.
+        JSONArray a1 = new JSONArray(java.lang.annotation.RetentionPolicy.values());
+        assertEquals("[\"SOURCE\",\"CLASS\",\"RUNTIME\"]", a1.toString());
+
+        // This doesn't because it's not.
+        JSONArray a2 = new JSONArray(MyEnum.values());
+        assertEquals("[\"A\",\"B\",\"C\"]", a2.toString());
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/test/java/org/json/JSONFunctionTestObject.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONFunctionTestObject.java b/geode-json/src/test/java/org/json/JSONFunctionTestObject.java
new file mode 100755
index 0000000..fe18ab6
--- /dev/null
+++ b/geode-json/src/test/java/org/json/JSONFunctionTestObject.java
@@ -0,0 +1,17 @@
+package org.json;
+
+/**
+ * Class to test the function hack
+ */
+public class JSONFunctionTestObject {
+    private String value;
+
+    public JSONFunctionTestObject(String value) {
+        this.value = value;
+    }
+
+    @Override
+    public String toString() {
+        return value;
+    }
+}
\ No newline at end of file


[48/51] [abbrv] geode git commit: Overhauling the javadocs for the LuceneService

Posted by ds...@apache.org.
Overhauling the javadocs for the LuceneService

Enhancing the javadocs with more detailed descriptions of what the
classes do, adding links to lucene classes where appropriate, and
removing some cruft that didn't match the current implementation.

This closes #410


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c0633c8d
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c0633c8d
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c0633c8d

Branch: refs/heads/feature/GEM-1195
Commit: c0633c8d612847fc284cd8b3f09a4aac214c8a1f
Parents: 6118d54
Author: Dan Smith <up...@apache.org>
Authored: Fri Feb 24 17:58:09 2017 -0800
Committer: Dan Smith <up...@apache.org>
Committed: Thu Mar 2 14:46:35 2017 -0800

----------------------------------------------------------------------
 geode-assembly/build.gradle                     |   2 +
 .../apache/geode/cache/lucene/LuceneIndex.java  |  17 ++-
 .../apache/geode/cache/lucene/LuceneQuery.java  |  41 +++++-
 .../cache/lucene/LuceneQueryException.java      |   2 +-
 .../geode/cache/lucene/LuceneQueryFactory.java  |  63 +++++---
 .../geode/cache/lucene/LuceneQueryProvider.java |  24 +--
 .../geode/cache/lucene/LuceneResultStruct.java  |  17 +--
 .../geode/cache/lucene/LuceneService.java       | 145 ++++++++++++-------
 .../cache/lucene/LuceneServiceProvider.java     |   2 +-
 .../lucene/PageableLuceneQueryResults.java      |  22 +--
 .../lucene/internal/LuceneQueryFactoryImpl.java |   8 +
 .../apache/geode/cache/lucene/package-info.java |   8 +-
 12 files changed, 226 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index cce5245..1900896 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -214,6 +214,8 @@ task gfshDepsJar (type: Jar, dependsOn: ':geode-core:classes') {
 def docsDir = file("$buildDir/javadocs")
 task docs(type: Javadoc) {
     options.addStringOption('Xdoclint:none', '-quiet')
+    options.links("https://lucene.apache.org/core/6_4_1/core/")
+    options.links("https://lucene.apache.org/core/6_4_1/queryparser/")
     options.encoding='UTF-8'
     source parent.subprojects*.javadoc*.source
     classpath = files(parent.subprojects*.javadoc*.classpath)

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java
index 1069f74..f13c8b3 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneIndex.java
@@ -23,34 +23,35 @@ import org.apache.geode.annotations.Experimental;
 
 
 /**
- * An lucene index is built over the data stored in a GemFire Region.
  * <p>
- * An index is specified using a index name, field names, region name.
- * <p>
- * The index name and region name together uniquely identifies the lucene index.
+ * An Lucene index is built over the data stored in a GemFire Region.
+ * </p>
  * <p>
+ * An index is specified using a index name, field names, region name.
+ * </p>
+ * The index name and region name together uniquely identifies the Lucene index.
  * 
  */
 @Experimental
 public interface LuceneIndex {
 
   /**
-   * @return the index name of this index
+   * @return the name of this index
    */
   public String getName();
 
   /**
-   * @return the region name for this index
+   * @return the name of the region that is being indexed
    */
   public String getRegionPath();
 
   /**
-   * @return the indexed field names in a Set
+   * @return the indexed field names
    */
   public String[] getFieldNames();
 
   /**
-   * @return the field to analyzer map
+   * @return a map of what {@link Analyzer} is being used for each indexed field.
    */
   public Map<String, Analyzer> getFieldAnalyzers();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java
index 1afb35a..1218dcc 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQuery.java
@@ -20,30 +20,57 @@ import java.util.List;
 import org.apache.geode.annotations.Experimental;
 
 /**
- * Provides wrapper object of Lucene's Query object and execute the search.
  * <p>
- * Instances of this interface are created using {@link LuceneQueryFactory#create}.
- * 
+ * A query on a Lucene index. Instances of this interface are created using
+ * {@link LuceneQueryFactory#create}. Once this query is constructed, use one of the find methods to
+ * find region entries that match this query.
+ * </p>
+ * <p>
+ * Instances obtained from {@link LuceneQueryFactory} are immutable, so they are safe for reuse and
+ * can be shared by multiple threads.
+ * </p>
+ * <p>
+ * Because Lucene indexes are maintained asynchronously, results returned from the find methods may
+ * not reflect the most recent updates to the region.
+ * </p>
+ * <p>
+ * Results are returned in order of their score with respect to this query. See
+ * {@link org.apache.lucene.search} for details on how Lucene scores entries.
+ * </p>
  */
 @Experimental
 public interface LuceneQuery<K, V> {
   /**
-   * Execute search and return keys.
+   * Execute the query and return the region keys that match this query, up to the limit specified
+   * by {@link #getLimit()}.
+   * 
+   * @throws LuceneQueryException if the query could not be parsed or executed.
    */
   public Collection<K> findKeys() throws LuceneQueryException;
 
   /**
-   * Execute search and return values.
+   * Execute the query and return the region values that match this query, up to the limit specified
+   * by {@link #getLimit()}
+   * 
+   * @throws LuceneQueryException if the query could not be parsed or executed.
    */
   public Collection<V> findValues() throws LuceneQueryException;
 
   /**
-   * Execute search and return list of LuceneResultStruct.
+   * Execute the query and return a list of {@link LuceneResultStruct}s that match this query, up to
+   * the limit specified by {@link #getLimit()} A {@link LuceneResultStruct} contains the region
+   * key, value, and a score for that entry.
+   *
+   * @throws LuceneQueryException if the query could not be parsed or executed.
    */
   public List<LuceneResultStruct<K, V>> findResults() throws LuceneQueryException;
 
   /**
-   * Execute the search and get results.
+   * Execute the query and get a {@link PageableLuceneQueryResults}. The
+   * {@link PageableLuceneQueryResults} provides the ability to fetch a page of results at a time,
+   * as specified by {@link #getPageSize()}
+   *
+   * @throws LuceneQueryException if the query could not be parsed or executed.
    */
   public PageableLuceneQueryResults<K, V> findPages() throws LuceneQueryException;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java
index 98c313e..dde8f9a 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryException.java
@@ -18,7 +18,7 @@ package org.apache.geode.cache.lucene;
 import org.apache.geode.GemFireCheckedException;
 
 /**
- * Thrown when a lucene query fails.
+ * Thrown when a Lucene query fails.
  */
 public class LuceneQueryException extends GemFireCheckedException {
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java
index 174e7e1..f4bd21c 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryFactory.java
@@ -14,17 +14,22 @@
  */
 package org.apache.geode.cache.lucene;
 
+import org.apache.geode.cache.query.Query;
 import org.apache.lucene.queryparser.classic.ParseException;
 
 import org.apache.geode.annotations.Experimental;
+import org.apache.lucene.queryparser.flexible.standard.StandardQueryParser;
 
 /**
- * Factory for creating instances of {@link LuceneQuery}. To get an instance of this factory call
+ * Factory for configuring a Lucene query. Use this factory to set parameters of the query such as
+ * page size, result limit, and query expression. To get an instance of this factory call
  * {@link LuceneService#createLuceneQueryFactory}.
  * <P>
- * To use this factory configure it with the <code>set</code> methods and then call {@link #create}
- * to produce a {@link LuceneQuery} instance.
- * 
+ * To use this factory configure it with the <code>set</code> methods and then call one of the
+ * create methods on this class. {@link #create(String, String, String, String)} creates a query by
+ * parsing a query string. {@link #create(String, String, LuceneQueryProvider)} creates a query
+ * based on a custom Lucene {@link Query} object.
+ *
  */
 @Experimental
 public interface LuceneQueryFactory {
@@ -40,32 +45,34 @@ public interface LuceneQueryFactory {
   public static final int DEFAULT_PAGESIZE = 0;
 
   /**
-   * Set page size for a query result. The default page size is 0 which means no pagination. If
-   * specified negative value, throw IllegalArgumentException
-   * 
+   * Set page size for a query result. The default page size is 0 which means no pagination.
+   *
    * @param pageSize
    * @return itself
+   * @throws IllegalArgumentException if the value is less than 0
    */
   LuceneQueryFactory setPageSize(int pageSize);
 
   /**
-   * Set max limit of result for a query If specified limit is less or equal to zero, throw
-   * IllegalArgumentException
-   * 
+   * Set maximum number of results for a query. By default, the limit is set to
+   * {@link #DEFAULT_LIMIT} which is 100.
+   *
    * @param limit
    * @return itself
+   * @throws IllegalArgumentException if the value is less than or equal to zero.
    */
   LuceneQueryFactory setResultLimit(int limit);
 
   /**
-   * Create wrapper object for lucene's QueryParser object using default standard analyzer. The
-   * queryString is using lucene QueryParser's syntax. QueryParser is for easy-to-use with human
-   * understandable syntax.
-   * 
+   * Creates a query based on a query string which is parsed by Lucene's
+   * {@link StandardQueryParser}. See the javadocs for {@link StandardQueryParser} for details on
+   * the syntax of the query string. The query string and default field as passed as is to
+   * {@link StandardQueryParser#parse(String, String)}
+   *
    * @param regionName region name
    * @param indexName index name
-   * @param queryString query string in lucene QueryParser's syntax
-   * @param defaultField default field used by the Lucene Query Parser
+   * @param queryString Query string parsed by Lucene's StandardQueryParser
+   * @param defaultField default field used by the Lucene's StandardQueryParser
    * @param <K> the key type in the query results
    * @param <V> the value type in the query results
    * @return LuceneQuery object
@@ -74,13 +81,29 @@ public interface LuceneQueryFactory {
       String defaultField);
 
   /**
-   * Creates a wrapper object for Lucene's Query object. This {@link LuceneQuery} builder method
-   * could be used in advanced cases, such as cases where Lucene's Query object construction needs
-   * Lucene's API over query string.
+   * <p>
+   * Create a query based on a programatically constructed Lucene {@link Query}. This can be used
+   * for queries that are not covered by {@link StandardQueryParser}, such as range queries.
+   * </p>
+   * <p>
+   * Because Geode may execute the Lucene query on multiple nodes in parallel and {@link Query} is
+   * not serializable, this method requires a serializable {@link LuceneQueryProvider} that can
+   * create a {@link Query} on the nodes hosting the Lucene index.
+   * </p>
+   * <p>
+   * Here's an example of using this method to create a range query on an integer field called
+   * "age."
+   * </p>
    * 
+   * <pre>
+   * {@code
+   *   LuceneQuery query = factory.create("index", "region", index -> IntPoint.newRangeQuery("age", 20, 30))
+   * }
+   * </pre>
+   *
    * @param indexName index name
    * @param regionName region name
-   * @param provider constructs and provides a Lucene Query object
+   * @param provider constructs and provides a Lucene {@link Query}.
    * @param <K> the key type in the query results
    * @param <V> the value type in the query results
    * @return LuceneQuery object

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java
index 8b1064e..2611293 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneQueryProvider.java
@@ -15,28 +15,32 @@
 
 package org.apache.geode.cache.lucene;
 
+import java.io.DataOutput;
 import java.io.Serializable;
 
+import org.apache.geode.DataSerializer;
 import org.apache.lucene.search.Query;
 
 import org.apache.geode.annotations.Experimental;
 import org.apache.geode.cache.query.QueryException;
 
 /**
- * The instances of this class will be used for distributing Lucene Query objects and
- * re-constructing the Query object. If necessary the implementation needs to take care of
- * serializing and de-serializing Lucene Query object. Geode respects the DataSerializable contract
- * to provide optimal object serialization. For instance, {@link LuceneQueryProvider}'s toData
- * method will be used to serialize it when it is sent to another member of the distributed system.
- * Implementation of DataSerializable can provide a zero-argument constructor that will be invoked
- * when they are read with DataSerializer.readObject.
+ * <p>
+ * A factory for {@link Query} objects. An implementation of this interface is required by
+ * {@link LuceneQueryFactory#create(String, String, LuceneQueryProvider)} so that a query can be
+ * serialized and distributed to multiple nodes.
+ * </p>
+ * Instances of this interface are serialized using the standard
+ * {@link DataSerializer#writeObject(Object, DataOutput)},
  */
 @Experimental
+@FunctionalInterface
 public interface LuceneQueryProvider extends Serializable {
   /**
-   * @return A Lucene Query object which could be used for executing Lucene Search on indexed data
-   * @param index local lucene index the query is being constructed against.
-   * @throws LuceneQueryException if the provider fails to construct the query object
+   * @return A {@link Query} which will be executed against a Lucene index.
+   * @param index The {@link LuceneIndex} the query is being executed against.
+   * @throws LuceneQueryException if the provider fails to construct the query object. This will be
+   *         propagated to callers of the {@link LuceneQuery} find methods.
    */
 
   public Query getQuery(LuceneIndex index) throws LuceneQueryException;

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
index b922185..4a6481f 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneResultStruct.java
@@ -17,34 +17,29 @@ package org.apache.geode.cache.lucene;
 import org.apache.geode.annotations.Experimental;
 
 /**
- * <p>
- * Abstract data structure for one item in query result.
+ * A single result of a Lucene query.
  * 
  */
 @Experimental
 public interface LuceneResultStruct<K, V> {
 
   /**
-   * Return key of the entry
+   * @return The region key of the entry matching the query
    *
-   * @return key
-   * @throws IllegalArgumentException If this struct does not contain key
    */
   public K getKey();
 
   /**
-   * Return value of the entry
+   * @return the region value of the entry matching the query.
    *
-   * @return value the whole domain object
-   * @throws IllegalArgumentException If this struct does not contain value
    */
   public V getValue();
 
   /**
-   * Return score of the query
+   * Return score the score of the entry matching the query. Scores are computed by Lucene based on
+   * how closely documents match the query. See {@link org.apache.lucene.search} for details on how
+   * scores are computed.
    *
-   * @return score
-   * @throws IllegalArgumentException If this struct does not contain score
    */
   public float getScore();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
index 704abcd..f035442 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
@@ -19,6 +19,7 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.DataPolicy;
 import org.apache.lucene.analysis.Analyzer;
 
 import org.apache.geode.annotations.Experimental;
@@ -26,82 +27,110 @@ import org.apache.geode.cache.GemFireCache;
 import org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile;
 
 /**
- * LuceneService instance is a singleton for each cache.
- * 
- * It provides handle for managing the {@link LuceneIndex} and create the {@link LuceneQuery} via
- * {@link LuceneQueryFactory}
- * 
+ *
+ * The LuceneService provides the capability to create Lucene indexes and execute lucene queries on
+ * data stored in Geode regions. The Lucene indexes are automatically maintained by Geode whenever
+ * entries are updated in the associated regions.
+ *
+ * <p>
+ * To obtain an instance of LuceneService, use {@link LuceneServiceProvider#get(GemFireCache)}.
+ * </p>
+ * <p>
+ * Lucene indexes can be created using gfsh, xml, or the java API. Below is an example of creating a
+ * Lucene index with the java API. The Lucene index created on each member that will host data for
+ * the region.
  * </p>
- * Example: <br>
  * 
  * <pre>
- * At client and server JVM, initializing cache will create the LuceneServiceImpl object, 
- * which is a singleton at each JVM. 
- * 
- * At each server JVM, for data region to create index, create the index on fields with default analyzer:
- * LuceneIndex index = luceneService.createIndex(indexName, regionName, "field1", "field2", "field3"); 
- * or create index on fields with specified analyzer:
- * LuceneIndex index = luceneService.createIndex(indexName, regionName, analyzerPerField);
- * 
- * We can also create index via cache.xml or gfsh.
- * 
- * At client side, create query and run the search:
- * 
- * LuceneQuery query = luceneService.createLuceneQueryFactory().setLimit(200).setPageSize(20)
- * .setResultTypes(SCORE, VALUE, KEY).setFieldProjection("field1", "field2")
- * .create(indexName, regionName, querystring, analyzer);
- * 
- * The querystring is using lucene's queryparser syntax, such as "field1:zhou* AND field2:gzhou@pivotal.io"
- *  
- * PageableLuceneQueryResults results = query.search();
- * 
- * If pagination is not specified:
- * List list = results.getNextPage(); // return all results in one getNextPage() call
- * or if paging is specified:
- * if (results.hasNextPage()) {
- *   List page = results.nextPage(); // return resules page by page
+ * {
+ *   &#64;code
+ *   LuceneIndex index =
+ *       luceneService.createIndex(indexName, regionName, "field1", "field2", "field3");
  * }
- * 
- * The item of the list is either the domain object or instance of {@link LuceneResultStruct}
  * </pre>
+ * <p>
+ * You can also specify what {@link Analyzer} to use for each field.
+ * </p>
  * 
+ * <pre>
+ * {
+ *   &#64;code
+ *   LuceneIndex index = luceneService.createIndex(indexName, regionName, analyzerPerField);
+ * }
+ * </pre>
+ *
+ * Indexes should be created on all peers that host the region being indexed. Clients do not need to
+ * define the index, they can directly execute queries using this service.
+ *
+ * <p>
+ * Queries on this service can return either the region keys, values, or both that match a Lucene
+ * query expression. To execute a query, start with the {@link #createLuceneQueryFactory()} method.
+ * </p>
  *
+ * <pre>
+ * {
+ *   &#64;code
+ *   LuceneQuery query = luceneService.createLuceneQueryFactory().setLimit(200).create(indexName,
+ *       regionName, "name:John AND zipcode:97006", defaultField);
+ *   Collection<Object> results = query.findValues();
+ * }
+ * </pre>
+ *
+ * <p>
+ * The Lucene index data is colocated with the region that is indexed. This means that the index
+ * data will be partitioned, copied, or persisted using the same configuration options you provide
+ * for the region that is indexed. Queries will automatically be distributed in parallel to cover
+ * all partitions of a partitioned region.
+ * </p>
+ * <p>
+ * Indexes are maintained asynchronously, so changes to regions may not be immediately reflected in
+ * the index. This means that queries executed using this service may return stale results. Use the
+ * {@link #waitUntilFlushed(String, String, long, TimeUnit)} method if you need to wait for your
+ * changes to be indexed before executing a query, however this method should be used sparingly
+ * because it is an expensive operation.
+ * </p>
+ *
+ * <p>
+ * Currently, only partitioned regions are supported. Creating an index on a region with
+ * {@link DataPolicy#REPLICATE} will fail.
+ * </p>
+ * 
  */
 @Experimental
 public interface LuceneService {
 
   /**
    * A special field name that indicates that the entire region value should be indexed. This will
-   * only work if the region value is a String or Number, in which case a lucene document will be
+   * only work if the region value is a String or Number, in which case a Lucene document will be
    * created with a single field with this name.
    */
-  String REGION_VALUE_FIELD = "__REGION_VALUE_FIELD";
+  public String REGION_VALUE_FIELD = "__REGION_VALUE_FIELD";
 
   /**
-   * Create a lucene index using default analyzer.
+   * Create a Lucene index using default analyzer.
    * 
    * @param fields The fields of the object to index. Only fields listed here will be stored in the
    *        index. Fields should map to PDX fieldNames if the object is serialized with PDX, or to
-   *        java fields on the object otherwise. The special field name
-   *        {{@link #REGION_VALUE_FIELD}} indicates that the entire value should be stored as a
-   *        single field in the index.
+   *        java fields on the object otherwise. The special field name {@link #REGION_VALUE_FIELD}
+   *        indicates that the entire value should be stored as a single field in the index.
    */
   public void createIndex(String indexName, String regionPath, String... fields);
 
   /**
-   * Create a lucene index using specified analyzer per field
+   * Create a Lucene index using specified {@link Analyzer} per field. Analyzers are used by Lucene
+   * to tokenize your field into individual words.
    * 
    * @param indexName index name
    * @param regionPath region name
    * @param analyzerPerField A map of fields to analyzers. See
-   *        {{@link #createIndex(String, String, String...)}} for details on valid values for
-   *        fields. Each field will be tokenized using the provided Analyzer.
+   *        {@link #createIndex(String, String, String...)} for details on valid values for fields.
+   *        Each field will be tokenized using the provided Analyzer.
    */
   public void createIndex(String indexName, String regionPath,
       Map<String, Analyzer> analyzerPerField);
 
   /**
-   * Destroy the lucene index
+   * Destroy the Lucene index
    *
    * @param indexName the name of the index to destroy
    * @param regionPath the path of the region whose index to destroy
@@ -109,14 +138,14 @@ public interface LuceneService {
   public void destroyIndex(String indexName, String regionPath);
 
   /**
-   * Destroy all the lucene indexes for the region
+   * Destroy all the Lucene indexes for the region
    *
    * @param regionPath The path of the region on which to destroy the indexes
    */
   public void destroyIndexes(String regionPath);
 
   /**
-   * Get the lucene index object specified by region name and index name
+   * Get the Lucene index object specified by region name and index name
    * 
    * @param indexName index name
    * @param regionPath region name
@@ -125,16 +154,14 @@ public interface LuceneService {
   public LuceneIndex getIndex(String indexName, String regionPath);
 
   /**
-   * get all the lucene indexes.
+   * get all the Lucene indexes.
    * 
    * @return all index objects in a Collection
    */
   public Collection<LuceneIndex> getAllIndexes();
 
   /**
-   * create LuceneQueryFactory
-   * 
-   * @return LuceneQueryFactory object
+   * Create a factory for building a Lucene query.
    */
   public LuceneQueryFactory createLuceneQueryFactory();
 
@@ -146,14 +173,24 @@ public interface LuceneService {
   public Cache getCache();
 
 
-  /**
-   * wait until the current entries in cache are indexed
-   * 
+  /*
+   * Wait until the current entries in cache are indexed.
+   *
+   * Lucene indexes are maintained asynchronously. This means that updates to the region will not be
+   * immediately reflected in the Lucene index. This method will either timeout or wait until any
+   * data put into the region before this method call is flushed to the lucene index.
+   *
+   * This method is an expensive operation, so using it before every query is highly discouraged.
+   *
    * @param indexName index name
+   * 
    * @param regionPath region name
+   * 
    * @param timeout max wait time
-   * @param unit granularity of the timeout
-   * @return if entries are flushed within timeout
+   * 
+   * @param unit Time unit associated with the max wait time
+   * 
+   * @return true if entries are flushed within timeout, false if the timeout has elapsed
    */
   public boolean waitUntilFlushed(String indexName, String regionPath, long timeout, TimeUnit unit)
       throws InterruptedException;

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java
index a1f73da..798b5c3 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneServiceProvider.java
@@ -27,7 +27,7 @@ import org.apache.geode.internal.cache.InternalCache;
 @Experimental
 public class LuceneServiceProvider {
   /**
-   * Retrieve or create the lucene service for this cache
+   * Retrieve or create the Lucene service for this cache
    */
   public static LuceneService get(GemFireCache cache) {
     InternalCache internalCache = (InternalCache) cache;

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java
index da04d01..9c68ce4 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/PageableLuceneQueryResults.java
@@ -15,30 +15,34 @@
 
 package org.apache.geode.cache.lucene;
 
+import org.apache.geode.annotations.Experimental;
+
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.geode.annotations.Experimental;
-
 /**
  * <p>
- * Defines the interface for a container of lucene query result collected from function
- * execution.<br>
- * 
- * 
+ * This interface allows you to retrieve a page of query results at a time, using the
+ * {@link #hasNext()} and {@link #next()} methods.
+ * </p>
+ *
+ * Each page is fetched individually from the server, so {@link PageableLuceneQueryResults} cannot
+ * be serialized and sent to other members.
+ *
+ * @see LuceneQuery#findPages()
+ *
  * @param <K> The type of the key
  * @param <V> The type of the value
  */
 @Experimental
 public interface PageableLuceneQueryResults<K, V> extends Iterator<List<LuceneResultStruct<K, V>>> {
   /**
-   * @return total number of hits for this query
+   * @return total number of hits for this query across all pages.
    */
   public int size();
 
   /**
-   * Returns the maximum score value encountered. Note that in case scores are not tracked, this
-   * returns {@link Float#NaN}.
+   * Returns the maximum score value across all pages.
    */
   public float getMaxScore();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java
index b798e30..5c088dc 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryFactoryImpl.java
@@ -32,12 +32,20 @@ public class LuceneQueryFactoryImpl implements LuceneQueryFactory {
 
   @Override
   public LuceneQueryFactory setPageSize(int pageSize) {
+    if (pageSize < 0) {
+      throw new IllegalArgumentException("Page size is negative: " + pageSize);
+    }
+
     this.pageSize = pageSize;
     return this;
   }
 
   @Override
   public LuceneQueryFactory setResultLimit(int limit) {
+    if (limit <= 0) {
+      throw new IllegalArgumentException("Limit is <= 0: " + limit);
+    }
+
     this.limit = limit;
     return this;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/c0633c8d/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java
index 9541fee..3c2becb 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/package-info.java
@@ -18,14 +18,14 @@
  * <p>
  * All indexing and query operations are performed through the
  * {@link org.apache.geode.cache.lucene.LuceneService} class. See
- * {@link org.apache.geode.cache.lucene.LuceneService} for an example of how to add a lucene index
- * to a geode region.
+ * {@link org.apache.geode.cache.lucene.LuceneService} for an example of how to add a Lucene index
+ * to a Geode region.
  * <p>
  *
- * The Lucene indexes created using this API are stored in geode and colocated with the indexed
+ * The Lucene indexes created using this API are stored in Geode and colocated with the indexed
  * region, which means they have the same availability guarantees as the underlying region. The
  * indexes are maintained asynchronously, so changes to the region may not be immediately visible in
- * the lucene index.
+ * the Lucene index.
  */
 
 package org.apache.geode.cache.lucene;


[07/51] [abbrv] geode git commit: GEODE-2142: Removal of offending JSON.ORG code and license information

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/JSONObject.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONObject.java b/geode-json/src/main/java/org/json/JSONObject.java
deleted file mode 100755
index a2c6d8b..0000000
--- a/geode-json/src/main/java/org/json/JSONObject.java
+++ /dev/null
@@ -1,1525 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-/**
- * A JSONObject is an unordered collection of name/value pairs. Its external form is a string
- * wrapped in curly braces with colons between the names and values, and commas between the values
- * and names. The internal form is an object having <code>get</code> and <code>opt</code> methods
- * for accessing the values by name, and <code>put</code> methods for adding or replacing values by
- * name. The values can be any of these types: <code>Boolean</code>, <code>JSONArray</code>,
- * <code>JSONObject</code>, <code>Number</code>, <code>String</code>, or the
- * <code>JSONObject.NULL</code> object. A JSONObject constructor can be used to convert an external
- * form JSON text into an internal form whose values can be retrieved with the <code>get</code> and
- * <code>opt</code> methods, or to convert values into a JSON text using the <code>put</code> and
- * <code>toString</code> methods. A <code>get</code> method returns a value if one can be found, and
- * throws an exception if one cannot be found. An <code>opt</code> method returns a default value
- * instead of throwing an exception, and so is useful for obtaining optional values.
- * <p>
- * The generic <code>get()</code> and <code>opt()</code> methods return an object, which you can
- * cast or query for type. There are also typed <code>get</code> and <code>opt</code> methods that
- * do type checking and type coercion for you. The opt methods differ from the get methods in that
- * they do not throw. Instead, they return a specified value, such as null.
- * <p>
- * The <code>put</code> methods add or replace values in an object. For example,
- *
- * <pre>
- * myString = new JSONObject().put(&quot;JSON&quot;, &quot;Hello, World!&quot;).toString();
- * </pre>
- *
- * produces the string <code>{"JSON": "Hello, World"}</code>.
- * <p>
- * The texts produced by the <code>toString</code> methods strictly conform to the JSON syntax
- * rules. The constructors are more forgiving in the texts they will accept:
- * <ul>
- * <li>An extra <code>,</code>&nbsp;<small>(comma)</small> may appear just before the closing
- * brace.</li>
- * <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single quote)</small>.</li>
- * <li>Strings do not need to be quoted at all if they do not begin with a quote or single quote,
- * and if they do not contain leading or trailing spaces, and if they do not contain any of these
- * characters: <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and if they
- * are not the reserved words <code>true</code>, <code>false</code>, or <code>null</code>.</li>
- * <li>Keys can be followed by <code>=</code> or <code>=></code> as well as by <code>:</code>.</li>
- * <li>Values can be followed by <code>;</code> <small>(semicolon)</small> as well as by
- * <code>,</code> <small>(comma)</small>.</li>
- * </ul>
- *
- * @author JSON.org
- * @version 2012-05-29
- */
-public class JSONObject {
-  /**
-   * JSONObject.NULL is equivalent to the value that JavaScript calls null, whilst Java's null is
-   * equivalent to the value that JavaScript calls undefined.
-   */
-  private static final class Null {
-
-    /**
-     * There is only intended to be a single instance of the NULL object, so the clone method
-     * returns itself.
-     * 
-     * @return NULL.
-     */
-    protected final Object clone() {
-      return this;
-    }
-
-    /**
-     * A Null object is equal to the null value and to itself.
-     * 
-     * @param object An object to test for nullness.
-     * @return true if the object parameter is the JSONObject.NULL object or null.
-     */
-    public boolean equals(Object object) {
-      return object == null || object == this;
-    }
-
-    /**
-     * Get the "null" string value.
-     * 
-     * @return The string "null".
-     */
-    public String toString() {
-      return "null";
-    }
-  }
-
-
-  /**
-   * The map where the JSONObject's properties are kept.
-   */
-  private final Map map;
-
-
-  /**
-   * It is sometimes more convenient and less ambiguous to have a <code>NULL</code> object than to
-   * use Java's <code>null</code> value. <code>JSONObject.NULL.equals(null)</code> returns
-   * <code>true</code>. <code>JSONObject.NULL.toString()</code> returns <code>"null"</code>.
-   */
-  public static final Object NULL = new Null();
-
-
-  public static ThreadLocal<Set> cyclicDependencySet = new ThreadLocal();
-  public static ThreadLocal<Boolean> cyclicDepChkEnabled = new ThreadLocal();
-
-
-  /**
-   * Construct an empty JSONObject.
-   */
-  public JSONObject() {
-    this.map = new LinkedHashMap();
-  }
-
-
-  /**
-   * Construct a JSONObject from a subset of another JSONObject. An array of strings is used to
-   * identify the keys that should be copied. Missing keys are ignored.
-   * 
-   * @param jo A JSONObject.
-   * @param names An array of strings.
-   */
-  public JSONObject(JSONObject jo, String[] names) {
-    this();
-    for (int i = 0; i < names.length; i += 1) {
-      try {
-        this.putOnce(names[i], jo.opt(names[i]));
-      } catch (Exception ignore) {
-      }
-    }
-  }
-
-
-  /**
-   * Construct a JSONObject from a JSONTokener.
-   * 
-   * @param x A JSONTokener object containing the source string.
-   * @throws JSONException If there is a syntax error in the source string or a duplicated key.
-   */
-  public JSONObject(JSONTokener x) throws JSONException {
-    this();
-    char c;
-    String key;
-
-    if (x.nextClean() != '{') {
-      throw x.syntaxError("A JSONObject text must begin with '{'");
-    }
-    for (;;) {
-      c = x.nextClean();
-      switch (c) {
-        case 0:
-          throw x.syntaxError("A JSONObject text must end with '}'");
-        case '}':
-          return;
-        default:
-          x.back();
-          key = x.nextValue().toString();
-      }
-
-      // The key is followed by ':'. We will also tolerate '=' or '=>'.
-
-      c = x.nextClean();
-      if (c == '=') {
-        if (x.next() != '>') {
-          x.back();
-        }
-      } else if (c != ':') {
-        throw x.syntaxError("Expected a ':' after a key");
-      }
-      this.putOnce(key, x.nextValue());
-
-      // Pairs are separated by ','. We will also tolerate ';'.
-
-      switch (x.nextClean()) {
-        case ';':
-        case ',':
-          if (x.nextClean() == '}') {
-            return;
-          }
-          x.back();
-          break;
-        case '}':
-          return;
-        default:
-          throw x.syntaxError("Expected a ',' or '}'");
-      }
-    }
-  }
-
-
-  /**
-   * Construct a JSONObject from a Map.
-   *
-   * @param map A map object that can be used to initialize the contents of the JSONObject.
-   */
-  public JSONObject(Map map) {
-    this.map = new LinkedHashMap();
-    if (map != null) {
-      Iterator i = map.entrySet().iterator();
-      while (i.hasNext()) {
-        Map.Entry e = (Map.Entry) i.next();
-        Object value = e.getValue();
-        if (value != null) {
-          this.map.put(e.getKey(), wrap(value));
-        }
-      }
-    }
-  }
-
-
-  /**
-   * Construct a JSONObject from an Object using bean getters. It reflects on all of the public
-   * methods of the object. For each of the methods with no parameters and a name starting with
-   * <code>"get"</code> or <code>"is"</code> followed by an uppercase letter, the method is invoked,
-   * and a key and the value returned from the getter method are put into the new JSONObject.
-   *
-   * The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix. If the second
-   * remaining character is not upper case, then the first character is converted to lower case.
-   *
-   * For example, if an object has a method named <code>"getName"</code>, and if the result of
-   * calling <code>object.getName()</code> is <code>"Larry Fine"</code>, then the JSONObject will
-   * contain <code>"name": "Larry Fine"</code>.
-   *
-   * @param bean An object that has getter methods that should be used to make a JSONObject.
-   */
-  public JSONObject(Object bean) {
-    this();
-    this.populateMap(bean);
-  }
-
-
-  /**
-   * Construct a JSONObject from an Object, using reflection to find the public members. The
-   * resulting JSONObject's keys will be the strings from the names array, and the values will be
-   * the field values associated with those keys in the object. If a key is not found or not
-   * visible, then it will not be copied into the new JSONObject.
-   * 
-   * @param object An object that has fields that should be used to make a JSONObject.
-   * @param names An array of strings, the names of the fields to be obtained from the object.
-   */
-  public JSONObject(Object object, String names[]) {
-    this();
-    Class c = object.getClass();
-    for (int i = 0; i < names.length; i += 1) {
-      String name = names[i];
-      try {
-        this.putOpt(name, c.getField(name).get(object));
-      } catch (Exception ignore) {
-      }
-    }
-  }
-
-
-  /**
-   * Construct a JSONObject from a source JSON text string. This is the most commonly used
-   * JSONObject constructor.
-   * 
-   * @param source A string beginning with <code>{</code>&nbsp;<small>(left brace)</small> and
-   *        ending with <code>}</code>&nbsp;<small>(right brace)</small>.
-   * @exception JSONException If there is a syntax error in the source string or a duplicated key.
-   */
-  public JSONObject(String source) throws JSONException {
-    this(new JSONTokener(source));
-  }
-
-
-  /**
-   * Construct a JSONObject from a ResourceBundle.
-   * 
-   * @param baseName The ResourceBundle base name.
-   * @param locale The Locale to load the ResourceBundle for.
-   * @throws JSONException If any JSONExceptions are detected.
-   */
-  public JSONObject(String baseName, Locale locale) throws JSONException {
-    this();
-    ResourceBundle bundle =
-        ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader());
-
-    // Iterate through the keys in the bundle.
-
-    Enumeration keys = bundle.getKeys();
-    while (keys.hasMoreElements()) {
-      Object key = keys.nextElement();
-      if (key instanceof String) {
-
-        // Go through the path, ensuring that there is a nested JSONObject for each
-        // segment except the last. Add the value using the last segment's name into
-        // the deepest nested JSONObject.
-
-        String[] path = ((String) key).split("\\.");
-        int last = path.length - 1;
-        JSONObject target = this;
-        for (int i = 0; i < last; i += 1) {
-          String segment = path[i];
-          JSONObject nextTarget = target.optJSONObject(segment);
-          if (nextTarget == null) {
-            nextTarget = new JSONObject();
-            target.put(segment, nextTarget);
-          }
-          target = nextTarget;
-        }
-        target.put(path[last], bundle.getString((String) key));
-      }
-    }
-  }
-
-
-  /**
-   * Accumulate values under a key. It is similar to the put method except that if there is already
-   * an object stored under the key then a JSONArray is stored under the key to hold all of the
-   * accumulated values. If there is already a JSONArray, then the new value is appended to it. In
-   * contrast, the put method replaces the previous value.
-   *
-   * If only one value is accumulated that is not a JSONArray, then the result will be the same as
-   * using put. But if multiple values are accumulated, then the result will be like append.
-   * 
-   * @param key A key string.
-   * @param value An object to be accumulated under the key.
-   * @return this.
-   * @throws JSONException If the value is an invalid number or if the key is null.
-   */
-  public JSONObject accumulate(String key, Object value) throws JSONException {
-    testValidity(value);
-    Object object = this.opt(key);
-    if (object == null) {
-      this.put(key, value instanceof JSONArray ? new JSONArray().put(value) : value);
-    } else if (object instanceof JSONArray) {
-      ((JSONArray) object).put(value);
-    } else {
-      this.put(key, new JSONArray().put(object).put(value));
-    }
-    return this;
-  }
-
-
-  /**
-   * Append values to the array under a key. If the key does not exist in the JSONObject, then the
-   * key is put in the JSONObject with its value being a JSONArray containing the value parameter.
-   * If the key was already associated with a JSONArray, then the value parameter is appended to it.
-   * 
-   * @param key A key string.
-   * @param value An object to be accumulated under the key.
-   * @return this.
-   * @throws JSONException If the key is null or if the current value associated with the key is not
-   *         a JSONArray.
-   */
-  public JSONObject append(String key, Object value) throws JSONException {
-    testValidity(value);
-    Object object = this.opt(key);
-    if (object == null) {
-      this.put(key, new JSONArray().put(value));
-    } else if (object instanceof JSONArray) {
-      this.put(key, ((JSONArray) object).put(value));
-    } else {
-      throw new JSONException("JSONObject[" + key + "] is not a JSONArray.");
-    }
-    return this;
-  }
-
-
-  /**
-   * Produce a string from a double. The string "null" will be returned if the number is not finite.
-   * 
-   * @param d A double.
-   * @return A String.
-   */
-  public static String doubleToString(double d) {
-    if (Double.isInfinite(d) || Double.isNaN(d)) {
-      return "null";
-    }
-
-    // Shave off trailing zeros and decimal point, if possible.
-
-    String string = Double.toString(d);
-    if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) {
-      while (string.endsWith("0")) {
-        string = string.substring(0, string.length() - 1);
-      }
-      if (string.endsWith(".")) {
-        string = string.substring(0, string.length() - 1);
-      }
-    }
-    return string;
-  }
-
-
-  /**
-   * Get the value object associated with a key.
-   *
-   * @param key A key string.
-   * @return The object associated with the key.
-   * @throws JSONException if the key is not found.
-   */
-  public Object get(String key) throws JSONException {
-    if (key == null) {
-      throw new JSONException("Null key.");
-    }
-    Object object = this.opt(key);
-    if (object == null) {
-      throw new JSONException("JSONObject[" + quote(key) + "] not found.");
-    }
-    return object;
-  }
-
-
-  /**
-   * Get the boolean value associated with a key.
-   *
-   * @param key A key string.
-   * @return The truth.
-   * @throws JSONException if the value is not a Boolean or the String "true" or "false".
-   */
-  public boolean getBoolean(String key) throws JSONException {
-    Object object = this.get(key);
-    if (object.equals(Boolean.FALSE)
-        || (object instanceof String && ((String) object).equalsIgnoreCase("false"))) {
-      return false;
-    } else if (object.equals(Boolean.TRUE)
-        || (object instanceof String && ((String) object).equalsIgnoreCase("true"))) {
-      return true;
-    }
-    throw new JSONException("JSONObject[" + quote(key) + "] is not a Boolean.");
-  }
-
-
-  /**
-   * Get the double value associated with a key.
-   * 
-   * @param key A key string.
-   * @return The numeric value.
-   * @throws JSONException if the key is not found or if the value is not a Number object and cannot
-   *         be converted to a number.
-   */
-  public double getDouble(String key) throws JSONException {
-    Object object = this.get(key);
-    try {
-      return object instanceof Number ? ((Number) object).doubleValue()
-          : Double.parseDouble((String) object);
-    } catch (Exception e) {
-      throw new JSONException("JSONObject[" + quote(key) + "] is not a number.");
-    }
-  }
-
-
-  /**
-   * Get the int value associated with a key.
-   *
-   * @param key A key string.
-   * @return The integer value.
-   * @throws JSONException if the key is not found or if the value cannot be converted to an
-   *         integer.
-   */
-  public int getInt(String key) throws JSONException {
-    Object object = this.get(key);
-    try {
-      return object instanceof Number ? ((Number) object).intValue()
-          : Integer.parseInt((String) object);
-    } catch (Exception e) {
-      throw new JSONException("JSONObject[" + quote(key) + "] is not an int.");
-    }
-  }
-
-
-  /**
-   * Get the JSONArray value associated with a key.
-   *
-   * @param key A key string.
-   * @return A JSONArray which is the value.
-   * @throws JSONException if the key is not found or if the value is not a JSONArray.
-   */
-  public JSONArray getJSONArray(String key) throws JSONException {
-    Object object = this.get(key);
-    if (object instanceof JSONArray) {
-      return (JSONArray) object;
-    }
-    throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONArray.");
-  }
-
-
-  /**
-   * Get the JSONObject value associated with a key.
-   *
-   * @param key A key string.
-   * @return A JSONObject which is the value.
-   * @throws JSONException if the key is not found or if the value is not a JSONObject.
-   */
-  public JSONObject getJSONObject(String key) throws JSONException {
-    Object object = this.get(key);
-    if (object instanceof JSONObject) {
-      return (JSONObject) object;
-    }
-    throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONObject.");
-  }
-
-
-  /**
-   * Get the long value associated with a key.
-   *
-   * @param key A key string.
-   * @return The long value.
-   * @throws JSONException if the key is not found or if the value cannot be converted to a long.
-   */
-  public long getLong(String key) throws JSONException {
-    Object object = this.get(key);
-    try {
-      return object instanceof Number ? ((Number) object).longValue()
-          : Long.parseLong((String) object);
-    } catch (Exception e) {
-      throw new JSONException("JSONObject[" + quote(key) + "] is not a long.");
-    }
-  }
-
-
-  /**
-   * Get an array of field names from a JSONObject.
-   *
-   * @return An array of field names, or null if there are no names.
-   */
-  public static String[] getNames(JSONObject jo) {
-    int length = jo.length();
-    if (length == 0) {
-      return null;
-    }
-    Iterator iterator = jo.keys();
-    String[] names = new String[length];
-    int i = 0;
-    while (iterator.hasNext()) {
-      names[i] = (String) iterator.next();
-      i += 1;
-    }
-    return names;
-  }
-
-
-  /**
-   * Get an array of field names from an Object.
-   *
-   * @return An array of field names, or null if there are no names.
-   */
-  public static String[] getNames(Object object) {
-    if (object == null) {
-      return null;
-    }
-    Class klass = object.getClass();
-    Field[] fields = klass.getFields();
-    int length = fields.length;
-    if (length == 0) {
-      return null;
-    }
-    String[] names = new String[length];
-    for (int i = 0; i < length; i += 1) {
-      names[i] = fields[i].getName();
-    }
-    return names;
-  }
-
-
-  /**
-   * Get the string associated with a key.
-   *
-   * @param key A key string.
-   * @return A string which is the value.
-   * @throws JSONException if there is no string value for the key.
-   */
-  public String getString(String key) throws JSONException {
-    Object object = this.get(key);
-    if (object instanceof String) {
-      return (String) object;
-    }
-    throw new JSONException("JSONObject[" + quote(key) + "] not a string.");
-  }
-
-
-  /**
-   * Determine if the JSONObject contains a specific key.
-   * 
-   * @param key A key string.
-   * @return true if the key exists in the JSONObject.
-   */
-  public boolean has(String key) {
-    return this.map.containsKey(key);
-  }
-
-
-  /**
-   * Increment a property of a JSONObject. If there is no such property, create one with a value of
-   * 1. If there is such a property, and if it is an Integer, Long, Double, or Float, then add one
-   * to it.
-   * 
-   * @param key A key string.
-   * @return this.
-   * @throws JSONException If there is already a property with this name that is not an Integer,
-   *         Long, Double, or Float.
-   */
-  public JSONObject increment(String key) throws JSONException {
-    Object value = this.opt(key);
-    if (value == null) {
-      this.put(key, 1);
-    } else if (value instanceof Integer) {
-      this.put(key, ((Integer) value).intValue() + 1);
-    } else if (value instanceof Long) {
-      this.put(key, ((Long) value).longValue() + 1);
-    } else if (value instanceof Double) {
-      this.put(key, ((Double) value).doubleValue() + 1);
-    } else if (value instanceof Float) {
-      this.put(key, ((Float) value).floatValue() + 1);
-    } else {
-      throw new JSONException("Unable to increment [" + quote(key) + "].");
-    }
-    return this;
-  }
-
-
-  /**
-   * Determine if the value associated with the key is null or if there is no value.
-   * 
-   * @param key A key string.
-   * @return true if there is no value associated with the key or if the value is the
-   *         JSONObject.NULL object.
-   */
-  public boolean isNull(String key) {
-    return JSONObject.NULL.equals(this.opt(key));
-  }
-
-
-  /**
-   * Get an enumeration of the keys of the JSONObject.
-   *
-   * @return An iterator of the keys.
-   */
-  public Iterator keys() {
-    return this.map.keySet().iterator();
-  }
-
-
-  /**
-   * Get the number of keys stored in the JSONObject.
-   *
-   * @return The number of keys in the JSONObject.
-   */
-  public int length() {
-    return this.map.size();
-  }
-
-
-  /**
-   * Produce a JSONArray containing the names of the elements of this JSONObject.
-   * 
-   * @return A JSONArray containing the key strings, or null if the JSONObject is empty.
-   */
-  public JSONArray names() {
-    JSONArray ja = new JSONArray();
-    Iterator keys = this.keys();
-    while (keys.hasNext()) {
-      ja.put(keys.next());
-    }
-    return ja.length() == 0 ? null : ja;
-  }
-
-  /**
-   * Produce a string from a Number.
-   * 
-   * @param number A Number
-   * @return A String.
-   * @throws JSONException If n is a non-finite number.
-   */
-  public static String numberToString(Number number) throws JSONException {
-    if (number == null) {
-      throw new JSONException("Null pointer");
-    }
-    testValidity(number);
-
-    // Shave off trailing zeros and decimal point, if possible.
-
-    String string = number.toString();
-    if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) {
-      while (string.endsWith("0")) {
-        string = string.substring(0, string.length() - 1);
-      }
-      if (string.endsWith(".")) {
-        string = string.substring(0, string.length() - 1);
-      }
-    }
-    return string;
-  }
-
-
-  /**
-   * Get an optional value associated with a key.
-   * 
-   * @param key A key string.
-   * @return An object which is the value, or null if there is no value.
-   */
-  public Object opt(String key) {
-    return key == null ? null : this.map.get(key);
-  }
-
-
-  /**
-   * Get an optional boolean associated with a key. It returns false if there is no such key, or if
-   * the value is not Boolean.TRUE or the String "true".
-   *
-   * @param key A key string.
-   * @return The truth.
-   */
-  public boolean optBoolean(String key) {
-    return this.optBoolean(key, false);
-  }
-
-
-  /**
-   * Get an optional boolean associated with a key. It returns the defaultValue if there is no such
-   * key, or if it is not a Boolean or the String "true" or "false" (case insensitive).
-   *
-   * @param key A key string.
-   * @param defaultValue The default.
-   * @return The truth.
-   */
-  public boolean optBoolean(String key, boolean defaultValue) {
-    try {
-      return this.getBoolean(key);
-    } catch (Exception e) {
-      return defaultValue;
-    }
-  }
-
-
-  /**
-   * Get an optional double associated with a key, or NaN if there is no such key or if its value is
-   * not a number. If the value is a string, an attempt will be made to evaluate it as a number.
-   *
-   * @param key A string which is the key.
-   * @return An object which is the value.
-   */
-  public double optDouble(String key) {
-    return this.optDouble(key, Double.NaN);
-  }
-
-
-  /**
-   * Get an optional double associated with a key, or the defaultValue if there is no such key or if
-   * its value is not a number. If the value is a string, an attempt will be made to evaluate it as
-   * a number.
-   *
-   * @param key A key string.
-   * @param defaultValue The default.
-   * @return An object which is the value.
-   */
-  public double optDouble(String key, double defaultValue) {
-    try {
-      return this.getDouble(key);
-    } catch (Exception e) {
-      return defaultValue;
-    }
-  }
-
-
-  /**
-   * Get an optional int value associated with a key, or zero if there is no such key or if the
-   * value is not a number. If the value is a string, an attempt will be made to evaluate it as a
-   * number.
-   *
-   * @param key A key string.
-   * @return An object which is the value.
-   */
-  public int optInt(String key) {
-    return this.optInt(key, 0);
-  }
-
-
-  /**
-   * Get an optional int value associated with a key, or the default if there is no such key or if
-   * the value is not a number. If the value is a string, an attempt will be made to evaluate it as
-   * a number.
-   *
-   * @param key A key string.
-   * @param defaultValue The default.
-   * @return An object which is the value.
-   */
-  public int optInt(String key, int defaultValue) {
-    try {
-      return this.getInt(key);
-    } catch (Exception e) {
-      return defaultValue;
-    }
-  }
-
-
-  /**
-   * Get an optional JSONArray associated with a key. It returns null if there is no such key, or if
-   * its value is not a JSONArray.
-   *
-   * @param key A key string.
-   * @return A JSONArray which is the value.
-   */
-  public JSONArray optJSONArray(String key) {
-    Object o = this.opt(key);
-    return o instanceof JSONArray ? (JSONArray) o : null;
-  }
-
-
-  /**
-   * Get an optional JSONObject associated with a key. It returns null if there is no such key, or
-   * if its value is not a JSONObject.
-   *
-   * @param key A key string.
-   * @return A JSONObject which is the value.
-   */
-  public JSONObject optJSONObject(String key) {
-    Object object = this.opt(key);
-    return object instanceof JSONObject ? (JSONObject) object : null;
-  }
-
-
-  /**
-   * Get an optional long value associated with a key, or zero if there is no such key or if the
-   * value is not a number. If the value is a string, an attempt will be made to evaluate it as a
-   * number.
-   *
-   * @param key A key string.
-   * @return An object which is the value.
-   */
-  public long optLong(String key) {
-    return this.optLong(key, 0);
-  }
-
-
-  /**
-   * Get an optional long value associated with a key, or the default if there is no such key or if
-   * the value is not a number. If the value is a string, an attempt will be made to evaluate it as
-   * a number.
-   *
-   * @param key A key string.
-   * @param defaultValue The default.
-   * @return An object which is the value.
-   */
-  public long optLong(String key, long defaultValue) {
-    try {
-      return this.getLong(key);
-    } catch (Exception e) {
-      return defaultValue;
-    }
-  }
-
-
-  /**
-   * Get an optional string associated with a key. It returns an empty string if there is no such
-   * key. If the value is not a string and is not null, then it is converted to a string.
-   *
-   * @param key A key string.
-   * @return A string which is the value.
-   */
-  public String optString(String key) {
-    return this.optString(key, "");
-  }
-
-
-  /**
-   * Get an optional string associated with a key. It returns the defaultValue if there is no such
-   * key.
-   *
-   * @param key A key string.
-   * @param defaultValue The default.
-   * @return A string which is the value.
-   */
-  public String optString(String key, String defaultValue) {
-    Object object = this.opt(key);
-    return NULL.equals(object) ? defaultValue : object.toString();
-  }
-
-
-  private void populateMap(Object bean) {
-    Class klass = bean.getClass();
-
-    // If klass is a System class then set includeSuperClass to false.
-
-    boolean includeSuperClass = klass.getClassLoader() != null;
-
-    Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods();
-    for (int i = 0; i < methods.length; i += 1) {
-      try {
-        Method method = methods[i];
-        if (Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers())) {
-          String name = method.getName();
-          String key = "";
-          if (name.startsWith("get")) {
-            if ("getClass".equals(name) || "getDeclaringClass".equals(name)) {
-              key = "";
-            } else {
-              key = name.substring(3);
-            }
-          } else if (name.startsWith("is")) {
-            key = name.substring(2);
-          }
-          if (key.length() > 0 && Character.isUpperCase(key.charAt(0))
-              && method.getParameterTypes().length == 0) {
-            if (key.length() == 1) {
-              key = key.toLowerCase();
-            } else if (!Character.isUpperCase(key.charAt(1))) {
-              key = key.substring(0, 1).toLowerCase() + key.substring(1);
-            }
-            Object result = method.invoke(bean, (Object[]) null);
-            if (result != null) {
-              this.map.put(key, wrap(result));
-            } else if (!method.getReturnType().isArray()) {
-              this.map.put(key, JSONObject.NULL);
-            }
-          }
-        }
-      } catch (Exception ignore) {
-      }
-    }
-    this.map.put("type-class", klass.getCanonicalName());
-  }
-
-
-  /**
-   * Put a key/boolean pair in the JSONObject.
-   *
-   * @param key A key string.
-   * @param value A boolean which is the value.
-   * @return this.
-   * @throws JSONException If the key is null.
-   */
-  public JSONObject put(String key, boolean value) throws JSONException {
-    this.put(key, value ? Boolean.TRUE : Boolean.FALSE);
-    return this;
-  }
-
-
-  /**
-   * Put a key/value pair in the JSONObject, where the value will be a JSONArray which is produced
-   * from a Collection.
-   * 
-   * @param key A key string.
-   * @param value A Collection value.
-   * @return this.
-   * @throws JSONException
-   */
-  public JSONObject put(String key, Collection value) throws JSONException {
-    this.put(key, new JSONArray(value));
-    return this;
-  }
-
-
-  /**
-   * Put a key/double pair in the JSONObject.
-   *
-   * @param key A key string.
-   * @param value A double which is the value.
-   * @return this.
-   * @throws JSONException If the key is null or if the number is invalid.
-   */
-  public JSONObject put(String key, double value) throws JSONException {
-    this.put(key, new Double(value));
-    return this;
-  }
-
-
-  /**
-   * Put a key/int pair in the JSONObject.
-   *
-   * @param key A key string.
-   * @param value An int which is the value.
-   * @return this.
-   * @throws JSONException If the key is null.
-   */
-  public JSONObject put(String key, int value) throws JSONException {
-    this.put(key, new Integer(value));
-    return this;
-  }
-
-
-  /**
-   * Put a key/long pair in the JSONObject.
-   *
-   * @param key A key string.
-   * @param value A long which is the value.
-   * @return this.
-   * @throws JSONException If the key is null.
-   */
-  public JSONObject put(String key, long value) throws JSONException {
-    this.put(key, new Long(value));
-    return this;
-  }
-
-
-  /**
-   * Put a key/value pair in the JSONObject, where the value will be a JSONObject which is produced
-   * from a Map.
-   * 
-   * @param key A key string.
-   * @param value A Map value.
-   * @return this.
-   * @throws JSONException
-   */
-  public JSONObject put(String key, Map value) throws JSONException {
-    this.put(key, new JSONObject(value));
-    return this;
-  }
-
-
-  /**
-   * Put a key/value pair in the JSONObject. If the value is null, then the key will be removed from
-   * the JSONObject if it is present.
-   * 
-   * @param key A key string.
-   * @param value An object which is the value. It should be of one of these types: Boolean, Double,
-   *        Integer, JSONArray, JSONObject, Long, String, or the JSONObject.NULL object.
-   * @return this.
-   * @throws JSONException If the value is non-finite number or if the key is null.
-   */
-  public JSONObject put(String key, Object value) throws JSONException {
-    if (key == null) {
-      throw new JSONException("Null key.");
-    }
-    if (value != null) {
-      testValidity(value);
-      this.map.put(key, value);
-    } else {
-      this.remove(key);
-    }
-    return this;
-  }
-
-
-  /**
-   * Put a key/value pair in the JSONObject, but only if the key and the value are both non-null,
-   * and only if there is not already a member with that name.
-   * 
-   * @param key
-   * @param value
-   * @return his.
-   * @throws JSONException if the key is a duplicate
-   */
-  public JSONObject putOnce(String key, Object value) throws JSONException {
-    if (key != null && value != null) {
-      if (this.opt(key) != null) {
-        throw new JSONException("Duplicate key \"" + key + "\"");
-      }
-      this.put(key, value);
-    }
-    return this;
-  }
-
-
-  /**
-   * Put a key/value pair in the JSONObject, but only if the key and the value are both non-null.
-   * 
-   * @param key A key string.
-   * @param value An object which is the value. It should be of one of these types: Boolean, Double,
-   *        Integer, JSONArray, JSONObject, Long, String, or the JSONObject.NULL object.
-   * @return this.
-   * @throws JSONException If the value is a non-finite number.
-   */
-  public JSONObject putOpt(String key, Object value) throws JSONException {
-    if (key != null && value != null) {
-      this.put(key, value);
-    }
-    return this;
-  }
-
-
-  /**
-   * Produce a string in double quotes with backslash sequences in all the right places. A backslash
-   * will be inserted within </, producing <\/, allowing JSON text to be delivered in HTML. In JSON
-   * text, a string cannot contain a control character or an unescaped quote or backslash.
-   * 
-   * @param string A String
-   * @return A String correctly formatted for insertion in a JSON text.
-   */
-  public static String quote(String string) {
-    StringWriter sw = new StringWriter();
-    synchronized (sw.getBuffer()) {
-      try {
-        return quote(string, sw).toString();
-      } catch (IOException ignored) {
-        // will never happen - we are writing to a string writer
-        return "";
-      }
-    }
-  }
-
-  public static Writer quote(String string, Writer w) throws IOException {
-    if (string == null || string.length() == 0) {
-      w.write("\"\"");
-      return w;
-    }
-
-    char b;
-    char c = 0;
-    String hhhh;
-    int i;
-    int len = string.length();
-
-    w.write('"');
-    for (i = 0; i < len; i += 1) {
-      b = c;
-      c = string.charAt(i);
-      switch (c) {
-        case '\\':
-        case '"':
-          w.write('\\');
-          w.write(c);
-          break;
-        case '/':
-          if (b == '<') {
-            w.write('\\');
-          }
-          w.write(c);
-          break;
-        case '\b':
-          w.write("\\b");
-          break;
-        case '\t':
-          w.write("\\t");
-          break;
-        case '\n':
-          w.write("\\n");
-          break;
-        case '\f':
-          w.write("\\f");
-          break;
-        case '\r':
-          w.write("\\r");
-          break;
-        default:
-          if (c < ' ' || (c >= '\u0080' && c < '\u00a0') || (c >= '\u2000' && c < '\u2100')) {
-            hhhh = "000" + Integer.toHexString(c);
-            w.write("\\u" + hhhh.substring(hhhh.length() - 4));
-          } else {
-            w.write(c);
-          }
-      }
-    }
-    w.write('"');
-    return w;
-  }
-
-  /**
-   * Remove a name and its value, if present.
-   * 
-   * @param key The name to be removed.
-   * @return The value that was associated with the name, or null if there was no value.
-   */
-  public Object remove(String key) {
-    return this.map.remove(key);
-  }
-
-  /**
-   * Try to convert a string into a number, boolean, or null. If the string can't be converted,
-   * return the string.
-   * 
-   * @param string A String.
-   * @return A simple JSON value.
-   */
-  public static Object stringToValue(String string) {
-    Double d;
-    if (string.equals("")) {
-      return string;
-    }
-    if (string.equalsIgnoreCase("true")) {
-      return Boolean.TRUE;
-    }
-    if (string.equalsIgnoreCase("false")) {
-      return Boolean.FALSE;
-    }
-    if (string.equalsIgnoreCase("null")) {
-      return JSONObject.NULL;
-    }
-
-    /*
-     * If it might be a number, try converting it. If a number cannot be produced, then the value
-     * will just be a string. Note that the plus and implied string conventions are non-standard. A
-     * JSON parser may accept non-JSON forms as long as it accepts all correct JSON forms.
-     */
-
-    char b = string.charAt(0);
-    if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
-      try {
-        if (string.indexOf('.') > -1 || string.indexOf('e') > -1 || string.indexOf('E') > -1) {
-          d = Double.valueOf(string);
-          if (!d.isInfinite() && !d.isNaN()) {
-            return d;
-          }
-        } else {
-          Long myLong = new Long(string);
-          if (myLong.longValue() == myLong.intValue()) {
-            return new Integer(myLong.intValue());
-          } else {
-            return myLong;
-          }
-        }
-      } catch (Exception ignore) {
-      }
-    }
-    return string;
-  }
-
-
-  /**
-   * Throw an exception if the object is a NaN or infinite number.
-   * 
-   * @param o The object to test.
-   * @throws JSONException If o is a non-finite number.
-   */
-  public static void testValidity(Object o) throws JSONException {
-    if (o != null) {
-      if (o instanceof Double) {
-        if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
-          throw new JSONException("JSON does not allow non-finite numbers.");
-        }
-      } else if (o instanceof Float) {
-        if (((Float) o).isInfinite() || ((Float) o).isNaN()) {
-          throw new JSONException("JSON does not allow non-finite numbers.");
-        }
-      }
-    }
-  }
-
-
-  /**
-   * Produce a JSONArray containing the values of the members of this JSONObject.
-   * 
-   * @param names A JSONArray containing a list of key strings. This determines the sequence of the
-   *        values in the result.
-   * @return A JSONArray of values.
-   * @throws JSONException If any of the values are non-finite numbers.
-   */
-  public JSONArray toJSONArray(JSONArray names) throws JSONException {
-    if (names == null || names.length() == 0) {
-      return null;
-    }
-    JSONArray ja = new JSONArray();
-    for (int i = 0; i < names.length(); i += 1) {
-      ja.put(this.opt(names.getString(i)));
-    }
-    return ja;
-  }
-
-  /**
-   * Make a JSON text of this JSONObject. For compactness, no whitespace is added. If this would not
-   * result in a syntactically correct JSON text, then null will be returned instead.
-   * <p>
-   * Warning: This method assumes that the data structure is acyclical.
-   *
-   * @return a printable, displayable, portable, transmittable representation of the object,
-   *         beginning with <code>{</code>&nbsp;<small>(left brace)</small> and ending with
-   *         <code>}</code>&nbsp;<small>(right brace)</small>.
-   */
-  public String toString() {
-    try {
-      return this.toString(0);
-    } catch (Exception e) {
-      return null;
-    }
-  }
-
-
-  /**
-   * Make a prettyprinted JSON text of this JSONObject.
-   * <p>
-   * Warning: This method assumes that the data structure is acyclical.
-   * 
-   * @param indentFactor The number of spaces to add to each level of indentation.
-   * @return a printable, displayable, portable, transmittable representation of the object,
-   *         beginning with <code>{</code>&nbsp;<small>(left brace)</small> and ending with
-   *         <code>}</code>&nbsp;<small>(right brace)</small>.
-   * @throws JSONException If the object contains an invalid number.
-   */
-  public String toString(int indentFactor) throws JSONException {
-    StringWriter w = new StringWriter();
-    synchronized (w.getBuffer()) {
-      return this.write(w, indentFactor, 0).toString();
-    }
-  }
-
-  /**
-   * Make a JSON text of an Object value. If the object has an value.toJSONString() method, then
-   * that method will be used to produce the JSON text. The method is required to produce a strictly
-   * conforming text. If the object does not contain a toJSONString method (which is the most common
-   * case), then a text will be produced by other means. If the value is an array or Collection,
-   * then a JSONArray will be made from it and its toJSONString method will be called. If the value
-   * is a MAP, then a JSONObject will be made from it and its toJSONString method will be called.
-   * Otherwise, the value's toString method will be called, and the result will be quoted.
-   *
-   * <p>
-   * Warning: This method assumes that the data structure is acyclical.
-   * 
-   * @param value The value to be serialized.
-   * @return a printable, displayable, transmittable representation of the object, beginning with
-   *         <code>{</code>&nbsp;<small>(left brace)</small> and ending with
-   *         <code>}</code>&nbsp;<small>(right brace)</small>.
-   * @throws JSONException If the value is or contains an invalid number.
-   */
-  public static String valueToString(Object value) throws JSONException {
-    if (value == null || value.equals(null)) {
-      return "null";
-    }
-    if (value instanceof JSONString) {
-      Object object;
-      try {
-        object = ((JSONString) value).toJSONString();
-      } catch (Exception e) {
-        throw new JSONException(e);
-      }
-      if (object instanceof String) {
-        return (String) object;
-      }
-      throw new JSONException("Bad value from toJSONString: " + object);
-    }
-    if (value instanceof Number) {
-      return numberToString((Number) value);
-    }
-    if (value instanceof Boolean || value instanceof JSONObject || value instanceof JSONArray) {
-      return value.toString();
-    }
-    if (value instanceof Map) {
-      return new JSONObject((Map) value).toString();
-    }
-    if (value instanceof Collection) {
-      return new JSONArray((Collection) value).toString();
-    }
-    if (value.getClass().isArray()) {
-      return new JSONArray(value).toString();
-    }
-    return quote(value.toString());
-  }
-
-  /**
-   * Wrap an object, if necessary. If the object is null, return the NULL object. If it is an array
-   * or collection, wrap it in a JSONArray. If it is a map, wrap it in a JSONObject. If it is a
-   * standard property (Double, String, et al) then it is already wrapped. Otherwise, if it comes
-   * from one of the java packages, turn it into a string. And if it doesn't, try to wrap it in a
-   * JSONObject. If the wrapping fails, then null is returned.
-   *
-   * @param object The object to wrap
-   * @return The wrapped value
-   */
-  public static Object wrap(Object object) {
-    try {
-      if (object == null) {
-        return NULL;
-      }
-      if (object instanceof JSONObject || object instanceof JSONArray || NULL.equals(object)
-          || object instanceof JSONString || object instanceof Byte || object instanceof Character
-          || object instanceof Short || object instanceof Integer || object instanceof Long
-          || object instanceof Boolean || object instanceof Float || object instanceof Double
-          || object instanceof String) {
-        return object;
-      }
-
-      if (object instanceof Collection) {
-        return new JSONArray((Collection) object);
-      }
-      if (object.getClass().isArray()) {
-        return new JSONArray(object);
-      }
-      if (object instanceof Map) {
-        return new JSONObject((Map) object);
-      }
-      Package objectPackage = object.getClass().getPackage();
-      String objectPackageName = objectPackage != null ? objectPackage.getName() : "";
-      if (objectPackageName.startsWith("java.") || objectPackageName.startsWith("javax.")
-          || object.getClass().getClassLoader() == null
-          || object.getClass().getName().contains("GemFireCacheImpl")) {
-        return object.toString();
-      }
-
-      if (cyclicDepChkEnabled.get() != null && cyclicDependencySet.get() != null) {
-        if (cyclicDepChkEnabled.get() && cyclicDependencySet.get().contains(object)) {
-          // break cyclic reference
-          return object.getClass().getCanonicalName();
-        } else {
-          cyclicDependencySet.get().add(object);
-          return new JSONObject(object);
-        }
-      } else
-        return new JSONObject(object);
-
-    } catch (Exception exception) {
-      return null;
-    }
-  }
-
-
-  /**
-   * Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace
-   * is added.
-   * <p>
-   * Warning: This method assumes that the data structure is acyclical.
-   *
-   * @return The writer.
-   * @throws JSONException
-   */
-  public Writer write(Writer writer) throws JSONException {
-    return this.write(writer, 0, 0);
-  }
-
-
-  static final Writer writeValue(Writer writer, Object value, int indentFactor, int indent)
-      throws JSONException, IOException {
-    if (value == null || value.equals(null)) {
-      writer.write("null");
-    } else if (value instanceof JSONObject) {
-      ((JSONObject) value).write(writer, indentFactor, indent);
-    } else if (value instanceof JSONArray) {
-      ((JSONArray) value).write(writer, indentFactor, indent);
-    } else if (value instanceof Map) {
-      new JSONObject((Map) value).write(writer, indentFactor, indent);
-    } else if (value instanceof Collection) {
-      new JSONArray((Collection) value).write(writer, indentFactor, indent);
-    } else if (value.getClass().isArray()) {
-      new JSONArray(value).write(writer, indentFactor, indent);
-    } else if (value instanceof Number) {
-      writer.write(numberToString((Number) value));
-    } else if (value instanceof Boolean) {
-      writer.write(value.toString());
-    } else if (value instanceof JSONString) {
-      Object o;
-      try {
-        o = ((JSONString) value).toJSONString();
-      } catch (Exception e) {
-        throw new JSONException(e);
-      }
-      writer.write(o != null ? o.toString() : quote(value.toString()));
-    } else {
-      quote(value.toString(), writer);
-    }
-    return writer;
-  }
-
-  static final void indent(Writer writer, int indent) throws IOException {
-    for (int i = 0; i < indent; i += 1) {
-      writer.write(' ');
-    }
-  }
-
-  /**
-   * Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace
-   * is added.
-   * <p>
-   * Warning: This method assumes that the data structure is acyclical.
-   *
-   * @return The writer.
-   * @throws JSONException
-   */
-  Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
-    try {
-      boolean commanate = false;
-      final int length = this.length();
-      Iterator keys = this.keys();
-      writer.write('{');
-
-      if (length == 1) {
-        Object key = keys.next();
-        writer.write(quote(key.toString()));
-        writer.write(':');
-        if (indentFactor > 0) {
-          writer.write(' ');
-        }
-        writeValue(writer, this.map.get(key), indentFactor, indent);
-      } else if (length != 0) {
-        final int newindent = indent + indentFactor;
-        while (keys.hasNext()) {
-          Object key = keys.next();
-          if (commanate) {
-            writer.write(',');
-          }
-          if (indentFactor > 0) {
-            writer.write('\n');
-          }
-          indent(writer, newindent);
-          writer.write(quote(key.toString()));
-          writer.write(':');
-          if (indentFactor > 0) {
-            writer.write(' ');
-          }
-          writeValue(writer, this.map.get(key), indentFactor, newindent);
-          commanate = true;
-        }
-        if (indentFactor > 0) {
-          writer.write('\n');
-        }
-        indent(writer, indent);
-      }
-      writer.write('}');
-      return writer;
-    } catch (IOException exception) {
-      throw new JSONException(exception);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/JSONString.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONString.java b/geode-json/src/main/java/org/json/JSONString.java
deleted file mode 100755
index 4a09d89..0000000
--- a/geode-json/src/main/java/org/json/JSONString.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.json;
-
-/**
- * The <code>JSONString</code> interface allows a <code>toJSONString()</code> method so that a class
- * can change the behavior of <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
- * and <code>JSONWriter.value(</code>Object<code>)</code>. The <code>toJSONString</code> method will
- * be used instead of the default behavior of using the Object's <code>toString()</code> method and
- * quoting the result.
- */
-public interface JSONString {
-  /**
-   * The <code>toJSONString</code> method allows a class to produce its own JSON serialization.
-   * 
-   * @return A strictly syntactically correct JSON text.
-   */
-  public String toJSONString();
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/JSONStringer.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONStringer.java b/geode-json/src/main/java/org/json/JSONStringer.java
deleted file mode 100755
index 234e174..0000000
--- a/geode-json/src/main/java/org/json/JSONStringer.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.json;
-
-/*
- * Copyright (c) 2006 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-import java.io.StringWriter;
-
-/**
- * JSONStringer provides a quick and convenient way of producing JSON text. The texts produced
- * strictly conform to JSON syntax rules. No whitespace is added, so the results are ready for
- * transmission or storage. Each instance of JSONStringer can produce one JSON text.
- * <p>
- * A JSONStringer instance provides a <code>value</code> method for appending values to the text,
- * and a <code>key</code> method for adding keys before values in objects. There are
- * <code>array</code> and <code>endArray</code> methods that make and bound array values, and
- * <code>object</code> and <code>endObject</code> methods which make and bound object values. All of
- * these methods return the JSONWriter instance, permitting cascade style. For example,
- * 
- * <pre>
- * myString = new JSONStringer().object().key("JSON").value("Hello, World!").endObject().toString();
- * </pre>
- * 
- * which produces the string
- * 
- * <pre>
- * {"JSON":"Hello, World!"}
- * </pre>
- * <p>
- * The first method called must be <code>array</code> or <code>object</code>. There are no methods
- * for adding commas or colons. JSONStringer adds them for you. Objects and arrays can be nested up
- * to 20 levels deep.
- * <p>
- * This can sometimes be easier than using a JSONObject to build a string.
- * 
- * @author JSON.org
- * @version 2008-09-18
- */
-public class JSONStringer extends JSONWriter {
-  /**
-   * Make a fresh JSONStringer. It can be used to build one JSON text.
-   */
-  public JSONStringer() {
-    super(new StringWriter());
-  }
-
-  /**
-   * Return the JSON text. This method is used to obtain the product of the JSONStringer instance.
-   * It will return <code>null</code> if there was a problem in the construction of the JSON text
-   * (such as the calls to <code>array</code> were not properly balanced with calls to
-   * <code>endArray</code>).
-   * 
-   * @return The JSON text.
-   */
-  public String toString() {
-    return this.mode == 'd' ? this.writer.toString() : null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/JSONTokener.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONTokener.java b/geode-json/src/main/java/org/json/JSONTokener.java
deleted file mode 100644
index 4dd2ba2..0000000
--- a/geode-json/src/main/java/org/json/JSONTokener.java
+++ /dev/null
@@ -1,437 +0,0 @@
-package org.json;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-
-/*
- * Copyright (c) 2002 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * A JSONTokener takes a source string and extracts characters and tokens from it. It is used by the
- * JSONObject and JSONArray constructors to parse JSON source strings.
- * 
- * @author JSON.org
- * @version 2012-02-16
- */
-public class JSONTokener {
-
-  private long character;
-  private boolean eof;
-  private long index;
-  private long line;
-  private char previous;
-  private Reader reader;
-  private boolean usePrevious;
-
-
-  /**
-   * Construct a JSONTokener from a Reader.
-   *
-   * @param reader A reader.
-   */
-  public JSONTokener(Reader reader) {
-    this.reader = reader.markSupported() ? reader : new BufferedReader(reader);
-    this.eof = false;
-    this.usePrevious = false;
-    this.previous = 0;
-    this.index = 0;
-    this.character = 1;
-    this.line = 1;
-  }
-
-
-  /**
-   * Construct a JSONTokener from an InputStream.
-   */
-  public JSONTokener(InputStream inputStream) throws JSONException {
-    this(new InputStreamReader(inputStream));
-  }
-
-
-  /**
-   * Construct a JSONTokener from a string.
-   *
-   * @param s A source string.
-   */
-  public JSONTokener(String s) {
-    this(new StringReader(s));
-  }
-
-
-  /**
-   * Back up one character. This provides a sort of lookahead capability, so that you can test for a
-   * digit or letter before attempting to parse the next number or identifier.
-   */
-  public void back() throws JSONException {
-    if (this.usePrevious || this.index <= 0) {
-      throw new JSONException("Stepping back two steps is not supported");
-    }
-    this.index -= 1;
-    this.character -= 1;
-    this.usePrevious = true;
-    this.eof = false;
-  }
-
-
-  /**
-   * Get the hex value of a character (base16).
-   * 
-   * @param c A character between '0' and '9' or between 'A' and 'F' or between 'a' and 'f'.
-   * @return An int between 0 and 15, or -1 if c was not a hex digit.
-   */
-  public static int dehexchar(char c) {
-    if (c >= '0' && c <= '9') {
-      return c - '0';
-    }
-    if (c >= 'A' && c <= 'F') {
-      return c - ('A' - 10);
-    }
-    if (c >= 'a' && c <= 'f') {
-      return c - ('a' - 10);
-    }
-    return -1;
-  }
-
-  public boolean end() {
-    return this.eof && !this.usePrevious;
-  }
-
-
-  /**
-   * Determine if the source string still contains characters that next() can consume.
-   * 
-   * @return true if not yet at the end of the source.
-   */
-  public boolean more() throws JSONException {
-    this.next();
-    if (this.end()) {
-      return false;
-    }
-    this.back();
-    return true;
-  }
-
-
-  /**
-   * Get the next character in the source string.
-   *
-   * @return The next character, or 0 if past the end of the source string.
-   */
-  public char next() throws JSONException {
-    int c;
-    if (this.usePrevious) {
-      this.usePrevious = false;
-      c = this.previous;
-    } else {
-      try {
-        c = this.reader.read();
-      } catch (IOException exception) {
-        throw new JSONException(exception);
-      }
-
-      if (c <= 0) { // End of stream
-        this.eof = true;
-        c = 0;
-      }
-    }
-    this.index += 1;
-    if (this.previous == '\r') {
-      this.line += 1;
-      this.character = c == '\n' ? 0 : 1;
-    } else if (c == '\n') {
-      this.line += 1;
-      this.character = 0;
-    } else {
-      this.character += 1;
-    }
-    this.previous = (char) c;
-    return this.previous;
-  }
-
-
-  /**
-   * Consume the next character, and check that it matches a specified character.
-   * 
-   * @param c The character to match.
-   * @return The character.
-   * @throws JSONException if the character does not match.
-   */
-  public char next(char c) throws JSONException {
-    char n = this.next();
-    if (n != c) {
-      throw this.syntaxError("Expected '" + c + "' and instead saw '" + n + "'");
-    }
-    return n;
-  }
-
-
-  /**
-   * Get the next n characters.
-   *
-   * @param n The number of characters to take.
-   * @return A string of n characters.
-   * @throws JSONException Substring bounds error if there are not n characters remaining in the
-   *         source string.
-   */
-  public String next(int n) throws JSONException {
-    if (n == 0) {
-      return "";
-    }
-
-    char[] chars = new char[n];
-    int pos = 0;
-
-    while (pos < n) {
-      chars[pos] = this.next();
-      if (this.end()) {
-        throw this.syntaxError("Substring bounds error");
-      }
-      pos += 1;
-    }
-    return new String(chars);
-  }
-
-
-  /**
-   * Get the next char in the string, skipping whitespace.
-   * 
-   * @throws JSONException
-   * @return A character, or 0 if there are no more characters.
-   */
-  public char nextClean() throws JSONException {
-    for (;;) {
-      char c = this.next();
-      if (c == 0 || c > ' ') {
-        return c;
-      }
-    }
-  }
-
-
-  /**
-   * Return the characters up to the next close quote character. Backslash processing is done. The
-   * formal JSON format does not allow strings in single quotes, but an implementation is allowed to
-   * accept them.
-   * 
-   * @param quote The quoting character, either <code>"</code>&nbsp;<small>(double quote)</small> or
-   *        <code>'</code>&nbsp;<small>(single quote)</small>.
-   * @return A String.
-   * @throws JSONException Unterminated string.
-   */
-  public String nextString(char quote) throws JSONException {
-    char c;
-    StringBuffer sb = new StringBuffer();
-    for (;;) {
-      c = this.next();
-      switch (c) {
-        case 0:
-        case '\n':
-        case '\r':
-          throw this.syntaxError("Unterminated string");
-        case '\\':
-          c = this.next();
-          switch (c) {
-            case 'b':
-              sb.append('\b');
-              break;
-            case 't':
-              sb.append('\t');
-              break;
-            case 'n':
-              sb.append('\n');
-              break;
-            case 'f':
-              sb.append('\f');
-              break;
-            case 'r':
-              sb.append('\r');
-              break;
-            case 'u':
-              sb.append((char) Integer.parseInt(this.next(4), 16));
-              break;
-            case '"':
-            case '\'':
-            case '\\':
-            case '/':
-              sb.append(c);
-              break;
-            default:
-              throw this.syntaxError("Illegal escape.");
-          }
-          break;
-        default:
-          if (c == quote) {
-            return sb.toString();
-          }
-          sb.append(c);
-      }
-    }
-  }
-
-
-  /**
-   * Get the text up but not including the specified character or the end of line, whichever comes
-   * first.
-   * 
-   * @param delimiter A delimiter character.
-   * @return A string.
-   */
-  public String nextTo(char delimiter) throws JSONException {
-    StringBuffer sb = new StringBuffer();
-    for (;;) {
-      char c = this.next();
-      if (c == delimiter || c == 0 || c == '\n' || c == '\r') {
-        if (c != 0) {
-          this.back();
-        }
-        return sb.toString().trim();
-      }
-      sb.append(c);
-    }
-  }
-
-
-  /**
-   * Get the text up but not including one of the specified delimiter characters or the end of line,
-   * whichever comes first.
-   * 
-   * @param delimiters A set of delimiter characters.
-   * @return A string, trimmed.
-   */
-  public String nextTo(String delimiters) throws JSONException {
-    char c;
-    StringBuffer sb = new StringBuffer();
-    for (;;) {
-      c = this.next();
-      if (delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r') {
-        if (c != 0) {
-          this.back();
-        }
-        return sb.toString().trim();
-      }
-      sb.append(c);
-    }
-  }
-
-
-  /**
-   * Get the next value. The value can be a Boolean, Double, Integer, JSONArray, JSONObject, Long,
-   * or String, or the JSONObject.NULL object.
-   * 
-   * @throws JSONException If syntax error.
-   *
-   * @return An object.
-   */
-  public Object nextValue() throws JSONException {
-    char c = this.nextClean();
-    String string;
-
-    switch (c) {
-      case '"':
-      case '\'':
-        return this.nextString(c);
-      case '{':
-        this.back();
-        return new JSONObject(this);
-      case '[':
-        this.back();
-        return new JSONArray(this);
-    }
-
-    /*
-     * Handle unquoted text. This could be the values true, false, or null, or it can be a number.
-     * An implementation (such as this one) is allowed to also accept non-standard forms.
-     *
-     * Accumulate characters until we reach the end of the text or a formatting character.
-     */
-
-    StringBuffer sb = new StringBuffer();
-    while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
-      sb.append(c);
-      c = this.next();
-    }
-    this.back();
-
-    string = sb.toString().trim();
-    if ("".equals(string)) {
-      throw this.syntaxError("Missing value");
-    }
-    return JSONObject.stringToValue(string);
-  }
-
-
-  /**
-   * Skip characters until the next character is the requested character. If the requested character
-   * is not found, no characters are skipped.
-   * 
-   * @param to A character to skip to.
-   * @return The requested character, or zero if the requested character is not found.
-   */
-  public char skipTo(char to) throws JSONException {
-    char c;
-    try {
-      long startIndex = this.index;
-      long startCharacter = this.character;
-      long startLine = this.line;
-      this.reader.mark(1000000);
-      do {
-        c = this.next();
-        if (c == 0) {
-          this.reader.reset();
-          this.index = startIndex;
-          this.character = startCharacter;
-          this.line = startLine;
-          return c;
-        }
-      } while (c != to);
-    } catch (IOException exc) {
-      throw new JSONException(exc);
-    }
-
-    this.back();
-    return c;
-  }
-
-
-  /**
-   * Make a JSONException to signal a syntax error.
-   *
-   * @param message The error message.
-   * @return A JSONException object, suitable for throwing
-   */
-  public JSONException syntaxError(String message) {
-    return new JSONException(message + this.toString());
-  }
-
-
-  /**
-   * Make a printable string of this JSONTokener.
-   *
-   * @return " at {index} [character {character} line {line}]"
-   */
-  public String toString() {
-    return " at " + this.index + " [character " + this.character + " line " + this.line + "]";
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/76ea6c3c/geode-json/src/main/java/org/json/JSONWriter.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONWriter.java b/geode-json/src/main/java/org/json/JSONWriter.java
deleted file mode 100755
index 7d4704b..0000000
--- a/geode-json/src/main/java/org/json/JSONWriter.java
+++ /dev/null
@@ -1,321 +0,0 @@
-package org.json;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/*
- * Copyright (c) 2006 JSON.org
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
- * associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- * 
- * The Software shall be used for Good, not Evil.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * JSONWriter provides a quick and convenient way of producing JSON text. The texts produced
- * strictly conform to JSON syntax rules. No whitespace is added, so the results are ready for
- * transmission or storage. Each instance of JSONWriter can produce one JSON text.
- * <p>
- * A JSONWriter instance provides a <code>value</code> method for appending values to the text, and
- * a <code>key</code> method for adding keys before values in objects. There are <code>array</code>
- * and <code>endArray</code> methods that make and bound array values, and <code>object</code> and
- * <code>endObject</code> methods which make and bound object values. All of these methods return
- * the JSONWriter instance, permitting a cascade style. For example,
- * 
- * <pre>
- * new JSONWriter(myWriter).object().key("JSON").value("Hello, World!").endObject();
- * </pre>
- * 
- * which writes
- * 
- * <pre>
- * {"JSON":"Hello, World!"}
- * </pre>
- * <p>
- * The first method called must be <code>array</code> or <code>object</code>. There are no methods
- * for adding commas or colons. JSONWriter adds them for you. Objects and arrays can be nested up to
- * 20 levels deep.
- * <p>
- * This can sometimes be easier than using a JSONObject to build a string.
- * 
- * @author JSON.org
- * @version 2011-11-24
- */
-public class JSONWriter {
-  private static final int maxdepth = 200;
-
-  /**
-   * The comma flag determines if a comma should be output before the next value.
-   */
-  private boolean comma;
-
-  /**
-   * The current mode. Values: 'a' (array), 'd' (done), 'i' (initial), 'k' (key), 'o' (object).
-   */
-  protected char mode;
-
-  /**
-   * The object/array stack.
-   */
-  private final JSONObject stack[];
-
-  /**
-   * The stack top index. A value of 0 indicates that the stack is empty.
-   */
-  private int top;
-
-  /**
-   * The writer that will receive the output.
-   */
-  protected Writer writer;
-
-  /**
-   * Make a fresh JSONWriter. It can be used to build one JSON text.
-   */
-  public JSONWriter(Writer w) {
-    this.comma = false;
-    this.mode = 'i';
-    this.stack = new JSONObject[maxdepth];
-    this.top = 0;
-    this.writer = w;
-  }
-
-  /**
-   * Append a value.
-   * 
-   * @param string A string value.
-   * @return this
-   * @throws JSONException If the value is out of sequence.
-   */
-  private JSONWriter append(String string) throws JSONException {
-    if (string == null) {
-      throw new JSONException("Null pointer");
-    }
-    if (this.mode == 'o' || this.mode == 'a') {
-      try {
-        if (this.comma && this.mode == 'a') {
-          this.writer.write(',');
-        }
-        this.writer.write(string);
-      } catch (IOException e) {
-        throw new JSONException(e);
-      }
-      if (this.mode == 'o') {
-        this.mode = 'k';
-      }
-      this.comma = true;
-      return this;
-    }
-    throw new JSONException("Value out of sequence.");
-  }
-
-  /**
-   * Begin appending a new array. All values until the balancing <code>endArray</code> will be
-   * appended to this array. The <code>endArray</code> method must be called to mark the array's
-   * end.
-   * 
-   * @return this
-   * @throws JSONException If the nesting is too deep, or if the object is started in the wrong
-   *         place (for example as a key or after the end of the outermost array or object).
-   */
-  public JSONWriter array() throws JSONException {
-    if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {
-      this.push(null);
-      this.append("[");
-      this.comma = false;
-      return this;
-    }
-    throw new JSONException("Misplaced array.");
-  }
-
-  /**
-   * End something.
-   * 
-   * @param mode Mode
-   * @param c Closing character
-   * @return this
-   * @throws JSONException If unbalanced.
-   */
-  private JSONWriter end(char mode, char c) throws JSONException {
-    if (this.mode != mode) {
-      throw new JSONException(mode == 'a' ? "Misplaced endArray." : "Misplaced endObject.");
-    }
-    this.pop(mode);
-    try {
-      this.writer.write(c);
-    } catch (IOException e) {
-      throw new JSONException(e);
-    }
-    this.comma = true;
-    return this;
-  }
-
-  /**
-   * End an array. This method most be called to balance calls to <code>array</code>.
-   * 
-   * @return this
-   * @throws JSONException If incorrectly nested.
-   */
-  public JSONWriter endArray() throws JSONException {
-    return this.end('a', ']');
-  }
-
-  /**
-   * End an object. This method most be called to balance calls to <code>object</code>.
-   * 
-   * @return this
-   * @throws JSONException If incorrectly nested.
-   */
-  public JSONWriter endObject() throws JSONException {
-    return this.end('k', '}');
-  }
-
-  /**
-   * Append a key. The key will be associated with the next value. In an object, every value must be
-   * preceded by a key.
-   * 
-   * @param string A key string.
-   * @return this
-   * @throws JSONException If the key is out of place. For example, keys do not belong in arrays or
-   *         if the key is null.
-   */
-  public JSONWriter key(String string) throws JSONException {
-    if (string == null) {
-      throw new JSONException("Null key.");
-    }
-    if (this.mode == 'k') {
-      try {
-        this.stack[this.top - 1].putOnce(string, Boolean.TRUE);
-        if (this.comma) {
-          this.writer.write(',');
-        }
-        this.writer.write(JSONObject.quote(string));
-        this.writer.write(':');
-        this.comma = false;
-        this.mode = 'o';
-        return this;
-      } catch (IOException e) {
-        throw new JSONException(e);
-      }
-    }
-    throw new JSONException("Misplaced key.");
-  }
-
-
-  /**
-   * Begin appending a new object. All keys and values until the balancing <code>endObject</code>
-   * will be appended to this object. The <code>endObject</code> method must be called to mark the
-   * object's end.
-   * 
-   * @return this
-   * @throws JSONException If the nesting is too deep, or if the object is started in the wrong
-   *         place (for example as a key or after the end of the outermost array or object).
-   */
-  public JSONWriter object() throws JSONException {
-    if (this.mode == 'i') {
-      this.mode = 'o';
-    }
-    if (this.mode == 'o' || this.mode == 'a') {
-      this.append("{");
-      this.push(new JSONObject());
-      this.comma = false;
-      return this;
-    }
-    throw new JSONException("Misplaced object.");
-
-  }
-
-
-  /**
-   * Pop an array or object scope.
-   * 
-   * @param c The scope to close.
-   * @throws JSONException If nesting is wrong.
-   */
-  private void pop(char c) throws JSONException {
-    if (this.top <= 0) {
-      throw new JSONException("Nesting error.");
-    }
-    char m = this.stack[this.top - 1] == null ? 'a' : 'k';
-    if (m != c) {
-      throw new JSONException("Nesting error.");
-    }
-    this.top -= 1;
-    this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1] == null ? 'a' : 'k';
-  }
-
-  /**
-   * Push an array or object scope.
-   * 
-   * @param jo The scope to open.
-   * @throws JSONException If nesting is too deep.
-   */
-  private void push(JSONObject jo) throws JSONException {
-    if (this.top >= maxdepth) {
-      throw new JSONException("Nesting too deep.");
-    }
-    this.stack[this.top] = jo;
-    this.mode = jo == null ? 'a' : 'k';
-    this.top += 1;
-  }
-
-
-  /**
-   * Append either the value <code>true</code> or the value <code>false</code>.
-   * 
-   * @param b A boolean.
-   * @return this
-   * @throws JSONException
-   */
-  public JSONWriter value(boolean b) throws JSONException {
-    return this.append(b ? "true" : "false");
-  }
-
-  /**
-   * Append a double value.
-   * 
-   * @param d A double.
-   * @return this
-   * @throws JSONException If the number is not finite.
-   */
-  public JSONWriter value(double d) throws JSONException {
-    return this.value(new Double(d));
-  }
-
-  /**
-   * Append a long value.
-   * 
-   * @param l A long.
-   * @return this
-   * @throws JSONException
-   */
-  public JSONWriter value(long l) throws JSONException {
-    return this.append(Long.toString(l));
-  }
-
-
-  /**
-   * Append an object value.
-   * 
-   * @param object The object to append. It can be null, or a Boolean, Number, String, JSONObject,
-   *        or JSONArray, or an object that implements JSONString.
-   * @return this
-   * @throws JSONException If the value is out of sequence.
-   */
-  public JSONWriter value(Object object) throws JSONException {
-    return this.append(JSONObject.valueToString(object));
-  }
-}


[20/51] [abbrv] geode git commit: GEODE-2545: NPE during lucene query execution when cache is closing or region is destroyed

Posted by ds...@apache.org.
GEODE-2545: NPE during lucene query execution when cache is closing or region is destroyed

* Throw an InternalFunctionTargetInvocationException if executing a query while cache is closing


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c4a5ab28
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c4a5ab28
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c4a5ab28

Branch: refs/heads/feature/GEM-1195
Commit: c4a5ab284baba371418cb7a389cb0f327d8becdc
Parents: 8ff2fd4
Author: Jason Huynh <hu...@gmail.com>
Authored: Mon Feb 27 10:02:23 2017 -0800
Committer: Jason Huynh <hu...@gmail.com>
Committed: Mon Feb 27 10:02:23 2017 -0800

----------------------------------------------------------------------
 .../distributed/LuceneQueryFunction.java        |  4 ++++
 .../LuceneQueryFunctionJUnitTest.java           | 25 +++++++++-----------
 2 files changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c4a5ab28/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
index e0a0a22..dd70480 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
@@ -75,6 +75,10 @@ public class LuceneQueryFunction implements Function, InternalEntity {
     LuceneService service = LuceneServiceProvider.get(region.getCache());
     LuceneIndexImpl index =
         (LuceneIndexImpl) service.getIndex(searchContext.getIndexName(), region.getFullPath());
+    if (index == null) {
+      throw new InternalFunctionInvocationTargetException(
+          "Index for Region:" + region.getFullPath() + " was not found");
+    }
     RepositoryManager repoManager = index.getRepositoryManager();
     LuceneIndexStats stats = index.getIndexStats();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c4a5ab28/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
index 0d06cab..6a9af9b 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
@@ -208,20 +208,17 @@ public class LuceneQueryFunctionJUnitTest {
     function.execute(mockContext);
   }
 
-  // Disabled currently as we are retrying the function if a bucket is not found
-  // @Test(expected = FunctionException.class)
-  // public void testBucketNotFound() throws Exception {
-  // when(mockContext.getDataSet()).thenReturn(mockRegion);
-  // when(mockContext.getArguments()).thenReturn(searchArgs);
-  // when(mockContext.<TopEntriesCollector>getResultSender()).thenReturn(mockResultSender);
-  // when(mockRepoManager.getRepositories(eq(mockContext)))
-  // .thenThrow(new BucketNotFoundException(""));
-  // LuceneQueryFunction function = new LuceneQueryFunction();
-  //
-  // function.execute(mockContext);
-  //
-  // verify(mockResultSender).sendException(any(BucketNotFoundException.class));
-  // }
+  @Test(expected = FunctionException.class)
+  public void whenServiceReturnsNullIndexDuringQueryExecutionFunctionExceptionShouldBeThrown()
+      throws Exception {
+    when(mockContext.getDataSet()).thenReturn(mockRegion);
+    when(mockContext.getArguments()).thenReturn(searchArgs);
+    LuceneQueryFunction function = new LuceneQueryFunction();
+
+    when(mockService.getIndex(eq("indexName"), eq(regionPath))).thenReturn(null);
+
+    function.execute(mockContext);
+  }
 
   @Test(expected = FunctionException.class)
   public void testReduceError() throws Exception {


[50/51] [abbrv] geode git commit: Merge remote-tracking branch 'origin/develop' into feature branch for gem 1195

Posted by ds...@apache.org.
Merge remote-tracking branch 'origin/develop' into feature branch for gem 1195


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d39f26c9
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d39f26c9
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d39f26c9

Branch: refs/heads/feature/GEM-1195
Commit: d39f26c985145de5a07e024164ffaa888d579823
Parents: d6761a1 21a9b5e
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Fri Mar 3 14:07:18 2017 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Fri Mar 3 14:07:18 2017 -0800

----------------------------------------------------------------------
 BUILDING.md                                     |   70 +-
 KEYS                                            |   70 +
 LICENSE                                         |  140 +-
 NOTICE                                          |    4 +-
 README.md                                       |  176 +-
 docker/Dockerfile                               |    4 +-
 etc/eclipse-java-google-style.xml               |    2 +-
 .../internal/filter/ListenerEventType.java      |    7 +-
 .../session/installer/InstallerJUnitTest.java   |   26 +-
 .../session/Tomcat6SessionsJUnitTest.java       |    3 +-
 geode-assembly/build.gradle                     |    7 +-
 geode-assembly/src/main/dist/LICENSE            |  139 +-
 geode-assembly/src/main/dist/NOTICE             |  145 +-
 .../org/apache/geode/BundledJarsJUnitTest.java  |   27 +-
 .../management/internal/AgentUtilJUnitTest.java |   15 +-
 .../LauncherLifecycleCommandsJUnitTest.java     |   43 +
 ...erConfigurationServiceEndToEndDUnitTest.java |    8 -
 .../web/RestSecurityIntegrationTest.java        |    8 +-
 .../web/RestSecurityPostProcessorTest.java      |    3 +-
 .../internal/web/RestSecurityWithSSLTest.java   |   16 +-
 .../rest/internal/web/RestServersJUnitTest.java |    3 +-
 .../internal/web/SwaggerVerificationTest.java   |   13 +-
 .../web/controllers/NoArgumentFunction.java     |  114 +
 .../RestAPIsAndInterOpsDUnitTest.java           |   46 +-
 .../RestAPIsQueryAndFEJUnitTest.java            |   18 +-
 .../geode/tools/pulse/PulseDataExportTest.java  |  172 +
 .../src/test/resources/expected_jars.txt        |    1 -
 geode-benchmarks/build.gradle                   |    2 +
 .../source/subnavs/geode-subnav.erb             |    2 +-
 geode-core/build.gradle                         |   13 +-
 .../java/org/apache/geode/DataSerializer.java   |   69 +
 .../java/org/apache/geode/cache/Operation.java  |   16 +
 .../internal/AsyncEventQueueImpl.java           |   14 +
 .../cache/client/internal/OpExecutorImpl.java   |    4 +-
 .../geode/cache/execute/FunctionContext.java    |    3 +
 .../cache/partition/PartitionListener.java      |   11 +
 .../geode/distributed/AbstractLauncher.java     |    8 +-
 .../geode/distributed/DistributedSystem.java    |   14 +-
 .../org/apache/geode/distributed/Locator.java   |    5 +-
 .../geode/distributed/LocatorLauncher.java      |    9 +-
 .../geode/distributed/ServerLauncher.java       |    8 +-
 .../internal/DefaultPropertiesGenerator.java    |   52 +
 .../internal/DistributionAdvisor.java           |   22 +
 .../internal/DistributionConfigImpl.java        |   23 +-
 .../internal/InternalDistributedSystem.java     |    2 +
 .../distributed/internal/ResourceEvent.java     |   28 +-
 .../internal/direct/DirectChannel.java          |    4 +-
 .../membership/InternalDistributedMember.java   |   48 +-
 .../internal/membership/gms/Services.java       |   12 +-
 .../gms/locator/FindCoordinatorResponse.java    |    2 +-
 .../membership/gms/locator/GMSLocator.java      |   28 +-
 .../membership/gms/membership/GMSJoinLeave.java |    4 +-
 .../gms/mgr/GMSMembershipManager.java           |  183 +-
 .../tcpserver/LocatorCancelException.java       |   15 +-
 .../internal/tcpserver/TcpClient.java           |   10 +-
 .../org/apache/geode/internal/DSFIDFactory.java |    6 +-
 .../geode/internal/DataSerializableFixedID.java |    4 +-
 .../org/apache/geode/internal/FileUtil.java     |  328 -
 .../apache/geode/internal/GemFireVersion.java   |   13 +-
 .../geode/internal/InternalDataSerializer.java  |    5 +-
 .../org/apache/geode/internal/JarDeployer.java  |   38 +-
 .../geode/internal/cache/AbstractRegion.java    |    4 +-
 .../geode/internal/cache/BucketAdvisor.java     |   15 +-
 .../geode/internal/cache/BucketRegion.java      |    4 +-
 .../geode/internal/cache/BucketRegionQueue.java |   52 +
 .../geode/internal/cache/DestroyOperation.java  |    6 -
 .../geode/internal/cache/DiskInitFile.java      |   60 +-
 .../geode/internal/cache/DiskStoreImpl.java     |  202 +-
 .../cache/DistributedCacheOperation.java        |   27 +-
 .../cache/DistributedPutAllOperation.java       |   27 -
 .../geode/internal/cache/DistributedRegion.java |  100 +-
 .../cache/DistributedRemoveAllOperation.java    |   15 -
 .../cache/DistributedTombstoneOperation.java    |   12 +
 .../geode/internal/cache/FilterProfile.java     |   15 +-
 .../geode/internal/cache/GemFireCacheImpl.java  |   27 -
 .../internal/cache/InitialImageOperation.java   |   23 +-
 .../internal/cache/InvalidateOperation.java     |    8 -
 .../geode/internal/cache/LocalDataSet.java      |    4 +-
 .../geode/internal/cache/LocalRegion.java       |    2 +-
 .../org/apache/geode/internal/cache/OpType.java |    2 +
 .../org/apache/geode/internal/cache/Oplog.java  |  163 +-
 .../geode/internal/cache/PartitionedRegion.java |   11 +
 .../internal/cache/PersistentOplogSet.java      |   40 +-
 .../cache/ReliableDistributionData.java         |   41 -
 .../internal/cache/ReliableMessageQueue.java    |   69 -
 .../cache/ReliableMessageQueueFactory.java      |   41 -
 .../cache/ReliableMessageQueueFactoryImpl.java  |  246 -
 .../internal/cache/SendQueueOperation.java      |  190 -
 .../geode/internal/cache/TXCommitMessage.java   |   41 +-
 .../geode/internal/cache/TombstoneService.java  |   11 +-
 .../cache/UpdateEntryVersionOperation.java      |    6 -
 .../geode/internal/cache/UpdateOperation.java   |   13 -
 .../cache/partitioned/PRTombstoneMessage.java   |    2 +-
 .../cache/partitioned/RegionAdvisor.java        |   22 +
 .../cache/persistence/BackupManager.java        |   57 +-
 .../cache/persistence/RestoreScript.java        |    6 +-
 .../cache/tier/sockets/AcceptorImpl.java        |  180 +-
 .../cache/tier/sockets/BaseCommand.java         |   18 +-
 .../internal/cache/tx/ClientTXStateStub.java    |    6 +
 .../cache/tx/TransactionalOperation.java        |   16 +-
 .../cache/wan/AbstractGatewaySender.java        |   40 +-
 .../cache/wan/GatewaySenderEventImpl.java       |    2 +-
 ...aitUntilGatewaySenderFlushedCoordinator.java |   43 +
 ...ParallelGatewaySenderFlushedCoordinator.java |  181 +
 .../cache/wan/serial/BatchDestroyOperation.java |    7 -
 .../cache/xmlcache/CacheXmlVersion.java         |   43 +-
 .../geode/internal/i18n/LocalizedStrings.java   |   21 +-
 .../io/MainWithChildrenRollingFileHandler.java  |   29 +-
 .../geode/internal/jta/TransactionImpl.java     |    4 +
 .../apache/geode/internal/lang/SystemUtils.java |   39 +-
 .../geode/internal/logging/MergeLogFiles.java   |   29 +-
 .../internal/logging/log4j/AlertAppender.java   |   19 +-
 .../offheap/annotations/OffHeapIdentifier.java  |   22 +-
 .../geode/internal/process/ProcessUtils.java    |    2 +-
 .../geode/internal/process/signal/Signal.java   |  114 +-
 .../internal/process/signal/SignalType.java     |   12 +-
 .../security/IntegratedSecurityService.java     |   35 +-
 .../security/SecurableCommunicationChannel.java |   13 +-
 .../internal/security/SecurityService.java      |    2 -
 .../internal/statistics/StatArchiveHandler.java |    6 +-
 .../internal/statistics/StatArchiveReader.java  |    4 +-
 .../platform/LinuxProcFsStatistics.java         |    8 +-
 .../apache/geode/internal/tcp/Connection.java   |   14 +-
 .../geode/internal/tcp/ConnectionTable.java     |    6 +-
 .../apache/geode/internal/tcp/TCPConduit.java   |   29 +-
 .../org/apache/geode/management/JVMMetrics.java |    3 +-
 .../org/apache/geode/management/OSMetrics.java  |    3 +-
 .../internal/SystemManagementService.java       |    3 +-
 .../geode/management/internal/cli/CliUtil.java  |    5 -
 .../internal/cli/commands/DataCommands.java     |    2 +-
 ...xportImportClusterConfigurationCommands.java |   62 +-
 .../cli/commands/LauncherLifecycleCommands.java |   13 +-
 .../internal/cli/commands/ShellCommands.java    |   75 +-
 .../cli/functions/DataCommandFunction.java      |    2 +-
 .../internal/cli/functions/NetstatFunction.java |  136 +-
 .../internal/cli/i18n/CliStrings.java           |   15 +-
 .../internal/cli/json/GfJsonObject.java         |   36 -
 .../internal/cli/parser/ParserUtils.java        |    2 +-
 .../internal/cli/result/AbstractResultData.java |   74 +-
 .../internal/cli/result/ResultBuilder.java      |   30 -
 .../management/internal/cli/util/JsonUtil.java  |    2 +-
 .../functions/GetRegionNamesFunction.java       |   43 +
 .../RegionsWithDataOnServerFunction.java        |   43 -
 .../internal/configuration/utils/ZipUtils.java  |   62 +-
 .../controllers/ConfigCommandsController.java   |   10 +-
 .../support/LoginHandlerInterceptor.java        |   28 +-
 .../internal/web/http/HttpHeader.java           |   80 +-
 .../java/org/apache/geode/pdx/FieldType.java    |   65 +-
 .../org/apache/geode/pdx/JSONFormatter.java     |  109 +-
 .../apache/geode/SystemFailureJUnitTest.java    |    2 +-
 ...ventQueueEvictionAndExpirationJUnitTest.java |    2 +-
 .../client/ClientCacheFactoryJUnitTest.java     |   17 +-
 .../AutoConnectionSourceImplJUnitTest.java      |    2 +-
 .../internal/LocatorLoadBalancingDUnitTest.java |    2 +-
 ...ientExecutorSubmitTaskWithExceptionTest.java |    2 +-
 .../BaseLineAndCompareQueryPerfJUnitTest.java   |    5 +-
 .../geode/cache/query/QueryTestUtils.java       |   30 +-
 .../query/cq/dunit/CqQueryTestListener.java     |    2 +-
 .../dunit/QueryIndexUsingXMLDUnitTest.java      |   31 +-
 .../query/dunit/QueryUsingPoolDUnitTest.java    |    2 +-
 .../query/dunit/SelectStarQueryDUnitTest.java   |    4 +-
 .../functional/IndexCreationJUnitTest.java      |   51 +-
 .../geode/cache/snapshot/RegionGenerator.java   |    7 +-
 .../apache/geode/cache30/Bug44418JUnitTest.java |    4 +-
 .../cache30/ClientMembershipDUnitTest.java      |    2 +-
 .../geode/cache30/ClientServerCCEDUnitTest.java |  123 +-
 .../geode/cache30/ReconnectDUnitTest.java       |   89 +-
 .../AbstractLauncherIntegrationTestCase.java    |   16 +-
 .../geode/distributed/LocatorDUnitTest.java     |  148 +-
 .../geode/distributed/LocatorJUnitTest.java     |    2 +-
 .../LocatorUDPSecurityDUnitTest.java            |    2 +-
 ...faultPropertiesGeneratorIntegrationTest.java |  128 +
 .../internal/DistributionManagerDUnitTest.java  |   80 +-
 .../GemFireDeadlockDetectorDUnitTest.java       |    2 +-
 .../auth/AbstractGMSAuthenticatorTestCase.java  |   15 +-
 .../gms/fd/GMSHealthMonitorJUnitTest.java       |    2 +-
 .../gms/membership/GMSJoinLeaveJUnitTest.java   |    2 +-
 .../internal/DataSerializableJUnitTest.java     |   64 +-
 .../geode/internal/FileUtilJUnitTest.java       |  101 -
 .../GemFireVersionIntegrationJUnitTest.java     |   50 -
 ...ernalDataSerializerQuickcheckStringTest.java |   63 +
 .../geode/internal/JarDeployerDUnitTest.java    |  260 +-
 .../internal/JarDeployerIntegrationTest.java    |  183 +
 .../org/apache/geode/internal/JavaExec.java     |   71 -
 .../org/apache/geode/internal/LongBuffer.java   |   96 -
 .../geode/internal/PdxDeleteFieldDUnitTest.java |   30 +-
 .../geode/internal/PdxDeleteFieldJUnitTest.java |   32 +-
 .../geode/internal/PdxRenameDUnitTest.java      |   30 +-
 .../geode/internal/PdxRenameJUnitTest.java      |   20 +-
 ...hreadPoolExecutorWithKeepAliveJUnitTest.java |    2 +-
 .../geode/internal/cache/BackupDUnitTest.java   |  113 +-
 .../geode/internal/cache/BackupJUnitTest.java   |   58 +-
 .../internal/cache/ClearTXLockingDUnitTest.java |    3 +
 .../cache/ClientServerTransactionDUnitTest.java |  134 +-
 .../cache/DiskLruRegRecoveryJUnitTest.java      |  294 +
 .../cache/DiskRegRecoveryJUnitTest.java         |   10 +-
 .../cache/DiskRegionAsyncRecoveryJUnitTest.java |   28 +-
 .../internal/cache/DiskRegionHelperFactory.java |   26 +
 .../internal/cache/DiskRegionProperties.java    |   12 +-
 .../internal/cache/DiskRegionTestingBase.java   |   36 +-
 .../internal/cache/EntryEventImplTest.java      |    2 +-
 ...eAndForgetFunctionOnAllServersDUnitTest.java |    2 +-
 .../cache/FixedPRSinglehopDUnitTest.java        |   50 +-
 .../internal/cache/GemFireCacheImplTest.java    |    2 +-
 .../cache/IncrementalBackupDUnitTest.java       |  167 +-
 .../MultipleOplogsRollingFeatureJUnitTest.java  |    2 +-
 .../geode/internal/cache/OplogFlushTest.java    |  169 +
 .../geode/internal/cache/OplogJUnitTest.java    |    2 +-
 .../geode/internal/cache/OplogRVVJUnitTest.java |   42 +-
 .../cache/PartitionListenerDUnitTest.java       |   75 +
 .../PartitionedRegionSingleHopDUnitTest.java    |    2 +-
 .../cache/PartitionedRegionStatsJUnitTest.java  |   25 +-
 .../PersistentPartitionedRegionJUnitTest.java   |  163 +-
 .../internal/cache/SingleHopStatsDUnitTest.java |    2 +-
 .../geode/internal/cache/TXManagerImplTest.java |    2 +-
 .../ha/BlockingHARegionQueueJUnitTest.java      |    2 +-
 .../cache/ha/HARegionQueueJUnitTest.java        |    2 +-
 .../cache/locks/TXLockServiceDUnitTest.java     |    2 +-
 ...tentColocatedPartitionedRegionDUnitTest.java |   57 +-
 .../PersistentPartitionedRegionDUnitTest.java   |    2 +-
 .../PersistentPartitionedRegionTestBase.java    |   33 +-
 .../cache/partitioned/ShutdownAllDUnitTest.java |    2 +-
 .../fixed/FixedPartitioningTestBase.java        |   40 +-
 .../persistence/BackupInspectorJUnitTest.java   |   18 +-
 .../PersistentReplicatedTestBase.java           |   26 +-
 .../RollingUpgrade2DUnitTest.java               | 1817 +++++
 .../rollingupgrade/RollingUpgradeDUnitTest.java | 1056 +++
 .../tier/sockets/AcceptorImplDUnitTest.java     |  248 +
 .../sockets/ClientInterestNotifyDUnitTest.java  |    2 +-
 .../ClientServerForceInvalidateDUnitTest.java   |    2 +-
 .../sockets/ClientServerMiscBCDUnitTest.java    |   49 +
 .../tier/sockets/ClientServerMiscDUnitTest.java |   70 +-
 .../ClientServerMiscSelectorDUnitTest.java      |   11 +-
 .../DurableClientQueueSizeDUnitTest.java        |    2 +-
 .../cache/tier/sockets/HABug36738DUnitTest.java |    4 +-
 .../sockets/HAStartupAndFailoverDUnitTest.java  |    2 +-
 .../tier/sockets/InterestListDUnitTest.java     |   99 +
 .../sockets/UpdatePropagationDUnitTest.java     |    2 +-
 .../tier/sockets/command/CreateRegionTest.java  |    8 -
 .../tier/sockets/command/DestroyRegionTest.java |    4 -
 ...atewaySenderFlushedCoordinatorJUnitTest.java |   62 +
 .../asyncqueue/AsyncEventListenerDUnitTest.java |    4 +-
 .../AsyncEventQueueValidationsJUnitTest.java    |    2 +-
 ...atewaySenderFlushedCoordinatorJUnitTest.java |  124 +
 ...ildrenRollingFileHandlerIntegrationTest.java |   96 +
 .../internal/lang/SystemUtilsJUnitTest.java     |   78 +-
 .../logging/log4j/Log4J2PerformanceTest.java    |   27 +-
 .../log4j/LogWriterLoggerPerformanceTest.java   |   27 +-
 .../log4j/custom/CustomConfiguration.java       |   10 +-
 .../internal/net/SSLSocketIntegrationTest.java  |   51 +-
 .../offheap/OutOfOffHeapMemoryDUnitTest.java    |    2 +-
 ...leProcessControllerIntegrationJUnitTest.java |    2 +-
 .../DiskSpaceLimitIntegrationTest.java          |  245 +-
 .../StatArchiveHandlerIntegrationTest.java      |  243 +
 ...veWithMissingResourceTypeRegressionTest.java |    3 +-
 .../statistics/StatSamplerIntegrationTest.java  |    2 +-
 .../statistics/StatisticsDistributedTest.java   |    2 +-
 .../geode/internal/tcp/ConnectionJUnitTest.java |    3 +-
 .../management/CacheManagementDUnitTest.java    | 1008 ++-
 .../management/ClientHealthStatsDUnitTest.java  |  576 +-
 .../management/CompositeTypeTestDUnitTest.java  |  190 +-
 .../ConnectToLocatorSSLDUnitTest.java           |   16 +-
 .../management/DLockManagementDUnitTest.java    |  547 +-
 .../management/DiskManagementDUnitTest.java     |  787 +-
 .../management/DistributedSystemDUnitTest.java  |  998 +--
 .../geode/management/JMXMBeanDUnitTest.java     |  380 +-
 .../geode/management/ManagementTestBase.java    |  544 +-
 .../geode/management/ManagementTestRule.java    |  445 ++
 .../org/apache/geode/management/Manager.java    |   29 +
 .../org/apache/geode/management/Member.java     |   29 +
 .../management/OffHeapManagementDUnitTest.java  |  347 +-
 .../geode/management/QueryDataDUnitTest.java    | 1309 ++--
 .../management/RegionManagementDUnitTest.java   | 1807 ++---
 ...ersalMembershipListenerAdapterDUnitTest.java |   60 +-
 .../stats/DistributedSystemStatsDUnitTest.java  |  132 +-
 .../management/internal/cli/HeadlessGfsh.java   |   24 +-
 .../cli/HeadlessGfshIntegrationTest.java        |   69 +-
 .../internal/cli/NetstatDUnitTest.java          |  119 +
 ...eateAlterDestroyRegionCommandsDUnitTest.java |    6 +-
 .../cli/commands/DeployCommandsDUnitTest.java   |    5 +-
 .../commands/DiskStoreCommandsDUnitTest.java    |   10 +-
 .../commands/GemfireDataCommandsDUnitTest.java  |   81 +
 ...laneousCommandsExportLogsPart1DUnitTest.java |   21 +-
 ...laneousCommandsExportLogsPart2DUnitTest.java |   22 +-
 ...laneousCommandsExportLogsPart3DUnitTest.java |   17 +-
 ...laneousCommandsExportLogsPart4DUnitTest.java |   21 +-
 .../cli/commands/QueueCommandsDUnitTest.java    |   10 +-
 .../cli/commands/UserCommandsDUnitTest.java     |   10 +-
 .../DescribeDiskStoreFunctionJUnitTest.java     |   58 +-
 .../configuration/ClusterConfigBaseTest.java    |   71 +-
 .../ClusterConfigDeployJarDUnitTest.java        |   61 +-
 .../ClusterConfigDistributionDUnitTest.java     |   23 +-
 .../ClusterConfigImportDUnitTest.java           |   99 +-
 .../ClusterConfigStartMemberDUnitTest.java      |    2 +-
 .../ClusterConfigWithSecurityDUnitTest.java     |   42 +-
 ...erConfigurationServiceUsingDirDUnitTest.java |    4 +-
 .../configuration/ZipUtilsJUnitTest.java        |    2 +-
 .../internal/pulse/TestClientIdsDUnitTest.java  |  320 +-
 .../pulse/TestSubscriptionsDUnitTest.java       |  288 +-
 .../CacheServerMBeanShiroJUnitTest.java         |    8 +-
 .../security/CacheServerStartupRule.java        |   23 +-
 .../security/DeployCommandsSecurityTest.java    |   11 +-
 .../security/GfshCommandsPostProcessorTest.java |   37 +-
 .../security/GfshCommandsSecurityTest.java      |   31 +-
 ...atedSecurityServiceWithIniFileJUnitTest.java |   36 +-
 .../security/JavaRmiServerNameTest.java         |   11 +-
 .../security/MemberMBeanSecurityJUnitTest.java  |   22 +-
 .../internal/security/MultiUserDUnitTest.java   |    2 +-
 .../geode/pdx/AutoSerializableJUnitTest.java    |    5 +-
 .../geode/pdx/PdxAttributesJUnitTest.java       |   19 +-
 .../geode/pdx/PdxClientServerDUnitTest.java     |  343 +-
 .../geode/pdx/PdxSerializableDUnitTest.java     |   12 -
 .../geode/pdx/PdxSerializableJUnitTest.java     |   72 +-
 .../security/AbstractSecureServerDUnitTest.java |    7 +-
 .../ClusterConfigWithoutSecurityDUnitTest.java  |   36 +-
 .../PDXGfshPostProcessorOnRemoteServerTest.java |    2 +-
 .../security/PDXPostProcessorDUnitTest.java     |    2 +-
 .../security/PeerAuthenticatorDUnitTest.java    |   24 +-
 ...eerSecurityWithEmbeddedLocatorDUnitTest.java |   32 +-
 .../SecurityClusterConfigDUnitTest.java         |   25 +-
 .../SecurityWithoutClusterConfigDUnitTest.java  |   32 +-
 .../security/StartServerAuthorizationTest.java  |   42 +-
 .../geode/test/dunit/AsyncInvocation.java       |   56 +-
 .../org/apache/geode/test/dunit/DUnitEnv.java   |    4 +-
 .../java/org/apache/geode/test/dunit/Host.java  |   42 +
 .../org/apache/geode/test/dunit/Invoke.java     |   20 +-
 .../geode/test/dunit/RepeatableRunnable.java    |    3 +-
 .../test/dunit/StoppableWaitCriterion.java      |    2 +-
 .../java/org/apache/geode/test/dunit/VM.java    |   47 +-
 .../java/org/apache/geode/test/dunit/Wait.java  |   30 +-
 .../apache/geode/test/dunit/WaitCriterion.java  |    8 +-
 .../cache/internal/JUnit4CacheTestCase.java     |   15 +-
 .../internal/JUnit4DistributedTestCase.java     |    4 +-
 .../dunit/rules/DistributedDisconnectRule.java  |    4 +-
 .../DistributedRestoreSystemProperties.java     |   16 +-
 .../DistributedUseJacksonForJsonPathRule.java   |   50 +
 .../dunit/rules/GfshShellConnectionRule.java    |  132 +-
 .../apache/geode/test/dunit/rules/Locator.java  |    6 +-
 .../rules/LocatorServerConfigurationRule.java   |    2 +-
 .../dunit/rules/LocatorServerStartupRule.java   |  100 +-
 .../test/dunit/rules/LocatorStarterRule.java    |   81 +-
 .../dunit/rules/MBeanServerConnectionRule.java  |  101 +-
 .../apache/geode/test/dunit/rules/Member.java   |   12 +-
 .../geode/test/dunit/rules/RemoteInvoker.java   |   22 +-
 .../apache/geode/test/dunit/rules/Server.java   |    6 +-
 .../test/dunit/rules/ServerStarterRule.java     |  104 +-
 .../geode/test/dunit/standalone/ChildVM.java    |    8 +-
 .../test/dunit/standalone/DUnitLauncher.java    |  136 +-
 .../test/dunit/standalone/ProcessManager.java   |  129 +-
 .../dunit/standalone/StandAloneDUnitEnv.java    |   11 +-
 .../test/dunit/standalone/VersionManager.java   |  147 +
 .../standalone/VersionManagerJUnitTest.java     |   47 +
 .../org/apache/geode/util/test/TestUtil.java    |    8 +-
 .../geode/codeAnalysis/excludedClasses.txt      |    1 +
 .../sanctionedDataSerializables.txt             | 1088 +--
 .../codeAnalysis/sanctionedSerializables.txt    |    4 +-
 .../cli/commands/golden-help-offline.properties |   16 +-
 .../internal/configuration/cluster.jar          |  Bin 617 -> 0 bytes
 .../internal/configuration/cluster_config.zip   |  Bin 4172 -> 0 bytes
 .../configuration/cluster_config_security.zip   |  Bin 950 -> 0 bytes
 .../internal/configuration/group1.jar           |  Bin 617 -> 0 bytes
 .../internal/configuration/group2.jar           |  Bin 617 -> 0 bytes
 .../sockets/DurableClientSimpleDUnitTest.java   |    2 +-
 .../cli/commands/ClientCommandsDUnitTest.java   |    2 +-
 .../geode/security/CQClientAuthDunitTest.java   |   14 +-
 .../security/CQPDXPostProcessorDUnitTest.java   |    2 +-
 geode-docs/about_geode.html.md.erb              |    2 +-
 .../auto_serialization.html.md.erb              |   11 +-
 .../jsonformatter_pdxinstances.html.md.erb      |   13 +-
 .../15_minute_quickstart_gfsh.html.md.erb       |    4 +
 .../getting_started/product_intro.html.md.erb   |   46 +-
 .../logging/configuring_log4j2.html.md.erb      |    6 +-
 .../managing/security/ssl_example.html.md.erb   |    2 +-
 geode-docs/prereq_and_install.html.md.erb       |    2 +-
 .../topics/gemfire_properties.html.md.erb       |  100 +-
 .../gfsh/command-pages/connect.html.md.erb      |    2 +-
 .../gfsh/command-pages/start.html.md.erb        |   15 +-
 .../gfsh/command_scripting.html.md.erb          |    2 +-
 .../gfsh/getting_started_gfsh.html.md.erb       |    3 +-
 .../tools_modules/gfsh/tour_of_gfsh.html.md.erb |   15 +-
 ...nt_server_example_configurations.html.md.erb |    2 +-
 geode-json/build.gradle                         |   20 +
 geode-json/src/main/java/org/json/CDL.java      |  272 -
 geode-json/src/main/java/org/json/Cookie.java   |  162 -
 .../src/main/java/org/json/CookieList.java      |   87 -
 geode-json/src/main/java/org/json/HTTP.java     |  185 -
 .../src/main/java/org/json/HTTPTokener.java     |   77 -
 geode-json/src/main/java/org/json/JSON.java     |  112 +
 .../src/main/java/org/json/JSONArray.java       | 1137 ++-
 .../src/main/java/org/json/JSONException.java   |   62 +-
 geode-json/src/main/java/org/json/JSONML.java   |  454 --
 .../src/main/java/org/json/JSONObject.java      | 1915 ++---
 .../src/main/java/org/json/JSONStringer.java    |  492 +-
 .../src/main/java/org/json/JSONTokener.java     |  852 +-
 .../src/main/java/org/json/JSONWriter.java      |  321 -
 geode-json/src/main/java/org/json/XML.java      |  504 --
 .../src/main/java/org/json/XMLTokener.java      |  362 -
 geode-json/src/test/resources/sample-01.json    |  227 +
 geode-junit/build.gradle                        |    1 +
 .../categories/BackwardCompatibilityTest.java   |   22 +
 .../junit/rules/UseJacksonForJsonPathRule.java  |  128 +
 .../SerializableExternalResource.java           |   22 +
 .../serializable/SerializableStatement.java     |   25 +
 geode-lucene/build.gradle                       |    2 +
 .../apache/geode/cache/lucene/LuceneIndex.java  |   26 +-
 .../apache/geode/cache/lucene/LuceneQuery.java  |   46 +-
 .../cache/lucene/LuceneQueryException.java      |    2 +-
 .../geode/cache/lucene/LuceneQueryFactory.java  |   74 +-
 .../geode/cache/lucene/LuceneQueryProvider.java |   24 +-
 .../geode/cache/lucene/LuceneResultStruct.java  |   25 +-
 .../geode/cache/lucene/LuceneService.java       |  170 +-
 .../cache/lucene/LuceneServiceProvider.java     |    2 +-
 .../lucene/PageableLuceneQueryResults.java      |   22 +-
 .../AbstractPartitionedRepositoryManager.java   |   36 +-
 .../internal/DestroyLuceneIndexMessage.java     |  109 +
 .../lucene/internal/IndexRepositoryFactory.java |   89 +-
 .../lucene/internal/InternalLuceneIndex.java    |    5 +
 .../lucene/internal/LuceneBucketListener.java   |   65 +
 .../lucene/internal/LuceneEventListener.java    |   45 +-
 .../internal/LuceneExceptionObserver.java       |   25 +
 .../LuceneIndexForPartitionedRegion.java        |  129 +-
 .../cache/lucene/internal/LuceneIndexImpl.java  |   60 +-
 .../cache/lucene/internal/LuceneIndexStats.java |    5 +-
 .../internal/LucenePrimaryBucketListener.java   |   49 -
 .../lucene/internal/LuceneQueryFactoryImpl.java |   16 +-
 .../cache/lucene/internal/LuceneQueryImpl.java  |   33 +-
 .../cache/lucene/internal/LuceneRawIndex.java   |    2 +
 .../lucene/internal/LuceneResultStructImpl.java |    5 -
 .../lucene/internal/LuceneServiceImpl.java      |  102 +-
 .../PageableLuceneQueryResultsImpl.java         |   23 +-
 .../internal/PartitionedRepositoryManager.java  |    8 +-
 .../internal/RawIndexRepositoryFactory.java     |   13 +-
 .../internal/RawLuceneRepositoryManager.java    |   26 +-
 .../lucene/internal/cli/LuceneCliStrings.java   |   28 +-
 .../cli/LuceneFunctionSerializable.java         |   36 +
 .../internal/cli/LuceneIndexCommands.java       |  113 +-
 .../lucene/internal/cli/LuceneIndexDetails.java |   16 +-
 .../lucene/internal/cli/LuceneIndexInfo.java    |   15 +-
 .../lucene/internal/cli/LuceneQueryInfo.java    |   15 +-
 .../functions/LuceneDestroyIndexFunction.java   |   57 +
 .../internal/directory/FileIndexInput.java      |    1 +
 .../internal/directory/RegionDirectory.java     |   34 +-
 .../internal/distributed/LuceneFunction.java    |  132 -
 .../distributed/LuceneQueryFunction.java        |  160 +
 .../distributed/WaitUntilFlushedFunction.java   |  103 +
 .../WaitUntilFlushedFunctionContext.java        |   93 +
 .../internal/distributed/package-info.java      |    4 +-
 .../cache/lucene/internal/filesystem/File.java  |    5 +-
 .../lucene/internal/filesystem/FileSystem.java  |   67 +-
 .../partition/BucketTargetingFixedResolver.java |   79 +
 .../internal/partition/BucketTargetingMap.java  |  118 +
 .../partition/BucketTargetingResolver.java      |   39 +
 .../repository/IndexRepositoryImpl.java         |   37 +-
 .../internal/results/LuceneGetPageFunction.java |   83 +
 .../internal/results/MapResultCollector.java    |   58 +
 .../lucene/internal/results/PageEntry.java      |   98 +
 .../lucene/internal/results/PageResults.java    |   60 +
 .../internal/xml/LuceneIndexCreation.java       |    5 +-
 .../apache/geode/cache/lucene/package-info.java |    8 +-
 .../geode/cache/lucene/LuceneDUnitTest.java     |  122 +-
 .../lucene/LuceneIndexCreationDUnitTest.java    |  195 +-
 .../LuceneIndexCreationIntegrationTest.java     |    2 +-
 .../LuceneIndexCreationOnFixedPRDUnitTest.java  |   51 +
 ...IndexCreationPersistenceIntegrationTest.java |    2 +-
 .../lucene/LuceneIndexDestroyDUnitTest.java     |  247 +
 .../LuceneIndexMaintenanceIntegrationTest.java  |   37 +-
 .../cache/lucene/LuceneQueriesAccessorBase.java |  211 +
 .../geode/cache/lucene/LuceneQueriesBase.java   |  208 -
 .../lucene/LuceneQueriesClientDUnitTest.java    |   18 +-
 .../cache/lucene/LuceneQueriesDUnitTest.java    |  142 +
 .../lucene/LuceneQueriesIntegrationTest.java    |   63 +-
 .../geode/cache/lucene/LuceneQueriesPRBase.java |  195 -
 .../lucene/LuceneQueriesPeerPRDUnitTest.java    |   41 -
 .../LuceneQueriesPeerPROverflowDUnitTest.java   |   44 -
 .../LuceneQueriesPeerPRRedundancyDUnitTest.java |  143 -
 ...LuceneQueriesPersistenceIntegrationTest.java |    3 +-
 .../geode/cache/lucene/PaginationDUnitTest.java |  210 +
 .../geode/cache/lucene/RebalanceDUnitTest.java  |  197 +
 .../RebalanceWithRedundancyDUnitTest.java       |  180 +
 .../internal/LuceneEventListenerJUnitTest.java  |   26 +
 .../lucene/internal/LuceneIndexFactorySpy.java  |   80 +
 .../internal/LuceneIndexImplJUnitTest.java      |   32 -
 .../LuceneIndexRecoveryHAIntegrationTest.java   |   14 +-
 .../internal/LuceneIndexStatsJUnitTest.java     |    1 +
 .../LuceneQueryFactoryImplJUnitTest.java        |    3 -
 .../internal/LuceneQueryImplJUnitTest.java      |   58 +-
 .../LuceneServiceImplIntegrationTest.java       |   15 +-
 .../internal/LuceneServiceImplJUnitTest.java    |   30 +-
 ...PageableLuceneQueryResultsImplJUnitTest.java |   39 +-
 .../PartitionedRepositoryManagerJUnitTest.java  |   35 +-
 .../RawLuceneRepositoryManagerJUnitTest.java    |   41 +-
 .../cli/LuceneIndexCommandsDUnitTest.java       |   54 +-
 .../cli/LuceneIndexCommandsJUnitTest.java       |   53 +
 .../LuceneDestroyIndexFunctionJUnitTest.java    |   93 +
 .../LuceneClusterConfigurationDUnitTest.java    |  241 +-
 .../DumpDirectoryFilesIntegrationTest.java      |    3 +-
 .../directory/RegionDirectoryJUnitTest.java     |    7 +
 .../DistributedScoringJUnitTest.java            |    2 +-
 .../LuceneFunctionContextJUnitTest.java         |   59 -
 .../distributed/LuceneFunctionJUnitTest.java    |  299 -
 .../LuceneQueryFunctionContextJUnitTest.java    |   59 +
 .../LuceneQueryFunctionJUnitTest.java           |  319 +
 .../WaitUntilFlushedFunctionJUnitTest.java      |  106 +
 .../filesystem/FileSystemJUnitTest.java         |   35 +-
 .../management/LuceneManagementDUnitTest.java   |   25 +-
 .../BucketTargetingFixedResolverTest.java       |   66 +
 .../partition/BucketTargetingMapTest.java       |   66 +
 .../IndexRepositoryImplJUnitTest.java           |    4 +-
 .../results/LuceneGetPageFunctionJUnitTest.java |   65 +
 .../internal/results/PageEntryJUnitTest.java    |   93 +
 .../internal/results/PageResultsJUnitTest.java  |   44 +
 .../cache/lucene/test/IndexRepositorySpy.java   |   19 +-
 .../cache/lucene/test/LuceneTestUtilities.java  |  115 +-
 geode-old-versions/build.gradle                 |   68 +
 geode-pulse/src/main/webapp/META-INF/NOTICE     |   10 +-
 .../tools/pulse/tests/PulseDataExportTest.java  |  174 -
 .../tools/pulse/tests/rules/ServerRule.java     |    2 +-
 .../util/AutoBalancerIntegrationJUnitTest.java  |    2 +-
 geode-site/.gitignore                           |    1 -
 geode-site/website/.gitignore                   |    1 -
 geode-site/website/README.md                    |  100 -
 geode-site/website/Rules                        |   70 -
 geode-site/website/build.sh                     |   18 -
 .../website/content/bootstrap/bootstrap.min.css |    9 -
 geode-site/website/content/community/index.html |  272 -
 .../website/content/css/bootflat-extensions.css |  356 -
 .../website/content/css/bootflat-square.css     |   69 -
 geode-site/website/content/css/bootflat.css     | 1559 ----
 .../website/content/css/font-awesome.min.css    |    4 -
 geode-site/website/content/css/geode-site.css   | 1612 ----
 .../website/content/docs/guide/10/CONTRIBUTE    |   53 -
 .../content/docs/guide/10/about_geode.html      | 3209 --------
 .../docs/guide/10/basic_config/book_intro.html  | 3222 --------
 .../config_concepts/chapter_overview.html       | 3222 --------
 ...distributed_system_member_configuration.html | 3238 --------
 .../config_concepts/local_vs_remote.html        | 3212 --------
 .../chapter_overview.html                       | 3216 --------
 .../managing_data_entries.html                  | 3315 --------
 .../using_custom_classes.html                   | 3241 --------
 .../data_regions/chapter_overview.html          | 3232 --------
 .../data_regions/create_a_region_with_gfsh.html | 3227 --------
 .../creating_custom_attributes.html             | 3250 --------
 .../data_regions/managing_data_regions.html     | 3489 ---------
 .../managing_region_attributes.html             | 3285 --------
 .../data_regions/new_region_existing_data.html  | 3211 --------
 .../data_regions/region_naming.html             | 3217 --------
 .../data_regions/region_shortcuts.html          | 3316 --------
 .../store_retrieve_region_shortcuts.html        | 3258 --------
 .../setting_distributed_properties.html         | 3260 --------
 .../the_cache/chapter_overview.html             | 3228 --------
 .../the_cache/intro_cache_management.html       | 3281 --------
 .../the_cache/managing_a_client_cache.html      | 3256 --------
 .../the_cache/managing_a_multiuser_cache.html   | 3250 --------
 .../the_cache/managing_a_peer_server_cache.html | 3258 --------
 .../the_cache/managing_a_secure_cache.html      | 3244 --------
 .../the_cache/setting_cache_initializer.html    | 3250 --------
 .../the_cache/setting_cache_properties.html     | 3225 --------
 .../guide/10/configuring/chapter_overview.html  | 3257 --------
 .../deploying_application_jars.html             | 3286 --------
 .../cluster_config/export-import.html           | 3233 --------
 .../gfsh_config_troubleshooting.html            | 3260 --------
 .../gfsh_load_from_shared_dir.html              | 3228 --------
 .../cluster_config/gfsh_persist.html            | 3325 --------
 .../configuring/cluster_config/gfsh_remote.html | 3263 --------
 .../persisting_configurations.html              | 3466 ---------
 .../cluster_config/using_member_groups.html     | 3229 --------
 .../configuring/running/change_file_spec.html   | 3233 --------
 .../configuring/running/default_file_specs.html | 3263 --------
 .../running/deploy_config_files_intro.html      | 3223 --------
 .../running/deploying_config_files.html         | 3227 --------
 .../running/deploying_config_jar_files.html     | 3236 --------
 .../running/firewall_ports_config.html          | 3216 --------
 .../running/firewalls_connections.html          | 3220 --------
 .../running/firewalls_multisite.html            | 3270 --------
 .../10/configuring/running/firewalls_ports.html | 3429 --------
 .../running/managing_output_files.html          | 3216 --------
 .../running/running_the_cacheserver.html        | 3342 --------
 .../running/running_the_locator.html            | 3398 --------
 .../running/starting_up_shutting_down.html      | 3315 --------
 .../docs/guide/10/developing/book_intro.html    | 3248 --------
 .../continuous_querying/chapter_overview.html   | 3221 --------
 .../continuous_querying_whats_next.html         | 3331 --------
 .../how_continuous_querying_works.html          | 3297 --------
 .../implementing_continuous_querying.html       | 3382 --------
 .../PDX_Serialization_Features.html             | 3225 --------
 .../data_serialization/auto_serialization.html  | 3316 --------
 ...erialization_with_class_pattern_strings.html | 3252 --------
 .../data_serialization/chapter_overview.html    | 3222 --------
 .../data_serialization_options.html             | 3289 --------
 .../extending_the_autoserializer.html           | 3309 --------
 .../gemfire_data_serialization.html             | 3234 --------
 .../gemfire_pdx_serialization.html              | 3240 --------
 .../data_serialization/java_serialization.html  | 3212 --------
 .../jsonformatter_pdxinstances.html             | 3235 --------
 .../persist_pdx_metadata_to_disk.html           | 3236 --------
 .../program_application_for_pdx.html            | 3288 --------
 .../use_pdx_high_level_steps.html               | 3232 --------
 .../use_pdx_serializable.html                   | 3294 --------
 .../data_serialization/use_pdx_serializer.html  | 3319 --------
 .../using_PdxInstanceFactory.html               | 3231 --------
 .../using_pdx_region_entry_keys.html            | 3214 --------
 .../delta_propagation/chapter_overview.html     | 3228 --------
 .../delta_propagation_example.html              | 3314 --------
 .../delta_propagation_properties.html           | 3276 --------
 .../errors_in_delta_propagation.html            | 3226 --------
 .../how_delta_propagation_works.html            | 3265 --------
 .../implementing_delta_propagation.html         | 3229 --------
 .../when_to_use_delta_prop.html                 | 3219 --------
 .../distributed_regions/chapter_overview.html   | 3225 --------
 .../choosing_level_of_dist.html                 | 3220 --------
 .../how_distribution_works.html                 | 3233 --------
 .../how_region_versioning_works.html            | 3312 --------
 .../how_region_versioning_works_wan.html        | 3227 --------
 .../how_replication_works.html                  | 3237 --------
 .../locking_in_global_regions.html              | 3284 --------
 .../managing_distributed_regions.html           | 3238 --------
 .../region_entry_versions.html                  | 3230 --------
 .../events/cache_event_handler_examples.html    | 3319 --------
 .../10/developing/events/chapter_overview.html  | 3225 --------
 ...configure_client_server_event_messaging.html | 3264 --------
 .../configure_multisite_event_messaging.html    | 3222 --------
 .../events/configure_p2p_event_messaging.html   | 3233 --------
 .../configuring_gateway_concurrency_levels.html | 3334 --------
 ...iguring_highly_available_gateway_queues.html | 3290 --------
 .../configuring_highly_available_servers.html   | 3248 --------
 .../conflate_multisite_gateway_queue.html       | 3299 --------
 .../conflate_server_subscription_queue.html     | 3230 --------
 .../events/event_handler_overview.html          | 3222 --------
 .../events/filtering_multisite_events.html      | 3294 --------
 .../events/ha_event_messaging_whats_next.html   | 3273 --------
 .../events/how_cache_events_work.html           | 3266 --------
 .../how_client_server_distribution_works.html   | 3346 --------
 .../10/developing/events/how_events_work.html   | 3302 --------
 .../how_multisite_distribution_works.html       | 3260 --------
 .../implementing_cache_event_handlers.html      | 3325 --------
 ...menting_durable_client_server_messaging.html | 3385 --------
 ...implementing_write_behind_event_handler.html | 3405 --------
 .../limit_server_subscription_queue_size.html   | 3249 --------
 .../list_of_event_handlers_and_events.html      | 3364 --------
 .../events/resolving_multisite_conflicts.html   | 3259 --------
 .../tune_client_message_tracking_timeout.html   | 3230 --------
 .../tune_client_server_event_messaging.html     | 3220 --------
 ...writing_callbacks_that_modify_the_cache.html | 3249 --------
 .../developing/eviction/chapter_overview.html   | 3218 --------
 .../eviction/configuring_data_eviction.html     | 3265 --------
 .../developing/eviction/how_eviction_works.html | 3223 --------
 .../developing/expiration/chapter_overview.html | 3216 --------
 .../expiration/configuring_data_expiration.html | 3262 --------
 .../expiration/how_expiration_works.html        | 3259 --------
 .../function_exec/chapter_overview.html         | 3219 --------
 .../function_exec/function_execution.html       | 3442 --------
 .../how_function_execution_works.html           | 3324 --------
 .../chapter_overview.html                       | 3222 --------
 .../outside_data_sources/chapter_overview.html  | 3222 --------
 .../how_data_loaders_work.html                  | 3237 --------
 .../implementing_data_loaders.html              | 3270 --------
 .../outside_data_sources/sync_outside_data.html | 3219 --------
 .../automated_rebalance.html                    | 3252 --------
 .../partitioned_regions/chapter_overview.html   | 3241 --------
 .../checking_region_redundancy.html             | 3232 --------
 .../colocating_partitioned_region_data.html     | 3315 --------
 .../configure_pr_single_hop.html                | 3216 --------
 .../configuring_bucket_for_pr.html              | 3250 --------
 .../configuring_ha_for_pr.html                  | 3243 --------
 ...custom_partitioning_and_data_colocation.html | 3247 --------
 .../how_partitioning_works.html                 | 3244 --------
 .../partitioned_regions/how_pr_ha_works.html    | 3251 --------
 .../how_pr_single_hop_works.html                | 3235 --------
 .../join_query_partitioned_regions.html         | 3271 --------
 .../managing_partitioned_regions.html           | 3229 --------
 .../moving_partitioned_data.html                | 3253 --------
 ...custom_partitioning_and_data_colocation.html | 3219 --------
 .../overview_how_pr_ha_works.html               | 3216 --------
 .../overview_how_pr_single_hop_works.html       | 3216 --------
 .../rebalancing_pr_data.html                    | 3285 --------
 .../set_crash_redundancy_recovery.html          | 3248 --------
 .../set_enforce_unique_host.html                | 3214 --------
 .../set_join_redundancy_recovery.html           | 3254 --------
 .../partitioned_regions/set_pr_redundancy.html  | 3228 --------
 .../set_redundancy_zones.html                   | 3223 --------
 .../using_custom_partition_resolvers.html       | 3404 --------
 .../query_additional/advanced_querying.html     | 3228 --------
 .../query_additional/case_sensitivity.html      | 3213 --------
 .../developing/query_additional/literals.html   | 3272 --------
 .../developing/query_additional/operators.html  | 3259 --------
 .../order_by_on_partitioned_regions.html        | 3215 --------
 .../partitioned_region_key_or_field_value.html  | 3266 --------
 .../partitioned_region_query_restrictions.html  | 3229 --------
 .../query_additional/query_debugging.html       | 3262 --------
 .../query_language_features.html                | 3219 --------
 .../query_on_a_single_node.html                 | 3345 --------
 .../query_additional/supported_keywords.html    | 3329 --------
 .../using_query_bind_parameters.html            | 3244 --------
 .../query_index/create_multiple_indexes.html    | 3246 --------
 .../query_index/creating_an_index.html          | 3277 --------
 .../query_index/creating_hash_indexes.html      | 3246 --------
 .../query_index/creating_key_indexes.html       | 3242 --------
 .../query_index/creating_map_indexes.html       | 3232 --------
 .../developing/query_index/index_samples.html   | 3257 --------
 .../indexes_on_single_region_queries.html       | 3226 --------
 .../indexes_with_overflow_regions.html          | 3234 --------
 .../query_index/indexing_guidelines.html        | 3229 --------
 .../query_index/maintaining_indexes.html        | 3250 --------
 .../10/developing/query_index/query_index.html  | 3252 --------
 .../query_index/query_index_hints.html          | 3217 --------
 .../using_indexes_with_equijoin_queries.html    | 3269 --------
 ..._with_equijoin_queries_multiple_regions.html | 3311 --------
 .../10/developing/query_select/aggregates.html  | 3288 --------
 .../query_select/the_from_clause.html           | 3266 --------
 .../query_select/the_import_statement.html      | 3211 --------
 .../query_select/the_select_statement.html      | 3360 --------
 .../query_select/the_where_clause.html          | 3486 ---------
 .../querying_basics/chapter_overview.html       | 3221 --------
 .../comments_in_query_strings.html              | 3210 --------
 .../monitor_queries_for_low_memory.html         | 3223 --------
 .../querying_basics/oql_compared_to_sql.html    | 3216 --------
 .../performance_considerations.html             | 3218 --------
 .../querying_basics/query_basics.html           | 3232 --------
 .../query_grammar_and_reserved_words.html       | 3340 --------
 .../querying_partitioned_regions.html           | 3221 --------
 .../querying_basics/reserved_words.html         | 3306 --------
 .../restrictions_and_unsupported_features.html  | 3218 --------
 .../querying_basics/running_a_query.html        | 3266 --------
 .../supported_character_sets.html               | 3207 --------
 .../querying_basics/what_is_a_query_string.html | 3234 --------
 .../region_options/chapter_overview.html        | 3222 --------
 .../data_hosts_and_accessors.html               | 3216 --------
 .../region_options/dynamic_region_creation.html | 3374 --------
 .../developing/region_options/region_types.html | 3339 --------
 .../storage_distribution_options.html           | 3226 --------
 .../storing_data_on_disk/chapter_overview.html  | 3224 --------
 .../how_persist_overflow_work.html              | 3249 --------
 .../overflow_config_examples.html               | 3232 --------
 .../storing_data_on_disk.html                   | 3269 --------
 .../transactions/JTA_transactions.html          | 3404 --------
 .../transactions/about_transactions.html        | 3231 --------
 .../transactions/cache_plugins_with_jta.html    | 3211 --------
 .../cache_transaction_performance.html          | 3214 --------
 .../transactions/cache_transactions.html        | 3230 --------
 .../cache_transactions_by_region_type.html      | 3352 --------
 .../transactions/chapter_overview.html          | 3228 --------
 .../client_server_transactions.html             | 3236 --------
 .../configuring_db_connections_using_JNDI.html  | 3490 ---------
 .../data_location_cache_transactions.html       | 3217 --------
 .../how_cache_transactions_work.html            | 3259 --------
 .../transactions/jca_adapter_example.html       | 3231 --------
 .../monitor_troubleshoot_transactions.html      | 3244 --------
 .../transactions/run_a_cache_transaction.html   | 3298 --------
 ...un_a_cache_transaction_with_external_db.html | 3235 --------
 .../transaction_coding_examples.html            | 3225 --------
 .../transaction_event_management.html           | 3233 --------
 .../transaction_jta_gemfire_example.html        | 3228 --------
 .../transactions/transaction_semantics.html     | 3239 --------
 .../transaction_suspend_resume_example.html     | 3218 --------
 .../transactional_and_nontransactional_ops.html | 3424 --------
 .../transactional_function_example.html         | 3252 --------
 .../transactions/transactions_overview.html     | 3247 --------
 .../transactions/turning_off_jta.html           | 3220 --------
 .../transactions/working_with_transactions.html | 3389 --------
 .../15_minute_quickstart_gfsh.html              | 3614 ---------
 .../guide/10/getting_started/book_intro.html    | 3222 --------
 .../10/getting_started/geode_overview.html      | 3222 --------
 .../installation/install_standalone.html        | 3282 --------
 .../guide/10/getting_started/product_intro.html | 3288 --------
 .../querying_quick_reference.html               | 3672 ---------
 .../10/getting_started/setup_classpath.html     | 3284 --------
 .../system_requirements/host_machine.html       | 3238 --------
 .../10/getting_started/uninstall_geode.html     | 3209 --------
 .../10/images/ClientServerAdvancedTopics-5.gif  |  Bin 10798 -> 0 bytes
 .../10/images/ClientServerAdvancedTopics-6.gif  |  Bin 12056 -> 0 bytes
 .../10/images/ClientServerAdvancedTopics-7.gif  |  Bin 5000 -> 0 bytes
 .../guide/10/images/ContinuousQuerying-1.gif    |  Bin 6955 -> 0 bytes
 .../guide/10/images/ContinuousQuerying-3.gif    |  Bin 9141 -> 0 bytes
 .../docs/guide/10/images/DataManagement-9.png   |  Bin 48188 -> 0 bytes
 .../docs/guide/10/images/DeltaPropagation-1.gif |  Bin 7593 -> 0 bytes
 .../docs/guide/10/images/DeltaPropagation-3.gif |  Bin 6843 -> 0 bytes
 .../content/docs/guide/10/images/Events-2.gif   |  Bin 8793 -> 0 bytes
 .../content/docs/guide/10/images/Events-3.gif   |  Bin 6432 -> 0 bytes
 .../docs/guide/10/images/FuncExecOnMembers.png  |  Bin 64959 -> 0 bytes
 .../10/images/FuncExecOnRegionHAWithFilter.png  |  Bin 80141 -> 0 bytes
 .../10/images/FuncExecOnRegionNoMetadata.png    |  Bin 70177 -> 0 bytes
 .../images/FuncExecOnRegionPeersWithFilter.png  |  Bin 86576 -> 0 bytes
 .../10/images/FuncExecOnRegionWithFilter.png    |  Bin 60773 -> 0 bytes
 .../10/images/FuncExecOnRegionWithMetadata.png  |  Bin 59576 -> 0 bytes
 .../docs/guide/10/images/FuncExecOnServers.png  |  Bin 57470 -> 0 bytes
 .../content/docs/guide/10/images/Gemcached.png  |  Bin 87366 -> 0 bytes
 .../content/docs/guide/10/images/JConsole.png   |  Bin 64272 -> 0 bytes
 .../docs/guide/10/images/MultiSite-4.gif        |  Bin 4991 -> 0 bytes
 .../images/MultisiteConcurrency_WAN_Gateway.png |  Bin 103701 -> 0 bytes
 .../guide/10/images/SQLite_Persistence_Mgr.png  |  Bin 58388 -> 0 bytes
 .../10/images/Statistics-implementation.png     |  Bin 28057 -> 0 bytes
 .../guide/10/images/Statistics-interfaces.png   |  Bin 28312 -> 0 bytes
 .../docs/guide/10/images/Transaction-simple.png |  Bin 119831 -> 0 bytes
 .../guide/10/images/consistent_multisite.png    |  Bin 39442 -> 0 bytes
 .../docs/guide/10/images/diskStores-1.gif       |  Bin 7292 -> 0 bytes
 .../docs/guide/10/images/diskStores-3.gif       |  Bin 5898 -> 0 bytes
 .../docs/guide/10/images/jconsole_mbeans.png    |  Bin 211394 -> 0 bytes
 .../content/docs/guide/10/images/jvisualvm.png  |  Bin 90153 -> 0 bytes
 .../content/docs/guide/10/images/logging-1.gif  |  Bin 2778 -> 0 bytes
 .../docs/guide/10/images/member_view_list.png   |  Bin 107811 -> 0 bytes
 .../10/images/multisite-topology-avoid-3.png    |  Bin 9794 -> 0 bytes
 .../10/images/multisite-topology-hybrid-1.png   |  Bin 7627 -> 0 bytes
 .../10/images/multisite-topology-hybrid-2.png   |  Bin 7631 -> 0 bytes
 .../10/images/multisite-topology-parallel.png   |  Bin 7838 -> 0 bytes
 .../10/images/multisite-topology-serial.png     |  Bin 6886 -> 0 bytes
 .../docs/guide/10/images/parallel_sender.png    |  Bin 36089 -> 0 bytes
 .../docs/guide/10/images/pulse-data-browser.png |  Bin 99987 -> 0 bytes
 .../guide/10/images/pulse-region-detail.png     |  Bin 61149 -> 0 bytes
 .../guide/10/images/pulse_alerts_widget.png     |  Bin 137883 -> 0 bytes
 .../docs/guide/10/images/pulse_cluster_view.png |  Bin 154531 -> 0 bytes
 .../docs/guide/10/images/pulse_data_view.png    |  Bin 138140 -> 0 bytes
 .../docs/guide/10/images/pulse_locator.png      |  Bin 228513 -> 0 bytes
 .../docs/guide/10/images/pulse_member_view.png  |  Bin 132309 -> 0 bytes
 .../10/images/rest_example_java_packages.png    |  Bin 30206 -> 0 bytes
 .../content/docs/guide/10/images/security-1.gif |  Bin 8343 -> 0 bytes
 .../content/docs/guide/10/images/security-3.gif |  Bin 8287 -> 0 bytes
 .../content/docs/guide/10/images/security-4.gif |  Bin 7028 -> 0 bytes
 .../content/docs/guide/10/images/security-5.gif |  Bin 7408 -> 0 bytes
 .../docs/guide/10/images/serial_sender.png      |  Bin 32385 -> 0 bytes
 .../docs/guide/10/images/swagger_home.png       |  Bin 187378 -> 0 bytes
 .../guide/10/images/swagger_post_region.png     |  Bin 170963 -> 0 bytes
 .../10/images/swagger_post_region_response.png  |  Bin 176783 -> 0 bytes
 .../content/docs/guide/10/images/swagger_v1.png |  Bin 149806 -> 0 bytes
 .../guide/10/images/swagger_v1_response.png     |  Bin 143134 -> 0 bytes
 .../guide/10/images/transactions-client-1.png   |  Bin 113816 -> 0 bytes
 .../10/images/transactions_jca_adapter.png      |  Bin 104775 -> 0 bytes
 .../docs/guide/10/images/transactions_jta.png   |  Bin 104780 -> 0 bytes
 .../10/images/transactions_jta_app_server.png   |  Bin 91885 -> 0 bytes
 .../guide/10/images_svg/JMX_Architecture.svg    |    3 -
 .../content/docs/guide/10/images_svg/MBeans.svg |    3 -
 .../async_system_queue_conflation.svg           |    3 -
 .../guide/10/images_svg/cache_data_loader.svg   |    3 -
 .../guide/10/images_svg/cache_data_loader_2.svg |    3 -
 .../10/images_svg/client_server_deployment.svg  |    3 -
 .../10/images_svg/client_server_event_dist.svg  |    3 -
 .../client_server_message_tracking.svg          |    3 -
 .../10/images_svg/cluster-group-config.svg      |    3 -
 .../10/images_svg/cluster_config_overview.svg   |    3 -
 .../colocated_partitioned_regions.svg           |    3 -
 .../guide/10/images_svg/cs_connection_pool.svg  |    3 -
 .../10/images_svg/cs_locator_discovery.svg      |    3 -
 .../guide/10/images_svg/cs_subscriptions.svg    |    3 -
 .../docs/guide/10/images_svg/cs_topology.svg    |    3 -
 .../guide/10/images_svg/custom_partitioned.svg  |    3 -
 .../guide/10/images_svg/developing_overflow.svg |    3 -
 .../10/images_svg/developing_persistence.svg    |    3 -
 .../developing_persistence_and_overflow.svg     |    3 -
 .../guide/10/images_svg/distributed_how_1.svg   |    3 -
 .../guide/10/images_svg/distributed_how_2.svg   |    3 -
 .../guide/10/images_svg/distributed_how_3.svg   |    3 -
 .../guide/10/images_svg/distributed_preload.svg |    3 -
 .../guide/10/images_svg/distributed_replica.svg |    3 -
 .../images_svg/distributed_replica_preload.svg  |    3 -
 .../docs/guide/10/images_svg/expiration.svg     |    3 -
 .../10/images_svg/how_partitioning_works_1.svg  |    3 -
 .../10/images_svg/how_partitioning_works_2.svg  |    3 -
 .../images_svg/http_module_cs_with_locator.svg  |    3 -
 .../images_svg/http_module_p2p_with_locator.svg |    3 -
 .../guide/10/images_svg/locator_discovery.svg   |    3 -
 .../guide/10/images_svg/member_severe_alert.svg |    3 -
 .../images_svg/network_partition_scenario.svg   |    3 -
 .../docs/guide/10/images_svg/p2p_topology.svg   |    3 -
 .../guide/10/images_svg/partitioned_data_HA.svg |    3 -
 .../images_svg/partitioned_data_buckets_1.svg   |    3 -
 .../images_svg/partitioned_data_buckets_2.svg   |    3 -
 .../10/images_svg/region_entry_versions_1.svg   |    3 -
 .../10/images_svg/region_entry_versions_2.svg   |    3 -
 .../10/images_svg/region_entry_versions_3.svg   |    3 -
 .../10/images_svg/server_client_event_dist.svg  |    3 -
 .../guide/10/images_svg/server_discovery.svg    |    3 -
 .../guide/10/images_svg/server_grouping.svg     |    3 -
 .../images_svg/transactions_partitioned_1.svg   |    3 -
 .../images_svg/transactions_partitioned_2.svg   |    3 -
 .../10/images_svg/transactions_replicate_1.svg  |    3 -
 .../10/images_svg/transactions_replicate_2.svg  |    3 -
 .../10/images_svg/transactions_replicate_3.svg  |    3 -
 .../10/images_svg/transactions_replicate_4.svg  |    3 -
 .../transactions_replicate_local_1.svg          |    3 -
 .../transactions_replicate_no_ack_1.svg         |    3 -
 .../transactions_replicate_no_ack_2.svg         |    3 -
 .../10/images_svg/tune_cs_event_messaging.svg   |    3 -
 .../unbalanced_network_capacity_probs.svg       |    3 -
 .../autoreconnect/member-reconnect.html         | 3262 --------
 .../docs/guide/10/managing/book_intro.html      | 3244 --------
 .../cache_snapshots/chapter_overview.html       | 3232 --------
 .../cache_snapshots/exporting_a_snapshot.html   | 3247 --------
 .../filtering_snapshot_entries.html             | 3226 --------
 .../cache_snapshots/importing_a_snapshot.html   | 3256 --------
 .../read_snapshots_programmatically.html        | 3223 --------
 .../using_cache_and_region_snapshots.html       | 3226 --------
 .../disk_storage/backup_restore_disk_store.html | 3366 --------
 .../managing/disk_storage/chapter_overview.html | 3234 --------
 .../disk_storage/compacting_disk_stores.html    | 3316 --------
 .../disk_free_space_monitoring.html             | 3238 --------
 .../disk_store_configuration_params.html        | 3317 --------
 .../disk_storage/file_names_and_extensions.html | 3343 --------
 .../handling_missing_disk_stores.html           | 3255 --------
 .../disk_storage/how_disk_stores_work.html      | 3250 --------
 .../keeping_offline_disk_store_in_sync.html     | 3244 --------
 .../managing_disk_buffer_flushes.html           | 3223 --------
 .../disk_storage/managing_disk_stores.html      | 3221 --------
 .../disk_storage/managing_disk_stores_cmds.html | 3283 --------
 .../managing/disk_storage/operation_logs.html   | 3245 --------
 .../optimize_availability_and_performance.html  | 3217 --------
 .../overview_using_disk_stores.html             | 3219 --------
 .../starting_system_with_disk_stores.html       | 3316 --------
 .../disk_storage/using_disk_stores.html         | 3381 --------
 .../using_the_default_disk_store.html           | 3245 --------
 .../disk_storage/validating_disk_store.html     | 3219 --------
 .../10/managing/heap_use/heap_management.html   | 3408 --------
 .../guide/10/managing/heap_use/lock_memory.html | 3227 --------
 .../managing/heap_use/off_heap_management.html  | 3385 --------
 .../10/managing/logging/configuring_log4j2.html | 3249 --------
 .../10/managing/logging/how_logging_works.html  | 3222 --------
 .../docs/guide/10/managing/logging/logging.html | 3225 --------
 .../10/managing/logging/logging_categories.html | 3401 --------
 .../10/managing/logging/logging_whats_next.html | 3234 --------
 .../10/managing/logging/setting_up_logging.html | 3251 --------
 .../management/configuring_rmi_connector.html   | 3219 --------
 .../management/gfsh_and_management_api.html     | 3243 --------
 .../managing/management/jmx_manager_node.html   | 3220 --------
 .../management/jmx_manager_operations.html      | 3379 --------
 .../management/list_of_mbean_notifications.html | 3392 --------
 .../10/managing/management/list_of_mbeans.html  | 3222 --------
 .../management/list_of_mbeans_full.html         | 3603 ---------
 .../management/management_and_monitoring.html   | 3231 --------
 .../management_and_monitoring_features.html     | 3229 --------
 .../management/management_system_overview.html  | 3303 --------
 .../managing/management/mbean_architecture.html | 3255 --------
 .../management/mbean_notifications.html         | 3218 --------
 .../10/managing/management/mbeans_jconsole.html | 3228 --------
 .../10/managing/management/mm_overview.html     | 3281 --------
 .../notification_federation_and_alerts.html     | 3240 --------
 .../management/programming_example.html         | 3414 --------
 .../monitor_tune/cache_consistency.html         | 3267 --------
 .../managing/monitor_tune/chapter_overview.html | 3237 --------
 .../monitor_tune/multicast_communication.html   | 3227 --------
 ..._communication_configuring_speed_limits.html | 3228 --------
 ...st_communication_provisioning_bandwidth.html | 3243 --------
 ...st_communication_runtime_considerations.html | 3227 --------
 ...nication_testing_multicast_speed_limits.html | 3323 --------
 ...multicast_communication_troubleshooting.html | 3221 --------
 .../monitor_tune/performance_controls.html      | 3227 --------
 ...ormance_controls_controlling_socket_use.html | 3233 --------
 ...performance_controls_data_serialization.html | 3209 --------
 ...formance_controls_increasing_cache_hits.html | 3211 --------
 ...rmance_controls_managing_slow_receivers.html | 3255 --------
 ...ormance_controls_setting_cache_timeouts.html | 3220 --------
 .../monitor_tune/performance_on_vsphere.html    | 3329 --------
 .../10/managing/monitor_tune/slow_messages.html | 3228 --------
 .../managing/monitor_tune/slow_receivers.html   | 3218 --------
 .../monitor_tune/slow_receivers_managing.html   | 3303 --------
 .../slow_receivers_preventing_problems.html     | 3228 --------
 .../monitor_tune/socket_communication.html      | 3229 --------
 ...communication_ephemeral_tcp_port_limits.html | 3234 --------
 ...ocket_communication_have_enough_sockets.html | 3379 --------
 ...mmunication_setting_socket_buffer_sizes.html | 3321 --------
 ...munication_tcpip_p2p_handshake_timeouts.html | 3215 --------
 .../monitor_tune/socket_tcp_keepalive.html      | 3214 --------
 .../monitor_tune/sockets_and_gateways.html      | 3307 --------
 .../monitor_tune/system_member_performance.html | 3224 --------
 ..._performance_connection_thread_settings.html | 3212 --------
 ...r_performance_distributed_system_member.html | 3213 --------
 .../system_member_performance_garbage.html      | 3232 --------
 ...tem_member_performance_jvm_mem_settings.html | 3238 --------
 .../monitor_tune/udp_communication.html         | 3237 --------
 .../network_partitioning/chapter_overview.html  | 3228 --------
 .../network_partitioning/failure_detection.html | 3248 --------
 .../handling_network_partitioning.html          | 3241 --------
 ...w_network_partitioning_management_works.html | 3246 --------
 ...coordinators_lead_members_and_weighting.html | 3270 --------
 .../network_partitioning_scenarios.html         | 3235 --------
 .../preventing_network_partitions.html          | 3215 --------
 .../region_compression/region_compression.html  | 3390 --------
 .../security/authentication_examples.html       | 3252 --------
 .../security/authentication_overview.html       | 3225 --------
 .../security/authorization_example.html         | 3252 --------
 .../security/authorization_overview.html        | 3218 --------
 .../10/managing/security/chapter_overview.html  | 3227 --------
 .../10/managing/security/enable_security.html   | 3253 --------
 .../managing/security/encrypting_passwords.html | 3223 --------
 .../security/encrypting_with_diffie_helman.html | 3261 --------
 .../security/implementing_authentication.html   | 3348 --------
 .../security/implementing_authorization.html    | 3909 ----------
 .../security/implementing_security.html         | 3265 --------
 .../10/managing/security/implementing_ssl.html  | 3472 ---------
 .../10/managing/security/post_processing.html   | 3258 --------
 .../10/managing/security/properties_file.html   | 3219 --------
 .../10/managing/security/security-audit.html    | 3253 --------
 .../security/security_audit_overview.html       | 3222 --------
 .../10/managing/security/security_intro.html    | 3224 --------
 .../guide/10/managing/security/ssl_example.html | 3271 --------
 .../10/managing/security/ssl_overview.html      | 3231 --------
 .../application_defined_statistics.html         | 3248 --------
 .../managing/statistics/chapter_overview.html   | 3223 --------
 .../statistics/how_statistics_work.html         | 3217 --------
 .../statistics/setting_up_statistics.html       | 3312 --------
 .../transient_region_and_entry_statistics.html  | 3227 --------
 .../managing/statistics/viewing_statistics.html | 3207 --------
 .../troubleshooting/chapter_overview.html       | 3237 --------
 .../diagnosing_system_probs.html                | 3616 ---------
 .../prevent_and_recover_disk_full_errors.html   | 3232 --------
 .../producing_troubleshooting_artifacts.html    | 3262 --------
 .../recovering_conflicting_data_exceptions.html | 3254 --------
 .../recovering_from_app_crashes.html            | 3216 --------
 .../recovering_from_cs_crashes.html             | 3243 --------
 .../recovering_from_machine_crashes.html        | 3248 --------
 .../recovering_from_network_outages.html        | 3253 --------
 .../recovering_from_p2p_crashes.html            | 3382 --------
 .../system_failure_and_recovery.html            | 3427 --------
 .../docs/guide/10/prereq_and_install.html       | 3222 --------
 .../docs/guide/10/reference/book_intro.html     | 3228 --------
 .../reference/statistics/statistics_list.html   | 7325 ------------------
 .../reference/topics/cache-elements-list.html   | 3365 --------
 .../guide/10/reference/topics/cache_xml.html    | 6328 ---------------
 .../topics/chapter_overview_cache_xml.html      | 3228 --------
 .../chapter_overview_regionshortcuts.html       | 3260 --------
 .../topics/client-cache-elements-list.html      | 3319 --------
 .../guide/10/reference/topics/client-cache.html | 5869 --------------
 .../guide/10/reference/topics/elements_ref.html | 3303 --------
 .../10/reference/topics/gemfire_properties.html | 3841 ---------
 .../10/reference/topics/gfe_cache_xml.html      | 6621 ----------------
 .../guide/10/reference/topics/glossary.html     | 3801 ---------
 .../handling_exceptions_and_failures.html       | 3217 --------
 .../memory_requirements_for_cache_data.html     | 3530 ---------
 .../non-ascii_strings_in_config_files.html      | 3220 --------
 .../topics/region_shortcuts_reference.html      | 4802 ------------
 .../topics/region_shortcuts_table.html          | 3703 ---------
 .../docs/guide/10/rest_apps/book_intro.html     | 3237 --------
 .../guide/10/rest_apps/chapter_overview.html    | 3215 --------
 .../guide/10/rest_apps/delete_all_data.html     | 3241 --------
 .../guide/10/rest_apps/delete_data_for_key.html | 3241 --------
 .../delete_data_for_multiple_keys.html          | 3241 --------
 .../guide/10/rest_apps/delete_named_query.html  | 3263 --------
 .../guide/10/rest_apps/develop_rest_apps.html   | 3743 ---------
 .../10/rest_apps/get_execute_adhoc_query.html   | 3306 --------
 .../docs/guide/10/rest_apps/get_functions.html  | 3252 --------
 .../docs/guide/10/rest_apps/get_queries.html    | 3269 --------
 .../guide/10/rest_apps/get_region_data.html     | 3322 --------
 .../get_region_data_for_multiple_keys.html      | 3422 --------
 .../guide/10/rest_apps/get_region_key_data.html | 3277 --------
 .../guide/10/rest_apps/get_region_keys.html     | 3255 --------
 .../docs/guide/10/rest_apps/get_regions.html    | 3280 --------
 .../docs/guide/10/rest_apps/get_servers.html    | 3246 --------
 .../guide/10/rest_apps/head_region_size.html    | 3250 --------
 .../docs/guide/10/rest_apps/ping_service.html   | 3239 --------
 .../guide/10/rest_apps/post_create_query.html   | 3292 --------
 .../10/rest_apps/post_execute_functions.html    | 3309 --------
 .../guide/10/rest_apps/post_execute_query.html  | 3358 --------
 .../guide/10/rest_apps/post_if_absent_data.html | 3334 --------
 .../rest_apps/put_multiple_values_for_keys.html | 3293 --------
 .../guide/10/rest_apps/put_replace_data.html    | 3287 --------
 .../guide/10/rest_apps/put_update_cas_data.html | 3405 --------
 .../guide/10/rest_apps/put_update_data.html     | 3272 --------
 .../guide/10/rest_apps/put_update_query.html    | 3285 --------
 .../docs/guide/10/rest_apps/rest_admin.html     | 3216 --------
 .../guide/10/rest_apps/rest_api_reference.html  | 3225 --------
 .../docs/guide/10/rest_apps/rest_examples.html  | 3870 ---------
 .../docs/guide/10/rest_apps/rest_functions.html | 3216 --------
 .../docs/guide/10/rest_apps/rest_prereqs.html   | 3225 --------
 .../docs/guide/10/rest_apps/rest_queries.html   | 3228 --------
 .../docs/guide/10/rest_apps/rest_regions.html   | 3254 --------
 .../docs/guide/10/rest_apps/setup_config.html   | 3330 --------
 .../guide/10/rest_apps/troubleshooting.html     | 3328 --------
 .../docs/guide/10/rest_apps/using_swagger.html  | 3242 --------
 .../docs/guide/10/tools_modules/book_intro.html | 3230 --------
 .../gemcached/about_gemcached.html              | 3232 --------
 .../10/tools_modules/gemcached/advantages.html  | 3219 --------
 .../gemcached/chapter_overview.html             | 3223 --------
 .../gemcached/deploying_gemcached.html          | 3274 --------
 .../guide/10/tools_modules/gfsh/about_gfsh.html | 3227 --------
 .../10/tools_modules/gfsh/cache_xml_2_gfsh.html | 3288 --------
 .../10/tools_modules/gfsh/chapter_overview.html | 3241 --------
 .../tools_modules/gfsh/command-pages/alter.html | 3682 ---------
 .../gfsh/command-pages/backup.html              | 3261 --------
 .../gfsh/command-pages/change.html              | 3275 --------
 .../tools_modules/gfsh/command-pages/clear.html | 3224 --------
 .../tools_modules/gfsh/command-pages/close.html | 3332 --------
 .../gfsh/command-pages/compact.html             | 3316 --------
 .../gfsh/command-pages/configure.html           | 3281 --------
 .../gfsh/command-pages/connect.html             | 3347 --------
 .../gfsh/command-pages/create.html              | 4114 ----------
 .../tools_modules/gfsh/command-pages/debug.html | 3238 --------
 .../gfsh/command-pages/define.html              | 3264 --------
 .../gfsh/command-pages/deploy.html              | 3266 --------
 .../gfsh/command-pages/describe.html            | 3593 ---------
 .../gfsh/command-pages/destroy.html             | 3380 --------
 .../gfsh/command-pages/disconnect.html          | 3224 --------
 .../tools_modules/gfsh/command-pages/echo.html  | 3245 --------
 .../gfsh/command-pages/encrypt.html             | 3239 --------
 .../gfsh/command-pages/execute.html             | 3262 --------
 .../tools_modules/gfsh/command-pages/exit.html  | 3217 --------
 .../gfsh/command-pages/export.html              | 3510 ---------
 .../10/tools_modules/gfsh/command-pages/gc.html | 3243 --------
 .../tools_modules/gfsh/command-pages/get.html   | 3267 --------
 .../tools_modules/gfsh/command-pages/help.html  | 3251 --------
 .../tools_modules/gfsh/command-pages/hint.html  | 3252 --------
 .../gfsh/command-pages/history.html             | 3247 --------
 .../gfsh/command-pages/import.html              | 3291 --------
 .../tools_modules/gfsh/command-pages/list.html  | 3631 ---------
 .../gfsh/command-pages/load-balance.html        | 3246 --------
 .../gfsh/command-pages/locate.html              | 3272 --------
 .../gfsh/command-pages/netstat.html             | 3335 --------
 .../tools_modules/gfsh/command-pages/pause.html | 3242 --------
 .../tools_modules/gfsh/command-pages/pdx.html   | 3269 --------
 .../tools_modules/gfsh/command-pages/put.html   | 3279 --------
 .../tools_modules/gfsh/command-pages/query.html | 3257 --------
 .../gfsh/command-pages/rebalance.html           | 3269 --------
 .../gfsh/command-pages/remove.html              | 3259 --------
 .../gfsh/command-pages/resume.html              | 3242 --------
 .../gfsh/command-pages/revoke.html              | 3244 --------
 .../tools_modules/gfsh/command-pages/run.html   | 3279 --------
 .../tools_modules/gfsh/command-pages/set.html   | 3252 --------
 .../10/tools_modules/gfsh/command-pages/sh.html | 3250 --------
 .../tools_modules/gfsh/command-pages/show.html  | 3478 ---------
 .../gfsh/command-pages/shutdown.html            | 3250 --------
 .../tools_modules/gfsh/command-pages/sleep.html | 3241 --------
 .../tools_modules/gfsh/command-pages/start.html | 3999 ----------
 .../gfsh/command-pages/status.html              | 3507 ---------
 .../tools_modules/gfsh/command-pages/stop.html  | 3434 --------
 .../gfsh/command-pages/undeploy.html            | 3262 --------
 .../gfsh/command-pages/validate.html            | 3236 --------
 .../gfsh/command-pages/version.html             | 3246 --------
 .../tools_modules/gfsh/command_scripting.html   | 3217 --------
 .../10/tools_modules/gfsh/configuring_gfsh.html | 3310 --------
 .../gfsh/getting_started_gfsh.html              | 3314 --------
 .../tools_modules/gfsh/gfsh_command_index.html  | 3360 --------
 .../gfsh/gfsh_quick_reference.html              | 3229 --------
 .../gfsh/os_command_line_execution.html         | 3224 --------
 .../gfsh/quick_ref_commands_by_area.html        | 3971 ----------
 .../10/tools_modules/gfsh/starting_gfsh.html    | 3243 --------
 .../10/tools_modules/gfsh/tour_of_gfsh.html     | 3543 ---------
 .../gfsh/useful_gfsh_shell_variables.html       | 3310 --------
 .../http_session_mgmt/chapter_overview.html     | 3238 --------
 .../common_gemfire_topologies.html              | 3221 --------
 .../http_session_mgmt/http_why_use_gemfire.html | 3241 --------
 .../http_session_mgmt/interactive_mode_ref.html | 3283 --------
 .../http_session_mgmt/quick_start.html          | 3322 --------
 .../session_mgmt_tcserver.html                  | 3221 --------
 .../http_session_mgmt/session_mgmt_tomcat.html  | 3221 --------
 .../session_mgmt_weblogic.html                  | 3218 --------
 .../session_state_log_files.html                | 3278 --------
 .../http_session_mgmt/tc_additional_info.html   | 3239 --------
 .../tc_changing_gf_default_cfg.html             | 3270 --------
 .../tc_installing_the_module.html               | 3213 --------
 .../tc_setting_up_the_module.html               | 3308 --------
 .../tomcat_changing_gf_default_cfg.html         | 3372 --------
 .../tomcat_installing_the_module.html           | 3225 --------
 .../tomcat_setting_up_the_module.html           | 3286 --------
 .../weblogic_changing_gf_default_cfg.html       | 3394 --------
 .../weblogic_common_configuration_changes.html  | 3226 --------
 .../weblogic_setting_up_the_module.html         | 3385 --------
 .../10/tools_modules/lucene_integration.html    | 3312 --------
 .../tools_modules/pulse/chapter_overview.html   | 3229 --------
 .../10/tools_modules/pulse/quickstart.html      | 3977 ----------
 .../pulse/system_requirements.html              | 3220 --------
 .../guide/10/tools_modules/redis_adapter.html   | 3281 --------
 .../10/topologies_and_comm/book_intro.html      | 3224 --------
 .../cs_configuration/chapter_overview.html      | 3231 --------
 .../client_server_example_configurations.html   | 3321 --------
 .../client_server_whats_next.html               | 3240 --------
 .../configure_servers_into_logical_groups.html  | 3231 --------
 .../setting_up_a_client_server_system.html      | 3260 --------
 .../standard_client_server_deployment.html      | 3220 --------
 .../chapter_overview.html                       | 3225 --------
 .../multisite_topologies.html                   | 3294 --------
 .../setting_up_a_multisite_system.html          | 3513 ---------
 .../p2p_configuration/chapter_overview.html     | 3219 --------
 .../configuring_peer_member_groups.html         | 3234 --------
 .../setting_up_a_p2p_system.html                | 3219 --------
 .../setting_up_peer_communication.html          | 3239 --------
 .../topology_concepts/IPv4_and_IPv6.html        | 3231 --------
 .../topology_concepts/chapter_overview.html     | 3228 --------
 .../how_communication_works.html                | 3244 --------
 .../how_member_discovery_works.html             | 3247 --------
 .../how_multisite_systems_work.html             | 3225 --------
 .../how_server_discovery_works.html             | 3247 --------
 .../how_the_pool_manages_connections.html       | 3275 --------
 .../topology_concepts/member_communication.html | 3237 --------
 .../topology_concepts/multisite_overview.html   | 3300 --------
 .../topology_concepts/topology_types.html       | 3237 --------
 .../topology_concepts/using_bind_addresses.html | 3357 --------
 geode-site/website/content/docs/index.html      |   57 -
 geode-site/website/content/favicon.ico          |  Bin 20805 -> 0 bytes
 geode-site/website/content/font/FontAwesome.otf |  Bin 124988 -> 0 bytes
 .../content/font/fontawesome-webfont-eot.eot    |  Bin 76518 -> 0 bytes
 .../content/font/fontawesome-webfont-svg.svg    |  685 --
 .../content/font/fontawesome-webfont-ttf.ttf    |  Bin 152796 -> 0 bytes
 .../content/font/fontawesome-webfont-woff.woff  |  Bin 90412 -> 0 bytes
 .../content/font/fontawesome-webfont.woff2      |  Bin 71896 -> 0 bytes
 .../fonts/font-awesome/fontawesome-webfont.eot  |  Bin 76204 -> 0 bytes
 .../fonts/font-awesome/fontawesome-webfont.svg  |  685 --
 .../fonts/font-awesome/fontawesome-webfont.ttf  |  Bin 152364 -> 0 bytes
 .../fonts/font-awesome/fontawesome-webfont.woff |  Bin 90144 -> 0 bytes
 .../font-awesome/fontawesome-webfont.woff2      |  Bin 71760 -> 0 bytes
 geode-site/website/content/images/favicon.ico   |  Bin 1317 -> 0 bytes
 .../website/content/img/apache_geode_logo.png   |  Bin 23616 -> 0 bytes
 .../content/img/apache_geode_logo_white.png     |  Bin 22695 -> 0 bytes
 .../img/apache_geode_logo_white_small.png       |  Bin 52948 -> 0 bytes
 geode-site/website/content/img/asf_logo.png     |  Bin 152842 -> 0 bytes
 .../website/content/img/check_flat/default.png  |  Bin 25851 -> 0 bytes
 geode-site/website/content/img/github.png       |  Bin 8936 -> 0 bytes
 geode-site/website/content/index.html           |  171 -
 geode-site/website/content/javascripts/all.js   | 1085 ---
 geode-site/website/content/javascripts/book.js  |  953 ---
 .../website/content/javascripts/bookbinder.js   |  145 -
 .../content/javascripts/waypoints/context.js    |  316 -
 .../content/javascripts/waypoints/group.js      |  121 -
 .../javascripts/waypoints/noframeworkAdapter.js |  229 -
 .../content/javascripts/waypoints/sticky.js     |   79 -
 .../content/javascripts/waypoints/waypoint.js   |  176 -
 geode-site/website/content/js/bootstrap.min.js  |    8 -
 geode-site/website/content/js/head.js           |  708 --
 geode-site/website/content/js/html5shiv.js      |    8 -
 .../website/content/js/jquery-1.10.1.min.js     |    6 -
 geode-site/website/content/js/jquery.icheck.js  |  397 -
 geode-site/website/content/js/respond.min.js    |    6 -
 geode-site/website/content/js/usergrid-site.js  |   66 -
 geode-site/website/content/releases/index.html  |  135 -
 .../website/content/schema/cache/cache-1.0.xsd  | 1469 ----
 .../website/content/schema/cache/lucene-1.0.xsd |   58 -
 geode-site/website/content/stylesheets/all.css  | 1590 ----
 geode-site/website/content/stylesheets/base     | 1869 -----
 .../website/content/stylesheets/book-styles     |    3 -
 .../website/content/stylesheets/layout-styles   |    0
 .../content/stylesheets/print-book-styles       |    0
 .../content/stylesheets/print-layout-styles     |    0
 .../website/content/stylesheets/print.css       |   38 -
 geode-site/website/content/subnavs/geode-subnav | 3052 --------
 geode-site/website/layouts/community.html       |    1 -
 geode-site/website/layouts/default.html         |   12 -
 geode-site/website/layouts/docs.html            |    1 -
 geode-site/website/layouts/footer.html          |   81 -
 geode-site/website/layouts/header.html          |  260 -
 geode-site/website/layouts/releases.html        |    1 -
 geode-site/website/lib/default.rb               |   60 -
 geode-site/website/lib/helpers_.rb              |   16 -
 geode-site/website/lib/pandoc.template          |    4 -
 geode-site/website/nanoc.yaml                   |   96 -
 geode-site/website/run.sh                       |   18 -
 geode-site/website/utilities/map-markers.rb     |   75 -
 geode-site/website/utilities/markers.txt        |  440 --
 geode-site/website/utilities/snapshot-apigee.rb |   88 -
 .../cache/wan/Simple2CacheServerDUnitTest.java  |    2 +-
 .../geode/internal/cache/wan/WANTestBase.java   |   97 +-
 ...oncurrentParallelGatewaySenderDUnitTest.java |    2 +-
 ...allelGatewaySenderOperation_2_DUnitTest.java |    2 +-
 .../wan/misc/NewWanAuthenticationDUnitTest.java |    2 +-
 ...llelGatewaySenderQueueOverflowDUnitTest.java |    2 +-
 .../wan/parallel/ParallelWANStatsDUnitTest.java |    2 +-
 ...rialGatewaySenderEventListenerDUnitTest.java |    2 +-
 .../SerialGatewaySenderQueueDUnitTest.java      |    2 +-
 .../serial/SerialWANConflationDUnitTest.java    |    2 +-
 .../wan/serial/SerialWANStatsDUnitTest.java     |    2 +-
 .../management/WANManagementDUnitTest.java      |    2 +-
 geode-web-api/build.gradle                      |    7 +-
 .../web/controllers/AbstractBaseController.java |   14 +-
 .../controllers/FunctionAccessController.java   |   13 +-
 .../security/GeodeAuthenticationProvider.java   |   13 +-
 geode-web-api/src/main/webapp/META-INF/NOTICE   |   10 +-
 .../AbstractBaseControllerJUnitTest.java        |   80 +
 geode-web/src/main/webapp/META-INF/NOTICE       |    6 +-
 .../commands/QueryNamesOverHttpDUnitTest.java   |   25 +-
 gradle.properties                               |    2 +-
 gradle/dependency-versions.properties           |  114 +-
 gradle/rat.gradle                               |   22 -
 gradle/test.gradle                              |    3 +-
 settings.gradle                                 |    2 +
 1268 files changed, 24201 insertions(+), 1815380 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d39f26c9/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------


[14/51] [abbrv] geode git commit: GEODE-2142: spotless

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/main/java/org/json/JSONTokener.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONTokener.java b/geode-json/src/main/java/org/json/JSONTokener.java
index 59eb4bc..21c9fb0 100755
--- a/geode-json/src/main/java/org/json/JSONTokener.java
+++ b/geode-json/src/main/java/org/json/JSONTokener.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -22,637 +20,620 @@ import java.io.IOException;
 import java.io.Reader;
 
 /**
- * Parses a JSON (<a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>)
- * encoded string into the corresponding object. Most clients of
- * this class will use only need the {@link #JSONTokener(String) constructor}
- * and {@link #nextValue} method. Example usage: <pre>
- * String json = "{"
- *         + "  \"query\": \"Pizza\", "
- *         + "  \"locations\": [ 94043, 90210 ] "
- *         + "}";
+ * Parses a JSON (<a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>) encoded string into
+ * the corresponding object. Most clients of this class will use only need the
+ * {@link #JSONTokener(String) constructor} and {@link #nextValue} method. Example usage:
+ * 
+ * <pre>
+ * String json = "{" + "  \"query\": \"Pizza\", " + "  \"locations\": [ 94043, 90210 ] " + "}";
  *
  * JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
  * String query = object.getString("query");
- * JSONArray locations = object.getJSONArray("locations");</pre>
+ * JSONArray locations = object.getJSONArray("locations");
+ * </pre>
  *
- * <p>For best interoperability and performance use JSON that complies with
- * RFC 4627, such as that generated by {@link JSONStringer}. For legacy reasons
- * this parser is lenient, so a successful parse does not indicate that the
- * input string was valid JSON. All of the following syntax errors will be
- * ignored:
+ * <p>
+ * For best interoperability and performance use JSON that complies with RFC 4627, such as that
+ * generated by {@link JSONStringer}. For legacy reasons this parser is lenient, so a successful
+ * parse does not indicate that the input string was valid JSON. All of the following syntax errors
+ * will be ignored:
  * <ul>
- * <li>End of line comments starting with {@code //} or {@code #} and ending
- * with a newline character.
- * <li>C-style comments starting with {@code /*} and ending with
- * {@code *}{@code /}. Such comments may not be nested.
+ * <li>End of line comments starting with {@code //} or {@code #} and ending with a newline
+ * character.
+ * <li>C-style comments starting with {@code /*} and ending with {@code *}{@code /}. Such comments
+ * may not be nested.
  * <li>Strings that are unquoted or {@code 'single quoted'}.
  * <li>Hexadecimal integers prefixed with {@code 0x} or {@code 0X}.
  * <li>Octal integers prefixed with {@code 0}.
  * <li>Array elements separated by {@code ;}.
- * <li>Unnecessary array separators. These are interpreted as if null was the
- * omitted value.
+ * <li>Unnecessary array separators. These are interpreted as if null was the omitted value.
  * <li>Key-value pairs separated by {@code =} or {@code =>}.
  * <li>Key-value pairs separated by {@code ;}.
  * </ul>
  *
- * <p>Each tokener may be used to parse a single JSON string. Instances of this
- * class are not thread safe. Although this class is nonfinal, it was not
- * designed for inheritance and should not be subclassed. In particular,
- * self-use by overrideable methods is not specified. See <i>Effective Java</i>
- * Item 17, "Design and Document or inheritance or else prohibit it" for further
+ * <p>
+ * Each tokener may be used to parse a single JSON string. Instances of this class are not thread
+ * safe. Although this class is nonfinal, it was not designed for inheritance and should not be
+ * subclassed. In particular, self-use by overrideable methods is not specified. See <i>Effective
+ * Java</i> Item 17, "Design and Document or inheritance or else prohibit it" for further
  * information.
  */
 public class JSONTokener {
 
-    /**
-     * The input JSON.
-     */
-    private final String in;
-
-    /**
-     * The index of the next character to be returned by {@link #next}. When
-     * the input is exhausted, this equals the input's length.
-     */
-    private int pos;
-
-    /**
-     * @param in JSON encoded string. Null is not permitted and will yield a
-     *           tokener that throws {@code NullPointerExceptions} when methods are
-     *           called.
-     */
-    public JSONTokener(String in) {
-        // consume an optional byte order mark (BOM) if it exists
-        if (in != null && in.startsWith("\ufeff")) {
-            in = in.substring(1);
-        }
-        this.in = in;
+  /**
+   * The input JSON.
+   */
+  private final String in;
+
+  /**
+   * The index of the next character to be returned by {@link #next}. When the input is exhausted,
+   * this equals the input's length.
+   */
+  private int pos;
+
+  /**
+   * @param in JSON encoded string. Null is not permitted and will yield a tokener that throws
+   *        {@code NullPointerExceptions} when methods are called.
+   */
+  public JSONTokener(String in) {
+    // consume an optional byte order mark (BOM) if it exists
+    if (in != null && in.startsWith("\ufeff")) {
+      in = in.substring(1);
     }
-
-    public JSONTokener(Reader input) throws IOException {
-        StringBuilder s = new StringBuilder();
-        char[] readBuf = new char[102400];
-        int n = input.read(readBuf);
-        while (n >= 0) {
-            s.append(readBuf, 0, n);
-            n = input.read(readBuf);
-        }
-        in = s.toString();
-        pos = 0;
+    this.in = in;
+  }
+
+  public JSONTokener(Reader input) throws IOException {
+    StringBuilder s = new StringBuilder();
+    char[] readBuf = new char[102400];
+    int n = input.read(readBuf);
+    while (n >= 0) {
+      s.append(readBuf, 0, n);
+      n = input.read(readBuf);
     }
-
-    /**
-     * Returns the next value from the input.
-     *
-     * @return a {@link JSONObject}, {@link JSONArray}, String, Boolean,
-     * Integer, Long, Double or {@link JSONObject#NULL}.
-     * @throws JSONException if the input is malformed.
-     */
-    public Object nextValue() throws JSONException {
-        int c = nextCleanInternal();
-        switch (c) {
-            case -1:
-                throw syntaxError("End of input");
-
-            case '{':
-                return readObject();
-
-            case '[':
-                return readArray();
-
-            case '\'':
-            case '"':
-                return nextString((char) c);
+    in = s.toString();
+    pos = 0;
+  }
+
+  /**
+   * Returns the next value from the input.
+   *
+   * @return a {@link JSONObject}, {@link JSONArray}, String, Boolean, Integer, Long, Double or
+   *         {@link JSONObject#NULL}.
+   * @throws JSONException if the input is malformed.
+   */
+  public Object nextValue() throws JSONException {
+    int c = nextCleanInternal();
+    switch (c) {
+      case -1:
+        throw syntaxError("End of input");
+
+      case '{':
+        return readObject();
+
+      case '[':
+        return readArray();
+
+      case '\'':
+      case '"':
+        return nextString((char) c);
+
+      default:
+        pos--;
+        return readLiteral();
+    }
+  }
+
+  private int nextCleanInternal() throws JSONException {
+    while (pos < in.length()) {
+      int c = in.charAt(pos++);
+      switch (c) {
+        case '\t':
+        case ' ':
+        case '\n':
+        case '\r':
+          continue;
+
+        case '/':
+          if (pos == in.length()) {
+            return c;
+          }
+
+          char peek = in.charAt(pos);
+          switch (peek) {
+            case '*':
+              // skip a /* c-style comment */
+              pos++;
+              int commentEnd = in.indexOf("*/", pos);
+              if (commentEnd == -1) {
+                throw syntaxError("Unterminated comment");
+              }
+              pos = commentEnd + 2;
+              continue;
+
+            case '/':
+              // skip a // end-of-line comment
+              pos++;
+              skipToEndOfLine();
+              continue;
 
             default:
-                pos--;
-                return readLiteral();
-        }
+              return c;
+          }
+
+        case '#':
+          /*
+           * Skip a # hash end-of-line comment. The JSON RFC doesn't specify this behavior, but it's
+           * required to parse existing documents. See http://b/2571423.
+           */
+          skipToEndOfLine();
+          continue;
+
+        default:
+          return c;
+      }
     }
 
-    private int nextCleanInternal() throws JSONException {
-        while (pos < in.length()) {
-            int c = in.charAt(pos++);
-            switch (c) {
-                case '\t':
-                case ' ':
-                case '\n':
-                case '\r':
-                    continue;
-
-                case '/':
-                    if (pos == in.length()) {
-                        return c;
-                    }
-
-                    char peek = in.charAt(pos);
-                    switch (peek) {
-                        case '*':
-                            // skip a /* c-style comment */
-                            pos++;
-                            int commentEnd = in.indexOf("*/", pos);
-                            if (commentEnd == -1) {
-                                throw syntaxError("Unterminated comment");
-                            }
-                            pos = commentEnd + 2;
-                            continue;
-
-                        case '/':
-                            // skip a // end-of-line comment
-                            pos++;
-                            skipToEndOfLine();
-                            continue;
-
-                        default:
-                            return c;
-                    }
-
-                case '#':
-                    /*
-                     * Skip a # hash end-of-line comment. The JSON RFC doesn't
-                     * specify this behavior, but it's required to parse
-                     * existing documents. See http://b/2571423.
-                     */
-                    skipToEndOfLine();
-                    continue;
-
-                default:
-                    return c;
-            }
-        }
-
-        return -1;
+    return -1;
+  }
+
+  /**
+   * Advances the position until after the next newline character. If the line is terminated by
+   * "\r\n", the '\n' must be consumed as whitespace by the caller.
+   */
+  private void skipToEndOfLine() {
+    for (; pos < in.length(); pos++) {
+      char c = in.charAt(pos);
+      if (c == '\r' || c == '\n') {
+        pos++;
+        break;
+      }
     }
-
-    /**
-     * Advances the position until after the next newline character. If the line
-     * is terminated by "\r\n", the '\n' must be consumed as whitespace by the
-     * caller.
+  }
+
+  /**
+   * Returns the string up to but not including {@code quote}, unescaping any character escape
+   * sequences encountered along the way. The opening quote should have already been read. This
+   * consumes the closing quote, but does not include it in the returned string.
+   *
+   * @param quote either ' or ".
+   * @return The unescaped string.
+   * @throws JSONException if the string isn't terminated by a closing quote correctly.
+   */
+  public String nextString(char quote) throws JSONException {
+    /*
+     * For strings that are free of escape sequences, we can just extract the result as a substring
+     * of the input. But if we encounter an escape sequence, we need to use a StringBuilder to
+     * compose the result.
      */
-    private void skipToEndOfLine() {
-        for (; pos < in.length(); pos++) {
-            char c = in.charAt(pos);
-            if (c == '\r' || c == '\n') {
-                pos++;
-                break;
-            }
+    StringBuilder builder = null;
+
+    /* the index of the first character not yet appended to the builder. */
+    int start = pos;
+
+    while (pos < in.length()) {
+      int c = in.charAt(pos++);
+      if (c == quote) {
+        if (builder == null) {
+          // a new string avoids leaking memory
+          // noinspection RedundantStringConstructorCall
+          return new String(in.substring(start, pos - 1));
+        } else {
+          builder.append(in, start, pos - 1);
+          return builder.toString();
         }
-    }
+      }
 
-    /**
-     * Returns the string up to but not including {@code quote}, unescaping any
-     * character escape sequences encountered along the way. The opening quote
-     * should have already been read. This consumes the closing quote, but does
-     * not include it in the returned string.
-     *
-     * @param quote either ' or ".
-     * @return The unescaped string.
-     * @throws JSONException if the string isn't terminated by a closing quote correctly.
-     */
-    public String nextString(char quote) throws JSONException {
-        /*
-         * For strings that are free of escape sequences, we can just extract
-         * the result as a substring of the input. But if we encounter an escape
-         * sequence, we need to use a StringBuilder to compose the result.
-         */
-        StringBuilder builder = null;
-
-        /* the index of the first character not yet appended to the builder. */
-        int start = pos;
-
-        while (pos < in.length()) {
-            int c = in.charAt(pos++);
-            if (c == quote) {
-                if (builder == null) {
-                    // a new string avoids leaking memory
-                    //noinspection RedundantStringConstructorCall
-                    return new String(in.substring(start, pos - 1));
-                } else {
-                    builder.append(in, start, pos - 1);
-                    return builder.toString();
-                }
-            }
-
-            if (c == '\\') {
-                if (pos == in.length()) {
-                    throw syntaxError("Unterminated escape sequence");
-                }
-                if (builder == null) {
-                    builder = new StringBuilder();
-                }
-                builder.append(in, start, pos - 1);
-                builder.append(readEscapeCharacter());
-                start = pos;
-            }
+      if (c == '\\') {
+        if (pos == in.length()) {
+          throw syntaxError("Unterminated escape sequence");
         }
-
-        throw syntaxError("Unterminated string");
-    }
-
-    /**
-     * Unescapes the character identified by the character or characters that
-     * immediately follow a backslash. The backslash '\' should have already
-     * been read. This supports both unicode escapes "u000A" and two-character
-     * escapes "\n".
-     */
-    private char readEscapeCharacter() throws JSONException {
-        char escaped = in.charAt(pos++);
-        switch (escaped) {
-            case 'u':
-                if (pos + 4 > in.length()) {
-                    throw syntaxError("Unterminated escape sequence");
-                }
-                String hex = in.substring(pos, pos + 4);
-                pos += 4;
-                try {
-                    return (char) Integer.parseInt(hex, 16);
-                } catch (NumberFormatException nfe) {
-                    throw syntaxError("Invalid escape sequence: " + hex);
-                }
-
-            case 't':
-                return '\t';
-
-            case 'b':
-                return '\b';
-
-            case 'n':
-                return '\n';
-
-            case 'r':
-                return '\r';
-
-            case 'f':
-                return '\f';
-
-            case '\'':
-            case '"':
-            case '\\':
-            default:
-                return escaped;
+        if (builder == null) {
+          builder = new StringBuilder();
         }
+        builder.append(in, start, pos - 1);
+        builder.append(readEscapeCharacter());
+        start = pos;
+      }
     }
 
-    /**
-     * Reads a null, boolean, numeric or unquoted string literal value. Numeric
-     * values will be returned as an Integer, Long, or Double, in that order of
-     * preference.
-     */
-    private Object readLiteral() throws JSONException {
-        String literal = nextToInternal("{}[]/\\:,=;# \t\f");
-
-        if (literal.length() == 0) {
-            throw syntaxError("Expected literal value");
-        } else if ("null".equalsIgnoreCase(literal)) {
-            return JSONObject.NULL;
-        } else if ("true".equalsIgnoreCase(literal)) {
-            return Boolean.TRUE;
-        } else if ("false".equalsIgnoreCase(literal)) {
-            return Boolean.FALSE;
-        }
-
-        /* try to parse as an integral type... */
-        if (literal.indexOf('.') == -1) {
-            int base = 10;
-            String number = literal;
-            if (number.startsWith("0x") || number.startsWith("0X")) {
-                number = number.substring(2);
-                base = 16;
-            } else if (number.startsWith("0") && number.length() > 1) {
-                number = number.substring(1);
-                base = 8;
-            }
-            try {
-                long longValue = Long.parseLong(number, base);
-                if (longValue <= Integer.MAX_VALUE && longValue >= Integer.MIN_VALUE) {
-                    return (int) longValue;
-                } else {
-                    return longValue;
-                }
-            } catch (NumberFormatException e) {
-                /*
-                 * This only happens for integral numbers greater than
-                 * Long.MAX_VALUE, numbers in exponential form (5e-10) and
-                 * unquoted strings. Fall through to try floating point.
-                 */
-            }
+    throw syntaxError("Unterminated string");
+  }
+
+  /**
+   * Unescapes the character identified by the character or characters that immediately follow a
+   * backslash. The backslash '\' should have already been read. This supports both unicode escapes
+   * "u000A" and two-character escapes "\n".
+   */
+  private char readEscapeCharacter() throws JSONException {
+    char escaped = in.charAt(pos++);
+    switch (escaped) {
+      case 'u':
+        if (pos + 4 > in.length()) {
+          throw syntaxError("Unterminated escape sequence");
         }
-
-        /* ...next try to parse as a floating point... */
+        String hex = in.substring(pos, pos + 4);
+        pos += 4;
         try {
-            return Double.valueOf(literal);
-        } catch (NumberFormatException ignored) {
+          return (char) Integer.parseInt(hex, 16);
+        } catch (NumberFormatException nfe) {
+          throw syntaxError("Invalid escape sequence: " + hex);
         }
 
-        /* ... finally give up. We have an unquoted string */
-        //noinspection RedundantStringConstructorCall
-        return new String(literal); // a new string avoids leaking memory
-    }
+      case 't':
+        return '\t';
 
-    /**
-     * Returns the string up to but not including any of the given characters or
-     * a newline character. This does not consume the excluded character.
-     */
-    private String nextToInternal(String excluded) {
-        int start = pos;
-        for (; pos < in.length(); pos++) {
-            char c = in.charAt(pos);
-            if (c == '\r' || c == '\n' || excluded.indexOf(c) != -1) {
-                return in.substring(start, pos);
-            }
-        }
-        return in.substring(start);
-    }
+      case 'b':
+        return '\b';
 
-    /**
-     * Reads a sequence of key/value pairs and the trailing closing brace '}' of
-     * an object. The opening brace '{' should have already been read.
-     */
-    private JSONObject readObject() throws JSONException {
-        JSONObject result = new JSONObject();
-
-        /* Peek to see if this is the empty object. */
-        int first = nextCleanInternal();
-        if (first == '}') {
-            return result;
-        } else if (first != -1) {
-            pos--;
-        }
+      case 'n':
+        return '\n';
 
-        while (true) {
-            Object name = nextValue();
-            if (!(name instanceof String)) {
-                if (name == null) {
-                    throw syntaxError("Names cannot be null");
-                } else {
-                    throw syntaxError("Names must be strings, but " + name
-                            + " is of type " + name.getClass().getName());
-                }
-            }
-
-            /*
-             * Expect the name/value separator to be either a colon ':', an
-             * equals sign '=', or an arrow "=>". The last two are bogus but we
-             * include them because that's what the original implementation did.
-             */
-            int separator = nextCleanInternal();
-            if (separator != ':' && separator != '=') {
-                throw syntaxError("Expected ':' after " + name);
-            }
-            if (pos < in.length() && in.charAt(pos) == '>') {
-                pos++;
-            }
-
-            result.put((String) name, nextValue());
-
-            switch (nextCleanInternal()) {
-                case '}':
-                    return result;
-                case ';':
-                case ',':
-                    continue;
-                default:
-                    throw syntaxError("Unterminated object");
-            }
-        }
-    }
+      case 'r':
+        return '\r';
 
-    /**
-     * Reads a sequence of values and the trailing closing brace ']' of an
-     * array. The opening brace '[' should have already been read. Note that
-     * "[]" yields an empty array, but "[,]" returns a two-element array
-     * equivalent to "[null,null]".
-     */
-    private JSONArray readArray() throws JSONException {
-        JSONArray result = new JSONArray();
-
-        /* to cover input that ends with ",]". */
-        boolean hasTrailingSeparator = false;
-
-        while (true) {
-            switch (nextCleanInternal()) {
-                case -1:
-                    throw syntaxError("Unterminated array");
-                case ']':
-                    if (hasTrailingSeparator) {
-                        result.put(null);
-                    }
-                    return result;
-                case ',':
-                case ';':
-                    /* A separator without a value first means "null". */
-                    result.put(null);
-                    hasTrailingSeparator = true;
-                    continue;
-                default:
-                    pos--;
-            }
-
-            result.put(nextValue());
-
-            switch (nextCleanInternal()) {
-                case ']':
-                    return result;
-                case ',':
-                case ';':
-                    hasTrailingSeparator = true;
-                    continue;
-                default:
-                    throw syntaxError("Unterminated array");
-            }
-        }
-    }
+      case 'f':
+        return '\f';
 
-    /**
-     * Returns an exception containing the given message plus the current
-     * position and the entire input string.
-     *
-     * @param message The message we want to include.
-     * @return An exception that we can throw.
-     */
-    public JSONException syntaxError(String message) {
-        return new JSONException(message + this);
+      case '\'':
+      case '"':
+      case '\\':
+      default:
+        return escaped;
     }
-
-    /**
-     * Returns the current position and the entire input string.
-     */
-    @Override
-    public String toString() {
-        // consistent with the original implementation
-        return " at character " + pos + " of " + in;
+  }
+
+  /**
+   * Reads a null, boolean, numeric or unquoted string literal value. Numeric values will be
+   * returned as an Integer, Long, or Double, in that order of preference.
+   */
+  private Object readLiteral() throws JSONException {
+    String literal = nextToInternal("{}[]/\\:,=;# \t\f");
+
+    if (literal.length() == 0) {
+      throw syntaxError("Expected literal value");
+    } else if ("null".equalsIgnoreCase(literal)) {
+      return JSONObject.NULL;
+    } else if ("true".equalsIgnoreCase(literal)) {
+      return Boolean.TRUE;
+    } else if ("false".equalsIgnoreCase(literal)) {
+      return Boolean.FALSE;
     }
 
-    /*
-     * Legacy APIs.
-     *
-     * None of the methods below are on the critical path of parsing JSON
-     * documents. They exist only because they were exposed by the original
-     * implementation and may be used by some clients.
-     */
-
-    /**
-     * Returns true until the input has been exhausted.
-     *
-     * @return true if more input exists.
-     */
-    public boolean more() {
-        return pos < in.length();
+    /* try to parse as an integral type... */
+    if (literal.indexOf('.') == -1) {
+      int base = 10;
+      String number = literal;
+      if (number.startsWith("0x") || number.startsWith("0X")) {
+        number = number.substring(2);
+        base = 16;
+      } else if (number.startsWith("0") && number.length() > 1) {
+        number = number.substring(1);
+        base = 8;
+      }
+      try {
+        long longValue = Long.parseLong(number, base);
+        if (longValue <= Integer.MAX_VALUE && longValue >= Integer.MIN_VALUE) {
+          return (int) longValue;
+        } else {
+          return longValue;
+        }
+      } catch (NumberFormatException e) {
+        /*
+         * This only happens for integral numbers greater than Long.MAX_VALUE, numbers in
+         * exponential form (5e-10) and unquoted strings. Fall through to try floating point.
+         */
+      }
     }
 
-    /**
-     * Returns the next available character, or the null character '\0' if all
-     * input has been exhausted. The return value of this method is ambiguous
-     * for JSON strings that contain the character '\0'.
-     *
-     * @return the next character.
-     */
-    public char next() {
-        return pos < in.length() ? in.charAt(pos++) : '\0';
+    /* ...next try to parse as a floating point... */
+    try {
+      return Double.valueOf(literal);
+    } catch (NumberFormatException ignored) {
     }
 
-    /**
-     * Returns the next available character if it equals {@code c}. Otherwise an
-     * exception is thrown.
-     *
-     * @param c The character we are looking for.
-     * @return the next character.
-     * @throws JSONException If the next character isn't {@code c}
-     */
-    public char next(char c) throws JSONException {
-        char result = next();
-        if (result != c) {
-            throw syntaxError("Expected " + c + " but was " + result);
-        }
-        return result;
+    /* ... finally give up. We have an unquoted string */
+    // noinspection RedundantStringConstructorCall
+    return new String(literal); // a new string avoids leaking memory
+  }
+
+  /**
+   * Returns the string up to but not including any of the given characters or a newline character.
+   * This does not consume the excluded character.
+   */
+  private String nextToInternal(String excluded) {
+    int start = pos;
+    for (; pos < in.length(); pos++) {
+      char c = in.charAt(pos);
+      if (c == '\r' || c == '\n' || excluded.indexOf(c) != -1) {
+        return in.substring(start, pos);
+      }
     }
-
-    /**
-     * Returns the next character that is not whitespace and does not belong to
-     * a comment. If the input is exhausted before such a character can be
-     * found, the null character '\0' is returned. The return value of this
-     * method is ambiguous for JSON strings that contain the character '\0'.
-     *
-     * @return The next non-whitespace character.
-     * @throws JSONException Should not be possible.
-     */
-    public char nextClean() throws JSONException {
-        int nextCleanInt = nextCleanInternal();
-        return nextCleanInt == -1 ? '\0' : (char) nextCleanInt;
+    return in.substring(start);
+  }
+
+  /**
+   * Reads a sequence of key/value pairs and the trailing closing brace '}' of an object. The
+   * opening brace '{' should have already been read.
+   */
+  private JSONObject readObject() throws JSONException {
+    JSONObject result = new JSONObject();
+
+    /* Peek to see if this is the empty object. */
+    int first = nextCleanInternal();
+    if (first == '}') {
+      return result;
+    } else if (first != -1) {
+      pos--;
     }
 
-    /**
-     * Returns the next {@code length} characters of the input.
-     *
-     * <p>The returned string shares its backing character array with this
-     * tokener's input string. If a reference to the returned string may be held
-     * indefinitely, you should use {@code new String(result)} to copy it first
-     * to avoid memory leaks.
-     *
-     * @param length The desired number of characters to return.
-     * @return The next few characters.
-     * @throws JSONException if the remaining input is not long enough to
-     *                       satisfy this request.
-     */
-    public String next(int length) throws JSONException {
-        if (pos + length > in.length()) {
-            throw syntaxError(length + " is out of bounds");
+    while (true) {
+      Object name = nextValue();
+      if (!(name instanceof String)) {
+        if (name == null) {
+          throw syntaxError("Names cannot be null");
+        } else {
+          throw syntaxError(
+              "Names must be strings, but " + name + " is of type " + name.getClass().getName());
         }
-        String result = in.substring(pos, pos + length);
-        pos += length;
-        return result;
+      }
+
+      /*
+       * Expect the name/value separator to be either a colon ':', an equals sign '=', or an arrow
+       * "=>". The last two are bogus but we include them because that's what the original
+       * implementation did.
+       */
+      int separator = nextCleanInternal();
+      if (separator != ':' && separator != '=') {
+        throw syntaxError("Expected ':' after " + name);
+      }
+      if (pos < in.length() && in.charAt(pos) == '>') {
+        pos++;
+      }
+
+      result.put((String) name, nextValue());
+
+      switch (nextCleanInternal()) {
+        case '}':
+          return result;
+        case ';':
+        case ',':
+          continue;
+        default:
+          throw syntaxError("Unterminated object");
+      }
     }
-
-    /**
-     * Returns the {@link String#trim trimmed} string holding the characters up
-     * to but not including the first of:
-     * <ul>
-     * <li>any character in {@code excluded}
-     * <li>a newline character '\n'
-     * <li>a carriage return '\r'
-     * </ul>
-     *
-     * <p>The returned string shares its backing character array with this
-     * tokener's input string. If a reference to the returned string may be held
-     * indefinitely, you should use {@code new String(result)} to copy it first
-     * to avoid memory leaks.
-     *
-     * @param excluded The limiting string where the search should stop.
-     * @return a possibly-empty string
-     */
-    public String nextTo(String excluded) {
-        if (excluded == null) {
-            throw new NullPointerException("excluded == null");
-        }
-        return nextToInternal(excluded).trim();
+  }
+
+  /**
+   * Reads a sequence of values and the trailing closing brace ']' of an array. The opening brace
+   * '[' should have already been read. Note that "[]" yields an empty array, but "[,]" returns a
+   * two-element array equivalent to "[null,null]".
+   */
+  private JSONArray readArray() throws JSONException {
+    JSONArray result = new JSONArray();
+
+    /* to cover input that ends with ",]". */
+    boolean hasTrailingSeparator = false;
+
+    while (true) {
+      switch (nextCleanInternal()) {
+        case -1:
+          throw syntaxError("Unterminated array");
+        case ']':
+          if (hasTrailingSeparator) {
+            result.put(null);
+          }
+          return result;
+        case ',':
+        case ';':
+          /* A separator without a value first means "null". */
+          result.put(null);
+          hasTrailingSeparator = true;
+          continue;
+        default:
+          pos--;
+      }
+
+      result.put(nextValue());
+
+      switch (nextCleanInternal()) {
+        case ']':
+          return result;
+        case ',':
+        case ';':
+          hasTrailingSeparator = true;
+          continue;
+        default:
+          throw syntaxError("Unterminated array");
+      }
     }
-
-    /**
-     * Equivalent to {@code nextTo(String.valueOf(excluded))}.
-     *
-     * @param excluded The limiting character.
-     * @return a possibly-empty string
-     */
-    public String nextTo(char excluded) {
-        return nextToInternal(String.valueOf(excluded)).trim();
+  }
+
+  /**
+   * Returns an exception containing the given message plus the current position and the entire
+   * input string.
+   *
+   * @param message The message we want to include.
+   * @return An exception that we can throw.
+   */
+  public JSONException syntaxError(String message) {
+    return new JSONException(message + this);
+  }
+
+  /**
+   * Returns the current position and the entire input string.
+   */
+  @Override
+  public String toString() {
+    // consistent with the original implementation
+    return " at character " + pos + " of " + in;
+  }
+
+  /*
+   * Legacy APIs.
+   *
+   * None of the methods below are on the critical path of parsing JSON documents. They exist only
+   * because they were exposed by the original implementation and may be used by some clients.
+   */
+
+  /**
+   * Returns true until the input has been exhausted.
+   *
+   * @return true if more input exists.
+   */
+  public boolean more() {
+    return pos < in.length();
+  }
+
+  /**
+   * Returns the next available character, or the null character '\0' if all input has been
+   * exhausted. The return value of this method is ambiguous for JSON strings that contain the
+   * character '\0'.
+   *
+   * @return the next character.
+   */
+  public char next() {
+    return pos < in.length() ? in.charAt(pos++) : '\0';
+  }
+
+  /**
+   * Returns the next available character if it equals {@code c}. Otherwise an exception is thrown.
+   *
+   * @param c The character we are looking for.
+   * @return the next character.
+   * @throws JSONException If the next character isn't {@code c}
+   */
+  public char next(char c) throws JSONException {
+    char result = next();
+    if (result != c) {
+      throw syntaxError("Expected " + c + " but was " + result);
     }
-
-    /**
-     * Advances past all input up to and including the next occurrence of
-     * {@code thru}. If the remaining input doesn't contain {@code thru}, the
-     * input is exhausted.
-     *
-     * @param thru The string to skip over.
-     */
-    public void skipPast(String thru) {
-        int thruStart = in.indexOf(thru, pos);
-        pos = thruStart == -1 ? in.length() : (thruStart + thru.length());
+    return result;
+  }
+
+  /**
+   * Returns the next character that is not whitespace and does not belong to a comment. If the
+   * input is exhausted before such a character can be found, the null character '\0' is returned.
+   * The return value of this method is ambiguous for JSON strings that contain the character '\0'.
+   *
+   * @return The next non-whitespace character.
+   * @throws JSONException Should not be possible.
+   */
+  public char nextClean() throws JSONException {
+    int nextCleanInt = nextCleanInternal();
+    return nextCleanInt == -1 ? '\0' : (char) nextCleanInt;
+  }
+
+  /**
+   * Returns the next {@code length} characters of the input.
+   *
+   * <p>
+   * The returned string shares its backing character array with this tokener's input string. If a
+   * reference to the returned string may be held indefinitely, you should use
+   * {@code new String(result)} to copy it first to avoid memory leaks.
+   *
+   * @param length The desired number of characters to return.
+   * @return The next few characters.
+   * @throws JSONException if the remaining input is not long enough to satisfy this request.
+   */
+  public String next(int length) throws JSONException {
+    if (pos + length > in.length()) {
+      throw syntaxError(length + " is out of bounds");
     }
-
-    /**
-     * Advances past all input up to but not including the next occurrence of
-     * {@code to}. If the remaining input doesn't contain {@code to}, the input
-     * is unchanged.
-     *
-     * @param to The character we want to skip to.
-     * @return The value of {@code to} or null.
-     */
-    public char skipTo(char to) {
-        int index = in.indexOf(to, pos);
-        if (index != -1) {
-            pos = index;
-            return to;
-        } else {
-            return '\0';
-        }
+    String result = in.substring(pos, pos + length);
+    pos += length;
+    return result;
+  }
+
+  /**
+   * Returns the {@link String#trim trimmed} string holding the characters up to but not including
+   * the first of:
+   * <ul>
+   * <li>any character in {@code excluded}
+   * <li>a newline character '\n'
+   * <li>a carriage return '\r'
+   * </ul>
+   *
+   * <p>
+   * The returned string shares its backing character array with this tokener's input string. If a
+   * reference to the returned string may be held indefinitely, you should use
+   * {@code new String(result)} to copy it first to avoid memory leaks.
+   *
+   * @param excluded The limiting string where the search should stop.
+   * @return a possibly-empty string
+   */
+  public String nextTo(String excluded) {
+    if (excluded == null) {
+      throw new NullPointerException("excluded == null");
     }
-
-    /**
-     * Unreads the most recent character of input. If no input characters have
-     * been read, the input is unchanged.
-     */
-    public void back() {
-        if (--pos == -1) {
-            pos = 0;
-        }
+    return nextToInternal(excluded).trim();
+  }
+
+  /**
+   * Equivalent to {@code nextTo(String.valueOf(excluded))}.
+   *
+   * @param excluded The limiting character.
+   * @return a possibly-empty string
+   */
+  public String nextTo(char excluded) {
+    return nextToInternal(String.valueOf(excluded)).trim();
+  }
+
+  /**
+   * Advances past all input up to and including the next occurrence of {@code thru}. If the
+   * remaining input doesn't contain {@code thru}, the input is exhausted.
+   *
+   * @param thru The string to skip over.
+   */
+  public void skipPast(String thru) {
+    int thruStart = in.indexOf(thru, pos);
+    pos = thruStart == -1 ? in.length() : (thruStart + thru.length());
+  }
+
+  /**
+   * Advances past all input up to but not including the next occurrence of {@code to}. If the
+   * remaining input doesn't contain {@code to}, the input is unchanged.
+   *
+   * @param to The character we want to skip to.
+   * @return The value of {@code to} or null.
+   */
+  public char skipTo(char to) {
+    int index = in.indexOf(to, pos);
+    if (index != -1) {
+      pos = index;
+      return to;
+    } else {
+      return '\0';
     }
-
-    /**
-     * Returns the integer [0..15] value for the given hex character, or -1
-     * for non-hex input.
-     *
-     * @param hex a character in the ranges [0-9], [A-F] or [a-f]. Any other
-     *            character will yield a -1 result.
-     * @return The decoded integer.
-     */
-    public static int dehexchar(char hex) {
-        if (hex >= '0' && hex <= '9') {
-            return hex - '0';
-        } else if (hex >= 'A' && hex <= 'F') {
-            return hex - 'A' + 10;
-        } else if (hex >= 'a' && hex <= 'f') {
-            return hex - 'a' + 10;
-        } else {
-            return -1;
-        }
+  }
+
+  /**
+   * Unreads the most recent character of input. If no input characters have been read, the input is
+   * unchanged.
+   */
+  public void back() {
+    if (--pos == -1) {
+      pos = 0;
+    }
+  }
+
+  /**
+   * Returns the integer [0..15] value for the given hex character, or -1 for non-hex input.
+   *
+   * @param hex a character in the ranges [0-9], [A-F] or [a-f]. Any other character will yield a -1
+   *        result.
+   * @return The decoded integer.
+   */
+  public static int dehexchar(char hex) {
+    if (hex >= '0' && hex <= '9') {
+      return hex - '0';
+    } else if (hex >= 'A' && hex <= 'F') {
+      return hex - 'A' + 10;
+    } else if (hex >= 'a' && hex <= 'f') {
+      return hex - 'a' + 10;
+    } else {
+      return -1;
     }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/test/java/org/json/FileTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/FileTest.java b/geode-json/src/test/java/org/json/FileTest.java
index dae910b..36fcae9 100755
--- a/geode-json/src/test/java/org/json/FileTest.java
+++ b/geode-json/src/test/java/org/json/FileTest.java
@@ -8,280 +8,153 @@ import java.io.InputStreamReader;
 import java.util.Set;
 
 public class FileTest {
-    @Test
-    public void testFile() throws IOException, JSONException {
-        String ref = "[\n" +
-                "  {\n" +
-                "    \"_id\": \"58309f3bd307b72ae49a9b23\",\n" +
-                "    \"index\": 0,\n" +
-                "    \"guid\": \"5764ebd8-b333-469e-8d83-4eb5658f1566\",\n" +
-                "    \"isActive\": true,\n" +
-                "    \"balance\": \"$1,099.93\",\n" +
-                "    \"picture\": \"http://placehold.it/32x32\",\n" +
-                "    \"age\": 37,\n" +
-                "    \"eyeColor\": \"blue\",\n" +
-                "    \"name\": \"Barrera Wilkerson\",\n" +
-                "    \"gender\": \"male\",\n" +
-                "    \"company\": \"VURBO\",\n" +
-                "    \"email\": \"barrerawilkerson@vurbo.com\",\n" +
-                "    \"phone\": \"+1 (817) 429-2473\",\n" +
-                "    \"address\": \"522 Vanderveer Street, Detroit, Wyoming, 4320\",\n" +
-                "    \"about\": \"Et officia aute ullamco magna adipisicing non ut cupidatat cupidatat aliquip. Tempor occaecat ex ad dolore aliquip mollit ea esse ipsum. Est incididunt sunt commodo duis est. Reprehenderit in ut reprehenderit ad culpa ea fugiat et est adipisicing aliquip. Id mollit voluptate qui pariatur officia.\\r\\n\",\n" +
-                "    \"registered\": \"2016-06-29T08:54:14 +07:00\",\n" +
-                "    \"latitude\": -87.548434,\n" +
-                "    \"longitude\": 64.251242,\n" +
-                "    \"tags\": [\n" +
-                "      \"aliqua\",\n" +
-                "      \"ex\",\n" +
-                "      \"sit\",\n" +
-                "      \"magna\",\n" +
-                "      \"dolor\",\n" +
-                "      \"laborum\",\n" +
-                "      \"non\"\n" +
-                "    ],\n" +
-                "    \"friends\": [\n" +
-                "      {\n" +
-                "        \"id\": 0,\n" +
-                "        \"name\": \"Byers Pratt\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 1,\n" +
-                "        \"name\": \"Kennedy Contreras\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 2,\n" +
-                "        \"name\": \"Frazier Monroe\"\n" +
-                "      }\n" +
-                "    ],\n" +
-                "    \"greeting\": \"Hello, Barrera Wilkerson! You have 3 unread messages.\",\n" +
-                "    \"favoriteFruit\": \"banana\"\n" +
-                "  },\n" +
-                "  {\n" +
-                "    \"_id\": \"58309f3b1f506440093a41d1\",\n" +
-                "    \"index\": 1,\n" +
-                "    \"guid\": \"de1a6cc9-f8b3-426e-b68a-cc30e1fff3c1\",\n" +
-                "    \"isActive\": false,\n" +
-                "    \"balance\": \"$3,397.60\",\n" +
-                "    \"picture\": \"http://placehold.it/32x32\",\n" +
-                "    \"age\": 32,\n" +
-                "    \"eyeColor\": \"blue\",\n" +
-                "    \"name\": \"Trisha Morris\",\n" +
-                "    \"gender\": \"female\",\n" +
-                "    \"company\": \"AMTAP\",\n" +
-                "    \"email\": \"trishamorris@amtap.com\",\n" +
-                "    \"phone\": \"+1 (805) 423-3375\",\n" +
-                "    \"address\": \"495 Tampa Court, Libertytown, New Hampshire, 5177\",\n" +
-                "    \"about\": \"Elit culpa Lorem dolor sit laborum ut ullamco ullamco nostrud reprehenderit adipisicing eiusmod. Aliqua quis dolor esse sint. Dolore in excepteur laborum anim ut consectetur. Nisi officia est eu ex ex id. Ipsum duis ullamco ad ut labore dolor. In amet tempor deserunt ullamco velit eu fugiat.\\r\\n\",\n" +
-                "    \"registered\": \"2015-02-08T06:14:19 +08:00\",\n" +
-                "    \"latitude\": -81.956277,\n" +
-                "    \"longitude\": 143.685584,\n" +
-                "    \"tags\": [\n" +
-                "      \"cillum\",\n" +
-                "      \"ullamco\",\n" +
-                "      \"magna\",\n" +
-                "      \"cillum\",\n" +
-                "      \"voluptate\",\n" +
-                "      \"magna\",\n" +
-                "      \"exercitation\"\n" +
-                "    ],\n" +
-                "    \"friends\": [\n" +
-                "      {\n" +
-                "        \"id\": 0,\n" +
-                "        \"name\": \"Fuentes Stout\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 1,\n" +
-                "        \"name\": \"Violet Vargas\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 2,\n" +
-                "        \"name\": \"Schmidt Wilder\"\n" +
-                "      }\n" +
-                "    ],\n" +
-                "    \"greeting\": \"Hello, Trisha Morris! You have 4 unread messages.\",\n" +
-                "    \"favoriteFruit\": \"strawberry\"\n" +
-                "  },\n" +
-                "  {\n" +
-                "    \"_id\": \"58309f3beaef2f31339b3755\",\n" +
-                "    \"index\": 2,\n" +
-                "    \"guid\": \"0bf387b7-abc2-4828-becc-1269928f7c3d\",\n" +
-                "    \"isActive\": false,\n" +
-                "    \"balance\": \"$1,520.64\",\n" +
-                "    \"picture\": \"http://placehold.it/32x32\",\n" +
-                "    \"age\": 37,\n" +
-                "    \"eyeColor\": \"blue\",\n" +
-                "    \"name\": \"Deanna Santiago\",\n" +
-                "    \"gender\": \"female\",\n" +
-                "    \"company\": \"MEGALL\",\n" +
-                "    \"email\": \"deannasantiago@megall.com\",\n" +
-                "    \"phone\": \"+1 (916) 511-2291\",\n" +
-                "    \"address\": \"919 Fayette Street, Homestead, Utah, 8669\",\n" +
-                "    \"about\": \"Sit amet ex quis velit irure Lorem non quis aliquip dolor pariatur nulla Lorem officia. Deserunt officia sit velit labore sint nostrud elit aliquip labore ullamco consectetur id amet. Ullamco duis commodo sit incididunt. Fugiat consectetur ad incididunt officia. Sint cillum minim laborum laboris id cillum est exercitation in eiusmod qui.\\r\\n\",\n" +
-                "    \"registered\": \"2015-11-18T08:39:28 +08:00\",\n" +
-                "    \"latitude\": 79.105701,\n" +
-                "    \"longitude\": -146.901754,\n" +
-                "    \"tags\": [\n" +
-                "      \"non\",\n" +
-                "      \"ullamco\",\n" +
-                "      \"cillum\",\n" +
-                "      \"ipsum\",\n" +
-                "      \"amet\",\n" +
-                "      \"aliqua\",\n" +
-                "      \"aliquip\"\n" +
-                "    ],\n" +
-                "    \"friends\": [\n" +
-                "      {\n" +
-                "        \"id\": 0,\n" +
-                "        \"name\": \"Hanson Anderson\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 1,\n" +
-                "        \"name\": \"Pollard Soto\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 2,\n" +
-                "        \"name\": \"Barlow Campbell\"\n" +
-                "      }\n" +
-                "    ],\n" +
-                "    \"greeting\": \"Hello, Deanna Santiago! You have 7 unread messages.\",\n" +
-                "    \"favoriteFruit\": \"apple\"\n" +
-                "  },\n" +
-                "  {\n" +
-                "    \"_id\": \"58309f3b49a68ad01346f27f\",\n" +
-                "    \"index\": 3,\n" +
-                "    \"guid\": \"d29c0dcc-48fb-4ca4-a63b-b47c0e6d6398\",\n" +
-                "    \"isActive\": false,\n" +
-                "    \"balance\": \"$2,069.96\",\n" +
-                "    \"picture\": \"http://placehold.it/32x32\",\n" +
-                "    \"age\": 29,\n" +
-                "    \"eyeColor\": \"green\",\n" +
-                "    \"name\": \"Brooks Gates\",\n" +
-                "    \"gender\": \"male\",\n" +
-                "    \"company\": \"TERRAGEN\",\n" +
-                "    \"email\": \"brooksgates@terragen.com\",\n" +
-                "    \"phone\": \"+1 (875) 483-2224\",\n" +
-                "    \"address\": \"562 Noll Street, Kipp, Louisiana, 7659\",\n" +
-                "    \"about\": \"Reprehenderit laboris mollit nulla commodo quis laborum commodo. Laborum aliquip laboris officia minim ipsum laborum ipsum reprehenderit quis laboris est sint culpa. Culpa magna aute mollit exercitation.\\r\\n\",\n" +
-                "    \"registered\": \"2016-05-04T10:34:38 +07:00\",\n" +
-                "    \"latitude\": 72.77079,\n" +
-                "    \"longitude\": -134.291768,\n" +
-                "    \"tags\": [\n" +
-                "      \"est\",\n" +
-                "      \"sunt\",\n" +
-                "      \"laboris\",\n" +
-                "      \"ea\",\n" +
-                "      \"proident\",\n" +
-                "      \"aute\",\n" +
-                "      \"excepteur\"\n" +
-                "    ],\n" +
-                "    \"friends\": [\n" +
-                "      {\n" +
-                "        \"id\": 0,\n" +
-                "        \"name\": \"Roxanne Morgan\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 1,\n" +
-                "        \"name\": \"Tamara Kelly\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 2,\n" +
-                "        \"name\": \"Cleveland Bush\"\n" +
-                "      }\n" +
-                "    ],\n" +
-                "    \"greeting\": \"Hello, Brooks Gates! You have 1 unread messages.\",\n" +
-                "    \"favoriteFruit\": \"banana\"\n" +
-                "  },\n" +
-                "  {\n" +
-                "    \"_id\": \"58309f3be746700e9af9a645\",\n" +
-                "    \"index\": 4,\n" +
-                "    \"guid\": \"54382bd6-c476-469d-9e1c-e546f959db51\",\n" +
-                "    \"isActive\": true,\n" +
-                "    \"balance\": \"$2,012.57\",\n" +
-                "    \"picture\": \"http://placehold.it/32x32\",\n" +
-                "    \"age\": 40,\n" +
-                "    \"eyeColor\": \"brown\",\n" +
-                "    \"name\": \"Jackie Thomas\",\n" +
-                "    \"gender\": \"female\",\n" +
-                "    \"company\": \"HINWAY\",\n" +
-                "    \"email\": \"jackiethomas@hinway.com\",\n" +
-                "    \"phone\": \"+1 (843) 470-2096\",\n" +
-                "    \"address\": \"910 Emerson Place, Gwynn, Federated States Of Micronesia, 4688\",\n" +
-                "    \"about\": \"Id cupidatat laboris elit est eiusmod esse nostrud. Ex commodo nisi voluptate est nisi laborum officia sint incididunt pariatur qui deserunt ullamco. Fugiat proident magna ipsum sit sint id adipisicing sit nostrud labore sit officia. Eiusmod exercitation non enim excepteur amet irure ullamco consectetur cupidatat proident Lorem reprehenderit aliquip. Veniam esse dolor Lorem incididunt proident officia enim in incididunt culpa. Mollit voluptate commodo aliquip anim ipsum nostrud ut labore enim labore qui do minim incididunt. Quis irure proident voluptate nisi qui sunt aute duis irure.\\r\\n\",\n" +
-                "    \"registered\": \"2014-08-03T09:21:43 +07:00\",\n" +
-                "    \"latitude\": 84.871256,\n" +
-                "    \"longitude\": 2.043339,\n" +
-                "    \"tags\": [\n" +
-                "      \"tempor\",\n" +
-                "      \"ut\",\n" +
-                "      \"deserunt\",\n" +
-                "      \"esse\",\n" +
-                "      \"nostrud\",\n" +
-                "      \"dolore\",\n" +
-                "      \"ex\"\n" +
-                "    ],\n" +
-                "    \"friends\": [\n" +
-                "      {\n" +
-                "        \"id\": 0,\n" +
-                "        \"name\": \"Lois Walters\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 1,\n" +
-                "        \"name\": \"Brewer Buchanan\"\n" +
-                "      },\n" +
-                "      {\n" +
-                "        \"id\": 2,\n" +
-                "        \"name\": \"Mccormick Fleming\"\n" +
-                "      }\n" +
-                "    ],\n" +
-                "    \"greeting\": \"Hello, Jackie Thomas! You have 2 unread messages.\",\n" +
-                "    \"favoriteFruit\": \"banana\"\n" +
-                "  }\n" +
-                "]";
+  @Test
+  public void testFile() throws IOException, JSONException {
+    String ref = "[\n" + "  {\n" + "    \"_id\": \"58309f3bd307b72ae49a9b23\",\n"
+        + "    \"index\": 0,\n" + "    \"guid\": \"5764ebd8-b333-469e-8d83-4eb5658f1566\",\n"
+        + "    \"isActive\": true,\n" + "    \"balance\": \"$1,099.93\",\n"
+        + "    \"picture\": \"http://placehold.it/32x32\",\n" + "    \"age\": 37,\n"
+        + "    \"eyeColor\": \"blue\",\n" + "    \"name\": \"Barrera Wilkerson\",\n"
+        + "    \"gender\": \"male\",\n" + "    \"company\": \"VURBO\",\n"
+        + "    \"email\": \"barrerawilkerson@vurbo.com\",\n"
+        + "    \"phone\": \"+1 (817) 429-2473\",\n"
+        + "    \"address\": \"522 Vanderveer Street, Detroit, Wyoming, 4320\",\n"
+        + "    \"about\": \"Et officia aute ullamco magna adipisicing non ut cupidatat cupidatat aliquip. Tempor occaecat ex ad dolore aliquip mollit ea esse ipsum. Est incididunt sunt commodo duis est. Reprehenderit in ut reprehenderit ad culpa ea fugiat et est adipisicing aliquip. Id mollit voluptate qui pariatur officia.\\r\\n\",\n"
+        + "    \"registered\": \"2016-06-29T08:54:14 +07:00\",\n"
+        + "    \"latitude\": -87.548434,\n" + "    \"longitude\": 64.251242,\n"
+        + "    \"tags\": [\n" + "      \"aliqua\",\n" + "      \"ex\",\n" + "      \"sit\",\n"
+        + "      \"magna\",\n" + "      \"dolor\",\n" + "      \"laborum\",\n" + "      \"non\"\n"
+        + "    ],\n" + "    \"friends\": [\n" + "      {\n" + "        \"id\": 0,\n"
+        + "        \"name\": \"Byers Pratt\"\n" + "      },\n" + "      {\n"
+        + "        \"id\": 1,\n" + "        \"name\": \"Kennedy Contreras\"\n" + "      },\n"
+        + "      {\n" + "        \"id\": 2,\n" + "        \"name\": \"Frazier Monroe\"\n"
+        + "      }\n" + "    ],\n"
+        + "    \"greeting\": \"Hello, Barrera Wilkerson! You have 3 unread messages.\",\n"
+        + "    \"favoriteFruit\": \"banana\"\n" + "  },\n" + "  {\n"
+        + "    \"_id\": \"58309f3b1f506440093a41d1\",\n" + "    \"index\": 1,\n"
+        + "    \"guid\": \"de1a6cc9-f8b3-426e-b68a-cc30e1fff3c1\",\n" + "    \"isActive\": false,\n"
+        + "    \"balance\": \"$3,397.60\",\n" + "    \"picture\": \"http://placehold.it/32x32\",\n"
+        + "    \"age\": 32,\n" + "    \"eyeColor\": \"blue\",\n"
+        + "    \"name\": \"Trisha Morris\",\n" + "    \"gender\": \"female\",\n"
+        + "    \"company\": \"AMTAP\",\n" + "    \"email\": \"trishamorris@amtap.com\",\n"
+        + "    \"phone\": \"+1 (805) 423-3375\",\n"
+        + "    \"address\": \"495 Tampa Court, Libertytown, New Hampshire, 5177\",\n"
+        + "    \"about\": \"Elit culpa Lorem dolor sit laborum ut ullamco ullamco nostrud reprehenderit adipisicing eiusmod. Aliqua quis dolor esse sint. Dolore in excepteur laborum anim ut consectetur. Nisi officia est eu ex ex id. Ipsum duis ullamco ad ut labore dolor. In amet tempor deserunt ullamco velit eu fugiat.\\r\\n\",\n"
+        + "    \"registered\": \"2015-02-08T06:14:19 +08:00\",\n"
+        + "    \"latitude\": -81.956277,\n" + "    \"longitude\": 143.685584,\n"
+        + "    \"tags\": [\n" + "      \"cillum\",\n" + "      \"ullamco\",\n"
+        + "      \"magna\",\n" + "      \"cillum\",\n" + "      \"voluptate\",\n"
+        + "      \"magna\",\n" + "      \"exercitation\"\n" + "    ],\n" + "    \"friends\": [\n"
+        + "      {\n" + "        \"id\": 0,\n" + "        \"name\": \"Fuentes Stout\"\n"
+        + "      },\n" + "      {\n" + "        \"id\": 1,\n"
+        + "        \"name\": \"Violet Vargas\"\n" + "      },\n" + "      {\n"
+        + "        \"id\": 2,\n" + "        \"name\": \"Schmidt Wilder\"\n" + "      }\n"
+        + "    ],\n" + "    \"greeting\": \"Hello, Trisha Morris! You have 4 unread messages.\",\n"
+        + "    \"favoriteFruit\": \"strawberry\"\n" + "  },\n" + "  {\n"
+        + "    \"_id\": \"58309f3beaef2f31339b3755\",\n" + "    \"index\": 2,\n"
+        + "    \"guid\": \"0bf387b7-abc2-4828-becc-1269928f7c3d\",\n" + "    \"isActive\": false,\n"
+        + "    \"balance\": \"$1,520.64\",\n" + "    \"picture\": \"http://placehold.it/32x32\",\n"
+        + "    \"age\": 37,\n" + "    \"eyeColor\": \"blue\",\n"
+        + "    \"name\": \"Deanna Santiago\",\n" + "    \"gender\": \"female\",\n"
+        + "    \"company\": \"MEGALL\",\n" + "    \"email\": \"deannasantiago@megall.com\",\n"
+        + "    \"phone\": \"+1 (916) 511-2291\",\n"
+        + "    \"address\": \"919 Fayette Street, Homestead, Utah, 8669\",\n"
+        + "    \"about\": \"Sit amet ex quis velit irure Lorem non quis aliquip dolor pariatur nulla Lorem officia. Deserunt officia sit velit labore sint nostrud elit aliquip labore ullamco consectetur id amet. Ullamco duis commodo sit incididunt. Fugiat consectetur ad incididunt officia. Sint cillum minim laborum laboris id cillum est exercitation in eiusmod qui.\\r\\n\",\n"
+        + "    \"registered\": \"2015-11-18T08:39:28 +08:00\",\n" + "    \"latitude\": 79.105701,\n"
+        + "    \"longitude\": -146.901754,\n" + "    \"tags\": [\n" + "      \"non\",\n"
+        + "      \"ullamco\",\n" + "      \"cillum\",\n" + "      \"ipsum\",\n"
+        + "      \"amet\",\n" + "      \"aliqua\",\n" + "      \"aliquip\"\n" + "    ],\n"
+        + "    \"friends\": [\n" + "      {\n" + "        \"id\": 0,\n"
+        + "        \"name\": \"Hanson Anderson\"\n" + "      },\n" + "      {\n"
+        + "        \"id\": 1,\n" + "        \"name\": \"Pollard Soto\"\n" + "      },\n"
+        + "      {\n" + "        \"id\": 2,\n" + "        \"name\": \"Barlow Campbell\"\n"
+        + "      }\n" + "    ],\n"
+        + "    \"greeting\": \"Hello, Deanna Santiago! You have 7 unread messages.\",\n"
+        + "    \"favoriteFruit\": \"apple\"\n" + "  },\n" + "  {\n"
+        + "    \"_id\": \"58309f3b49a68ad01346f27f\",\n" + "    \"index\": 3,\n"
+        + "    \"guid\": \"d29c0dcc-48fb-4ca4-a63b-b47c0e6d6398\",\n" + "    \"isActive\": false,\n"
+        + "    \"balance\": \"$2,069.96\",\n" + "    \"picture\": \"http://placehold.it/32x32\",\n"
+        + "    \"age\": 29,\n" + "    \"eyeColor\": \"green\",\n"
+        + "    \"name\": \"Brooks Gates\",\n" + "    \"gender\": \"male\",\n"
+        + "    \"company\": \"TERRAGEN\",\n" + "    \"email\": \"brooksgates@terragen.com\",\n"
+        + "    \"phone\": \"+1 (875) 483-2224\",\n"
+        + "    \"address\": \"562 Noll Street, Kipp, Louisiana, 7659\",\n"
+        + "    \"about\": \"Reprehenderit laboris mollit nulla commodo quis laborum commodo. Laborum aliquip laboris officia minim ipsum laborum ipsum reprehenderit quis laboris est sint culpa. Culpa magna aute mollit exercitation.\\r\\n\",\n"
+        + "    \"registered\": \"2016-05-04T10:34:38 +07:00\",\n" + "    \"latitude\": 72.77079,\n"
+        + "    \"longitude\": -134.291768,\n" + "    \"tags\": [\n" + "      \"est\",\n"
+        + "      \"sunt\",\n" + "      \"laboris\",\n" + "      \"ea\",\n" + "      \"proident\",\n"
+        + "      \"aute\",\n" + "      \"excepteur\"\n" + "    ],\n" + "    \"friends\": [\n"
+        + "      {\n" + "        \"id\": 0,\n" + "        \"name\": \"Roxanne Morgan\"\n"
+        + "      },\n" + "      {\n" + "        \"id\": 1,\n"
+        + "        \"name\": \"Tamara Kelly\"\n" + "      },\n" + "      {\n"
+        + "        \"id\": 2,\n" + "        \"name\": \"Cleveland Bush\"\n" + "      }\n"
+        + "    ],\n" + "    \"greeting\": \"Hello, Brooks Gates! You have 1 unread messages.\",\n"
+        + "    \"favoriteFruit\": \"banana\"\n" + "  },\n" + "  {\n"
+        + "    \"_id\": \"58309f3be746700e9af9a645\",\n" + "    \"index\": 4,\n"
+        + "    \"guid\": \"54382bd6-c476-469d-9e1c-e546f959db51\",\n" + "    \"isActive\": true,\n"
+        + "    \"balance\": \"$2,012.57\",\n" + "    \"picture\": \"http://placehold.it/32x32\",\n"
+        + "    \"age\": 40,\n" + "    \"eyeColor\": \"brown\",\n"
+        + "    \"name\": \"Jackie Thomas\",\n" + "    \"gender\": \"female\",\n"
+        + "    \"company\": \"HINWAY\",\n" + "    \"email\": \"jackiethomas@hinway.com\",\n"
+        + "    \"phone\": \"+1 (843) 470-2096\",\n"
+        + "    \"address\": \"910 Emerson Place, Gwynn, Federated States Of Micronesia, 4688\",\n"
+        + "    \"about\": \"Id cupidatat laboris elit est eiusmod esse nostrud. Ex commodo nisi voluptate est nisi laborum officia sint incididunt pariatur qui deserunt ullamco. Fugiat proident magna ipsum sit sint id adipisicing sit nostrud labore sit officia. Eiusmod exercitation non enim excepteur amet irure ullamco consectetur cupidatat proident Lorem reprehenderit aliquip. Veniam esse dolor Lorem incididunt proident officia enim in incididunt culpa. Mollit voluptate commodo aliquip anim ipsum nostrud ut labore enim labore qui do minim incididunt. Quis irure proident voluptate nisi qui sunt aute duis irure.\\r\\n\",\n"
+        + "    \"registered\": \"2014-08-03T09:21:43 +07:00\",\n" + "    \"latitude\": 84.871256,\n"
+        + "    \"longitude\": 2.043339,\n" + "    \"tags\": [\n" + "      \"tempor\",\n"
+        + "      \"ut\",\n" + "      \"deserunt\",\n" + "      \"esse\",\n" + "      \"nostrud\",\n"
+        + "      \"dolore\",\n" + "      \"ex\"\n" + "    ],\n" + "    \"friends\": [\n"
+        + "      {\n" + "        \"id\": 0,\n" + "        \"name\": \"Lois Walters\"\n"
+        + "      },\n" + "      {\n" + "        \"id\": 1,\n"
+        + "        \"name\": \"Brewer Buchanan\"\n" + "      },\n" + "      {\n"
+        + "        \"id\": 2,\n" + "        \"name\": \"Mccormick Fleming\"\n" + "      }\n"
+        + "    ],\n" + "    \"greeting\": \"Hello, Jackie Thomas! You have 2 unread messages.\",\n"
+        + "    \"favoriteFruit\": \"banana\"\n" + "  }\n" + "]";
 
-        JSONArray x1 = (JSONArray) new JSONTokener(new InputStreamReader(this.getClass().getResourceAsStream("/sample-01.json"))).nextValue();
-        JSONArray x2 = (JSONArray) new JSONTokener(ref).nextValue();
+    JSONArray x1 = (JSONArray) new JSONTokener(
+        new InputStreamReader(this.getClass().getResourceAsStream("/sample-01.json"))).nextValue();
+    JSONArray x2 = (JSONArray) new JSONTokener(ref).nextValue();
 
-        Assert.assertTrue(jsonEquals(x1, x2));
-    }
+    Assert.assertTrue(jsonEquals(x1, x2));
+  }
 
-    private boolean jsonEquals(JSONArray x1, JSONArray x2) throws JSONException {
-        if (x1.length() != x2.length()) {
-            return false;
-        }
+  private boolean jsonEquals(JSONArray x1, JSONArray x2) throws JSONException {
+    if (x1.length() != x2.length()) {
+      return false;
+    }
 
-        for (int i = 0; i < x1.length(); i++) {
-            Object element1 = x1.get(i);
-            Object element2 = x2.get(i);
-            if (!jsonEquals(element1, element2)) {
-                return false;
-            }
-        }
-        return true;
+    for (int i = 0; i < x1.length(); i++) {
+      Object element1 = x1.get(i);
+      Object element2 = x2.get(i);
+      if (!jsonEquals(element1, element2)) {
+        return false;
+      }
     }
+    return true;
+  }
 
-    private boolean jsonEquals(JSONObject x1, JSONObject x2) throws JSONException {
-        if (x1.length() != x2.length()) {
-            return false;
-        }
-        Set<String> names = x1.keySet();
-        for (String name : names) {
-            if (!jsonEquals(x1.get(name), x2.get(name))) {
-                return false;
-            }
-        }
-        return true;
+  private boolean jsonEquals(JSONObject x1, JSONObject x2) throws JSONException {
+    if (x1.length() != x2.length()) {
+      return false;
+    }
+    Set<String> names = x1.keySet();
+    for (String name : names) {
+      if (!jsonEquals(x1.get(name), x2.get(name))) {
+        return false;
+      }
     }
+    return true;
+  }
 
-    private boolean jsonEquals(Object element1, Object element2) throws JSONException {
-        if (!element1.getClass().equals(element2.getClass())) {
-            return false;
-        }
-        if (element1 instanceof JSONObject) {
-            return jsonEquals((JSONObject) element1, (JSONObject) element2);
-        }
-        if (element1 instanceof JSONArray) {
-            return jsonEquals((JSONArray) element1, (JSONArray) element2);
-        }
-        return element1.equals(element2);
+  private boolean jsonEquals(Object element1, Object element2) throws JSONException {
+    if (!element1.getClass().equals(element2.getClass())) {
+      return false;
+    }
+    if (element1 instanceof JSONObject) {
+      return jsonEquals((JSONObject) element1, (JSONObject) element2);
+    }
+    if (element1 instanceof JSONArray) {
+      return jsonEquals((JSONArray) element1, (JSONArray) element2);
     }
+    return element1.equals(element2);
+  }
 }


[37/51] [abbrv] geode git commit: GEODE-2562 Revise Main Features paragraph per review

Posted by ds...@apache.org.
GEODE-2562 Revise Main Features paragraph per review


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c0d43b35
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c0d43b35
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c0d43b35

Branch: refs/heads/feature/GEM-1195
Commit: c0d43b35ee78dfbfb2fee767bc552ed924da6eb7
Parents: 83ff677
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Mar 1 15:44:17 2017 -0800
Committer: Karen Miller <km...@pivotal.io>
Committed: Wed Mar 1 15:44:17 2017 -0800

----------------------------------------------------------------------
 geode-docs/getting_started/product_intro.html.md.erb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c0d43b35/geode-docs/getting_started/product_intro.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/getting_started/product_intro.html.md.erb b/geode-docs/getting_started/product_intro.html.md.erb
index 103b2dd..063fd08 100644
--- a/geode-docs/getting_started/product_intro.html.md.erb
+++ b/geode-docs/getting_started/product_intro.html.md.erb
@@ -37,7 +37,8 @@ This section summarizes main features and key functionality.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_CF0E3E5C4F884374B8F2F536DD2A375C" class="no-quick-link"></a>High Read-and-Write Throughput
 
-Read-and-write throughput is provided by concurrent main-memory data structures and a highly optimized distribution infrastructure. Applications can make copies of data dynamically in memory through synchronous or asynchronous replication for high read throughput or partition the data across many system members to achieve high read-and-write throughput. Data partitioning doubles the aggregate throughput if the data access is fairly balanced across the entire data set. Linear increase in throughput is limited only by the backbone network capacity.
+Concurrent main-memory data structures and a highly optimized distribution infrastructure provide read-and-write throughput.
+Applications can make copies of data dynamically in memory through synchronous or asynchronous replication for high read throughput or partition the data across many system members to achieve high read-and-write throughput. Data partitioning doubles the aggregate throughput if the data access is fairly balanced across the entire data set. Linear increase in throughput is limited only by the backbone network capacity.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_9C5D669B583646F1B817284EB494DDA7" class="no-quick-link"></a>Low and Predictable Latency
 


[05/51] [abbrv] geode git commit: GEODE-2142: Removal of offending JSON.ORG code and license information

Posted by ds...@apache.org.
GEODE-2142: Removal of offending JSON.ORG code and license information


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/a2f47b72
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/a2f47b72
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/a2f47b72

Branch: refs/heads/feature/GEM-1195
Commit: a2f47b724d0894811d77ce92c524e3eba4ed34f2
Parents: 76ea6c3
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Feb 17 14:22:55 2017 -0800
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Mon Feb 27 07:18:55 2017 -0800

----------------------------------------------------------------------
 NOTICE                               |  4 +---
 geode-assembly/src/main/dist/LICENSE | 30 ------------------------------
 2 files changed, 1 insertion(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/a2f47b72/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 13a30d3..d27ae96 100644
--- a/NOTICE
+++ b/NOTICE
@@ -18,6 +18,4 @@ Copyright 2016 AddThis
    Copyright 2014 The Apache Software Foundation
 
 This product includes software developed by the MX4J
-project (http://mx4j.sourceforge.net).
-
-This project includes software licensed under the JSON license.
+project (http://mx4j.sourceforge.net).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/a2f47b72/geode-assembly/src/main/dist/LICENSE
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/LICENSE b/geode-assembly/src/main/dist/LICENSE
index a00b0c3..2f2de95 100644
--- a/geode-assembly/src/main/dist/LICENSE
+++ b/geode-assembly/src/main/dist/LICENSE
@@ -595,36 +595,6 @@ Federal Courts of the Northern District of California and the state courts
 of the State of California, with venue lying in Santa Clara County,
 California.
 
-
----------------------------------------------------------------------------
-The JSON License (http://www.json.org/license.html)
----------------------------------------------------------------------------
-
-Apache Geode bundles the following file under the JSON license:
-
-  - JSON (http://www.json.org), Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-
-
 ---------------------------------------------------------------------------
 The MIT License (http://opensource.org/licenses/mit-license.html)
 ---------------------------------------------------------------------------


[21/51] [abbrv] geode git commit: GEODE-2404: Added support for destroying lucene indexes

Posted by ds...@apache.org.
GEODE-2404: Added support for destroying lucene indexes


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/11521a82
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/11521a82
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/11521a82

Branch: refs/heads/feature/GEM-1195
Commit: 11521a824f31ff03db13d0e59cb0fbf29e592151
Parents: c4a5ab2
Author: Barry Oglesby <bo...@pivotal.io>
Authored: Mon Feb 13 17:01:13 2017 -0800
Committer: Barry Oglesby <bo...@pivotal.io>
Committed: Mon Feb 27 10:06:48 2017 -0800

----------------------------------------------------------------------
 .../internal/AsyncEventQueueImpl.java           |   9 +
 .../geode/internal/DataSerializableFixedID.java |   2 +-
 .../geode/internal/i18n/LocalizedStrings.java   |   4 +
 .../geode/cache/lucene/LuceneService.java       |  14 +-
 .../internal/DestroyLuceneIndexMessage.java     | 109 ++++++++
 .../lucene/internal/InternalLuceneIndex.java    |   5 +
 .../LuceneIndexForPartitionedRegion.java        | 109 +++++++-
 .../cache/lucene/internal/LuceneIndexImpl.java  |  16 ++
 .../cache/lucene/internal/LuceneRawIndex.java   |   2 +
 .../lucene/internal/LuceneServiceImpl.java      |  57 ++++-
 .../lucene/internal/cli/LuceneCliStrings.java   |  28 ++-
 .../cli/LuceneFunctionSerializable.java         |  36 +++
 .../internal/cli/LuceneIndexCommands.java       | 113 +++++++--
 .../lucene/internal/cli/LuceneIndexDetails.java |  16 +-
 .../lucene/internal/cli/LuceneIndexInfo.java    |  15 +-
 .../lucene/internal/cli/LuceneQueryInfo.java    |  15 +-
 .../functions/LuceneDestroyIndexFunction.java   |  57 +++++
 .../lucene/LuceneIndexDestroyDUnitTest.java     | 247 +++++++++++++++++++
 .../cli/LuceneIndexCommandsDUnitTest.java       |  50 +++-
 .../cli/LuceneIndexCommandsJUnitTest.java       |  53 ++++
 .../LuceneDestroyIndexFunctionJUnitTest.java    |  93 +++++++
 .../LuceneClusterConfigurationDUnitTest.java    |  99 +++++++-
 22 files changed, 1068 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java b/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java
index 3b99f1c..a44b9e4 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/asyncqueue/internal/AsyncEventQueueImpl.java
@@ -25,6 +25,7 @@ import org.apache.geode.cache.wan.GatewayEventFilter;
 import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter;
 import org.apache.geode.cache.wan.GatewaySender;
 import org.apache.geode.cache.wan.GatewaySender.OrderPolicy;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.RegionQueue;
 import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
 import org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor;
@@ -191,8 +192,16 @@ public class AsyncEventQueueImpl implements AsyncEventQueue {
     return ((AbstractGatewaySender) sender).getIsMetaQueue();
   }
 
+  public void stop() {
+    if (this.sender.isRunning()) {
+      this.sender.stop();
+    }
+  }
+
   public void destroy() {
+    GemFireCacheImpl gfci = (GemFireCacheImpl) ((AbstractGatewaySender) this.sender).getCache();
     this.sender.destroy();
+    gfci.removeAsyncEventQueue(this);
   }
 
   public boolean isBucketSorted() {

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
index 74e40e9..4e45646 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
@@ -809,8 +809,8 @@ public interface DataSerializableFixedID extends SerializationVersions {
   public static final short LUCENE_ENTRY_SCORE = 2174;
   public static final short LUCENE_TOP_ENTRIES = 2175;
   public static final short LUCENE_TOP_ENTRIES_COLLECTOR = 2176;
-
   public static final short WAIT_UNTIL_FLUSHED_FUNCTION_CONTEXT = 2177;
+  public static final short DESTROY_LUCENE_INDEX_MESSAGE = 2178;
 
   // NOTE, codes > 65535 will take 4 bytes to serialize
 

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
index d855e29..fa63437 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
@@ -7674,6 +7674,10 @@ public class LocalizedStrings {
       new StringId(6650,
           "Caught the following exception attempting waitUntilFlushed and will return:");
 
+  public static final StringId LuceneService_INDEX_0_NOT_FOUND_IN_REGION_1 =
+      new StringId(6651, "Lucene index {0} was not found in region {1}.");
+  public static final StringId LuceneService_DESTROYED_INDEX_0_FROM_REGION_1 =
+      new StringId(6652, "Destroyed Lucene index {0} from region {1}.");
   /** Testing strings, messageId 90000-99999 **/
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
index d273760..5cfae59 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/LuceneService.java
@@ -101,10 +101,18 @@ public interface LuceneService {
 
   /**
    * Destroy the lucene index
-   * 
-   * @param index index object
+   *
+   * @param indexName the name of the index to destroy
+   * @param regionPath the path of the region whose index to destroy
+   */
+  public void destroyIndex(String indexName, String regionPath);
+
+  /**
+   * Destroy all the lucene indexes for the region
+   *
+   * @param regionPath The path of the region on which to destroy the indexes
    */
-  public void destroyIndex(LuceneIndex index);
+  public void destroyIndexes(String regionPath);
 
   /**
    * Get the lucene index object specified by region name and index name

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/DestroyLuceneIndexMessage.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/DestroyLuceneIndexMessage.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/DestroyLuceneIndexMessage.java
new file mode 100644
index 0000000..8bdef9b
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/DestroyLuceneIndexMessage.java
@@ -0,0 +1,109 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal;
+
+import org.apache.geode.DataSerializer;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.lucene.LuceneServiceProvider;
+import org.apache.geode.distributed.internal.*;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.logging.log4j.Logger;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Collection;
+
+public class DestroyLuceneIndexMessage extends PooledDistributionMessage
+    implements MessageWithReply {
+
+  private int processorId;
+
+  private String regionPath;
+
+  private String indexName;
+
+  private static final Logger logger = LogService.getLogger();
+
+  /* For serialization */
+  public DestroyLuceneIndexMessage() {}
+
+  protected DestroyLuceneIndexMessage(Collection recipients, int processorId, String regionPath,
+      String indexName) {
+    super();
+    setRecipients(recipients);
+    this.processorId = processorId;
+    this.regionPath = regionPath;
+    this.indexName = indexName;
+  }
+
+  @Override
+  protected void process(DistributionManager dm) {
+    ReplyException replyException = null;
+    try {
+      if (logger.isDebugEnabled()) {
+        logger.debug("DestroyLuceneIndexMessage: Destroying regionPath=" + this.regionPath
+            + "; indexName=" + this.indexName);
+      }
+      try {
+        Cache cache = GemFireCacheImpl.getInstance();
+        LuceneServiceImpl impl = (LuceneServiceImpl) LuceneServiceProvider.get(cache);
+        impl.destroyIndex(this.indexName, this.regionPath, false);
+        if (logger.isDebugEnabled()) {
+          logger.debug("DestroyLuceneIndexMessage: Destroyed regionPath=" + this.regionPath
+              + "; indexName=" + this.indexName);
+        }
+      } catch (Throwable e) {
+        replyException = new ReplyException(e);
+        if (logger.isDebugEnabled()) {
+          logger.debug(
+              "DestroyLuceneIndexMessage: Caught the following exception attempting to destroy indexName="
+                  + this.indexName + "; regionPath=" + this.regionPath + ":",
+              e);
+        }
+      }
+    } finally {
+      ReplyMessage replyMsg = new ReplyMessage();
+      replyMsg.setRecipient(getSender());
+      replyMsg.setProcessorId(this.processorId);
+      if (replyException != null) {
+        replyMsg.setException(replyException);
+      }
+      dm.putOutgoing(replyMsg);
+    }
+  }
+
+  @Override
+  public int getDSFID() {
+    return DESTROY_LUCENE_INDEX_MESSAGE;
+  }
+
+  @Override
+  public void toData(DataOutput out) throws IOException {
+    super.toData(out);
+    out.writeInt(this.processorId);
+    DataSerializer.writeString(this.regionPath, out);
+    DataSerializer.writeString(this.indexName, out);
+  }
+
+  @Override
+  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
+    super.fromData(in);
+    this.processorId = in.readInt();
+    this.regionPath = DataSerializer.readString(in);
+    this.indexName = DataSerializer.readString(in);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
index 2800f49..c28fcdc 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
@@ -27,4 +27,9 @@ public interface InternalLuceneIndex extends LuceneIndex {
    */
   public void dumpFiles(String directory);
 
+  /**
+   * Destroy the index
+   */
+  public void destroy(boolean initiator);
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index 9a39b39..f45d94d 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -15,6 +15,7 @@
 
 package org.apache.geode.cache.lucene.internal;
 
+import org.apache.geode.CancelException;
 import org.apache.geode.cache.AttributesFactory;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.FixedPartitionResolver;
@@ -24,6 +25,7 @@ import org.apache.geode.cache.PartitionResolver;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.lucene.internal.directory.DumpDirectoryFiles;
@@ -36,15 +38,23 @@ import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
 import org.apache.geode.cache.lucene.internal.repository.serializer.HeterogeneousLuceneSerializer;
 import org.apache.geode.cache.partition.PartitionListener;
 import org.apache.geode.distributed.internal.DM;
+import org.apache.geode.distributed.internal.ReplyException;
+import org.apache.geode.distributed.internal.ReplyProcessor21;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.PartitionedRegion;
 
+import java.util.Set;
+
 /* wrapper of IndexWriter */
 public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
   protected Region<String, File> fileRegion;
   protected Region<ChunkKey, byte[]> chunkRegion;
   protected final FileSystemStats fileSystemStats;
 
+  public static final String FILES_REGION_SUFFIX = ".files";
+  public static final String CHUNKS_REGION_SUFFIX = ".chunks";
+
   public LuceneIndexForPartitionedRegion(String indexName, String regionPath, Cache cache) {
     super(indexName, regionPath, cache);
 
@@ -123,7 +133,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
   }
 
   public String createFileRegionName() {
-    return LuceneServiceImpl.getUniqueIndexName(indexName, regionPath) + ".files";
+    return LuceneServiceImpl.getUniqueIndexRegionName(indexName, regionPath, FILES_REGION_SUFFIX);
   }
 
   boolean chunkRegionExists(String chunkRegionName) {
@@ -139,7 +149,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
   }
 
   public String createChunkRegionName() {
-    return LuceneServiceImpl.getUniqueIndexName(indexName, regionPath) + ".chunks";
+    return LuceneServiceImpl.getUniqueIndexRegionName(indexName, regionPath, CHUNKS_REGION_SUFFIX);
   }
 
   private PartitionAttributesFactory configureLuceneRegionAttributesFactory(
@@ -192,4 +202,99 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
         .withArgs(new String[] {directory, indexName}).execute(DumpDirectoryFiles.ID);
     results.getResult();
   }
+
+  @Override
+  public void destroy(boolean initiator) {
+    if (logger.isDebugEnabled()) {
+      logger.debug("Destroying index regionPath=" + regionPath + "; indexName=" + indexName
+          + "; initiator=" + initiator);
+    }
+
+    // Invoke super destroy to remove the extension
+    super.destroy(initiator);
+
+    // Destroy the AsyncEventQueue
+    PartitionedRegion pr = (PartitionedRegion) getDataRegion();
+    destroyAsyncEventQueue(pr);
+
+    // Destroy the chunk region (colocated with the file region)
+    // localDestroyRegion can't be used because locally destroying regions is not supported on
+    // colocated regions
+    if (!chunkRegion.isDestroyed()) {
+      chunkRegion.destroyRegion();
+      if (logger.isDebugEnabled()) {
+        logger.debug("Destroyed chunkRegion=" + chunkRegion.getName());
+      }
+    }
+
+    // Destroy the file region (colocated with the application region)
+    // localDestroyRegion can't be used because locally destroying regions is not supported on
+    // colocated regions
+    if (!fileRegion.isDestroyed()) {
+      fileRegion.destroyRegion();
+      if (logger.isDebugEnabled()) {
+        logger.debug("Destroyed fileRegion=" + fileRegion.getName());
+      }
+    }
+
+    // Destroy index on remote members if necessary
+    if (initiator) {
+      destroyOnRemoteMembers(pr);
+    }
+
+    if (logger.isDebugEnabled()) {
+      logger.debug("Destroyed index regionPath=" + regionPath + "; indexName=" + indexName
+          + "; initiator=" + initiator);
+    }
+  }
+
+  private void destroyAsyncEventQueue(PartitionedRegion pr) {
+    String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, regionPath);
+
+    // Get the AsyncEventQueue
+    AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
+
+    // Stop the AsyncEventQueue (this stops the AsyncEventQueue's underlying GatewaySender)
+    aeq.stop();
+
+    // Remove the id from the dataRegion's AsyncEventQueue ids
+    // Note: The region may already have been destroyed by a remote member
+    if (!pr.isDestroyed()) {
+      pr.getAttributesMutator().removeAsyncEventQueueId(aeqId);
+    }
+
+    // Destroy the aeq (this also removes it from the GemFireCacheImpl)
+    aeq.destroy();
+    if (logger.isDebugEnabled()) {
+      logger.debug("Destroyed aeqId=" + aeqId);
+    }
+  }
+
+  private void destroyOnRemoteMembers(PartitionedRegion pr) {
+    DM dm = pr.getDistributionManager();
+    Set<InternalDistributedMember> recipients = pr.getRegionAdvisor().adviseDataStore();
+    if (!recipients.isEmpty()) {
+      if (logger.isDebugEnabled()) {
+        logger.debug("LuceneIndexForPartitionedRegion: About to send destroy message recipients="
+            + recipients);
+      }
+      ReplyProcessor21 processor = new ReplyProcessor21(dm, recipients);
+      DestroyLuceneIndexMessage message = new DestroyLuceneIndexMessage(recipients,
+          processor.getProcessorId(), regionPath, indexName);
+      dm.putOutgoing(message);
+      if (logger.isDebugEnabled()) {
+        logger.debug("LuceneIndexForPartitionedRegion: Sent message recipients=" + recipients);
+      }
+      try {
+        processor.waitForReplies();
+      } catch (ReplyException e) {
+        if (!(e.getCause() instanceof CancelException)) {
+          throw e;
+        }
+      } catch (InterruptedException e) {
+        dm.getCancelCriterion().checkCancelInProgress(e);
+        Thread.currentThread().interrupt();
+      }
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
index 42ccc84..cf519be 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
@@ -20,6 +20,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.geode.internal.cache.extension.Extension;
 import org.apache.logging.log4j.Logger;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -203,6 +204,21 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
     dataRegion.getExtensionPoint().addExtension(creation);
   }
 
+  public void destroy(boolean initiator) {
+    // Find and delete the appropriate extension
+    Extension extensionToDelete = null;
+    for (Extension extension : getDataRegion().getExtensionPoint().getExtensions()) {
+      LuceneIndexCreation index = (LuceneIndexCreation) extension;
+      if (index.getName().equals(indexName)) {
+        extensionToDelete = extension;
+        break;
+      }
+    }
+    if (extensionToDelete != null) {
+      getDataRegion().getExtensionPoint().removeExtension(extensionToDelete);
+    }
+  }
+
   protected <K, V> Region<K, V> createRegion(final String regionName,
       final RegionAttributes<K, V> attributes) {
     // Create InternalRegionArguments to set isUsedForMetaRegion true to suppress xml generation

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
index a4e48ad..f4518aa 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
@@ -36,4 +36,6 @@ public class LuceneRawIndex extends LuceneIndexImpl {
     return;
   }
 
+  @Override
+  public void destroy(boolean initiator) {}
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index cf7b2c9..a608dd9 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -114,6 +114,11 @@ public class LuceneServiceImpl implements InternalLuceneService {
     return name;
   }
 
+  public static String getUniqueIndexRegionName(String indexName, String regionPath,
+      String regionSuffix) {
+    return getUniqueIndexName(indexName, regionPath) + regionSuffix;
+  }
+
   @Override
   public void createIndex(String indexName, String regionPath, String... fields) {
     if (fields == null || fields.length == 0) {
@@ -256,10 +261,53 @@ public class LuceneServiceImpl implements InternalLuceneService {
   }
 
   @Override
-  public void destroyIndex(LuceneIndex index) {
-    LuceneIndexImpl indexImpl = (LuceneIndexImpl) index;
+  public void destroyIndex(String indexName, String regionPath) {
+    destroyIndex(indexName, regionPath, true);
+  }
+
+  protected void destroyIndex(String indexName, String regionPath, boolean initiator) {
+    if (!regionPath.startsWith("/")) {
+      regionPath = "/" + regionPath;
+    }
+    LuceneIndexImpl indexImpl = (LuceneIndexImpl) getIndex(indexName, regionPath);
+    if (indexImpl == null) {
+      throw new IllegalArgumentException(
+          LocalizedStrings.LuceneService_INDEX_0_NOT_FOUND_IN_REGION_1.toLocalizedString(indexName,
+              regionPath));
+    } else {
+      indexImpl.destroy(initiator);
+      removeFromIndexMap(indexImpl);
+      logger.info(LocalizedStrings.LuceneService_DESTROYED_INDEX_0_FROM_REGION_1
+          .toLocalizedString(indexName, regionPath));
+    }
+  }
+
+  @Override
+  public void destroyIndexes(String regionPath) {
+    destroyIndexes(regionPath, true);
+  }
+
+  protected void destroyIndexes(String regionPath, boolean initiator) {
+    if (!regionPath.startsWith("/")) {
+      regionPath = "/" + regionPath;
+    }
+    List<LuceneIndexImpl> indexesToDestroy = new ArrayList<>();
+    for (LuceneIndex index : getAllIndexes()) {
+      if (index.getRegionPath().equals(regionPath)) {
+        LuceneIndexImpl indexImpl = (LuceneIndexImpl) index;
+        indexImpl.destroy(initiator);
+        indexesToDestroy.add(indexImpl);
+      }
+    }
+    for (LuceneIndex index : indexesToDestroy) {
+      removeFromIndexMap(index);
+      logger.info(LocalizedStrings.LuceneService_DESTROYED_INDEX_0_FROM_REGION_1
+          .toLocalizedString(index.getName(), regionPath));
+    }
+  }
+
+  private void removeFromIndexMap(LuceneIndex index) {
     indexMap.remove(getUniqueIndexName(index.getName(), index.getRegionPath()));
-    // indexImpl.close();
   }
 
   @Override
@@ -320,6 +368,9 @@ public class LuceneServiceImpl implements InternalLuceneService {
 
     DSFIDFactory.registerDSFID(DataSerializableFixedID.WAIT_UNTIL_FLUSHED_FUNCTION_CONTEXT,
         WaitUntilFlushedFunctionContext.class);
+
+    DSFIDFactory.registerDSFID(DataSerializableFixedID.DESTROY_LUCENE_INDEX_MESSAGE,
+        DestroyLuceneIndexMessage.class);
   }
 
   public Collection<LuceneIndexCreationProfile> getAllDefinedIndexes() {

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneCliStrings.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneCliStrings.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneCliStrings.java
index 36f5aeb..fbb70d2 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneCliStrings.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneCliStrings.java
@@ -37,7 +37,7 @@ public class LuceneCliStrings {
   public static final String LUCENE_CREATE_INDEX__NAME__HELP =
       "Name of the lucene index to create.";
   public static final String LUCENE_CREATE_INDEX__REGION_HELP =
-      "Name/Path of the region where the lucene index is created on.";
+      "Name/Path of the region on which to create the lucene index.";
   public static final String LUCENE_CREATE_INDEX__FIELD = "field";
   public static final String LUCENE_CREATE_INDEX__FIELD_HELP =
       "fields on the region values which are stored in the lucene index.";
@@ -61,14 +61,13 @@ public class LuceneCliStrings {
   // Describe lucene index commands
   public static final String LUCENE_DESCRIBE_INDEX = "describe lucene index";
   public static final String LUCENE_DESCRIBE_INDEX__HELP =
-      "Display the describe of lucene indexes created for all members.";
+      "Display the description of lucene indexes created for all members.";
   public static final String LUCENE_DESCRIBE_INDEX__ERROR_MESSAGE =
       "An error occurred while collecting lucene index information across the Geode cluster: %1$s";
   public static final String LUCENE_DESCRIBE_INDEX__NAME__HELP =
       "Name of the lucene index to describe.";
   public static final String LUCENE_DESCRIBE_INDEX__REGION_HELP =
-      "Name/Path of the region where the lucene index to be described exists.";
-
+      "Name/Path of the region defining the lucene index to be described.";
 
   // Search lucene index commands
   public static final String LUCENE_SEARCH_INDEX = "search lucene";
@@ -78,7 +77,7 @@ public class LuceneCliStrings {
   public static final String LUCENE_SEARCH_INDEX__NAME__HELP =
       "Name of the lucene index to search.";
   public static final String LUCENE_SEARCH_INDEX__REGION_HELP =
-      "Name/Path of the region where the lucene index exists.";
+      "Name/Path of the region defining the lucene index to be searched.";
   public static final String LUCENE_SEARCH_INDEX__QUERY_STRING = "queryStrings";
   public static final String LUCENE_SEARCH_INDEX__LIMIT = "limit";
   public static final String LUCENE_SEARCH_INDEX__LIMIT__HELP = "Number of search results needed";
@@ -95,4 +94,23 @@ public class LuceneCliStrings {
   public static final String LUCENE_SEARCH_INDEX__KEYSONLY__HELP =
       "Return only keys of search results.";
 
+  // Destroy lucene index command
+  public static final String LUCENE_DESTROY_INDEX = "destroy lucene index";
+  public static final String LUCENE_DESTROY_INDEX__HELP = "Destroy the lucene index.";
+  public static final String LUCENE_DESTROY_INDEX__EXCEPTION_MESSAGE =
+      "An unexpected exception occurred while destroying lucene index:";
+  public static final String LUCENE_DESTROY_INDEX__NAME__HELP =
+      "Name of the lucene index to destroy.";
+  public static final String LUCENE_DESTROY_INDEX__REGION_HELP =
+      "Name of the region defining the lucene index to be destroyed.";
+  public static final String LUCENE_DESTROY_INDEX__MSG__REGION_CANNOT_BE_EMPTY =
+      "Region cannot be empty.";
+  public static final String LUCENE_DESTROY_INDEX__MSG__INDEX_CANNOT_BE_EMPTY =
+      "Index cannot be empty.";
+  public static final String LUCENE_DESTROY_INDEX__MSG__COULDNOT_FIND_MEMBERS_FOR_REGION_0 =
+      "Could not find any members defining region {0}.";
+  public static final String LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FOR_REGION_0 =
+      "Successfully destroyed all lucene indexes for region {0}";
+  public static final String LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FOR_REGION_1 =
+      "Successfully destroyed lucene index {0} for region {1}";
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneFunctionSerializable.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneFunctionSerializable.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneFunctionSerializable.java
new file mode 100644
index 0000000..1390e22
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneFunctionSerializable.java
@@ -0,0 +1,36 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.cli;
+
+import java.io.Serializable;
+
+public class LuceneFunctionSerializable implements Serializable {
+
+  protected final String indexName;
+  protected final String regionPath;
+
+  public LuceneFunctionSerializable(final String indexName, final String regionPath) {
+    this.indexName = indexName;
+    this.regionPath = regionPath;
+  }
+
+  public String getIndexName() {
+    return indexName;
+  }
+
+  public String getRegionPath() {
+    return regionPath;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
index b84246c..e2d85a6 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -16,16 +16,12 @@ package org.apache.geode.cache.lucene.internal.cli;
 
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.execute.Execution;
-import org.apache.geode.cache.execute.FunctionAdapter;
-import org.apache.geode.cache.execute.FunctionInvocationTargetException;
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.cache.lucene.internal.cli.functions.LuceneCreateIndexFunction;
-import org.apache.geode.cache.lucene.internal.cli.functions.LuceneDescribeIndexFunction;
-import org.apache.geode.cache.lucene.internal.cli.functions.LuceneListIndexFunction;
-import org.apache.geode.cache.lucene.internal.cli.functions.LuceneSearchIndexFunction;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.execute.*;
+import org.apache.geode.cache.lucene.internal.cli.functions.*;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
+import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.security.IntegratedSecurityService;
 import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.management.cli.CliMetaData;
@@ -70,6 +66,8 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
       new LuceneDescribeIndexFunction();
   private static final LuceneSearchIndexFunction searchIndexFunction =
       new LuceneSearchIndexFunction();
+  private static final LuceneDestroyIndexFunction destroyIndexFunction =
+      new LuceneDestroyIndexFunction();
   private List<LuceneSearchResults> searchResults = null;
 
   private SecurityService securityService = IntegratedSecurityService.getSecurityService();
@@ -316,6 +314,74 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
     }
   }
 
+  @CliCommand(value = LuceneCliStrings.LUCENE_DESTROY_INDEX,
+      help = LuceneCliStrings.LUCENE_DESTROY_INDEX__HELP)
+  @CliMetaData(shellOnly = false,
+      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
+  public Result destroyIndex(
+      @CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = false,
+          help = LuceneCliStrings.LUCENE_DESTROY_INDEX__NAME__HELP) final String indexName,
+
+      @CliOption(key = LuceneCliStrings.LUCENE__REGION_PATH, mandatory = true,
+          optionContext = ConverterHint.REGIONPATH,
+          help = LuceneCliStrings.LUCENE_DESTROY_INDEX__REGION_HELP) final String regionPath) {
+    if (StringUtils.isBlank(regionPath) || regionPath.equals(Region.SEPARATOR)) {
+      return ResultBuilder.createInfoResult(
+          CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__REGION_CANNOT_BE_EMPTY));
+    }
+
+    if (StringUtils.isEmpty(indexName)) {
+      return ResultBuilder.createInfoResult(
+          CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__INDEX_CANNOT_BE_EMPTY));
+    }
+
+    this.securityService.authorizeRegionManage(regionPath);
+
+    Result result = null;
+    try {
+      LuceneIndexInfo indexInfo = new LuceneIndexInfo(indexName, regionPath);
+      ResultCollector<?, ?> rc = executeFunction(destroyIndexFunction, indexInfo, false);
+      List<CliFunctionResult> functionResults = (List<CliFunctionResult>) rc.getResult();
+      CliFunctionResult cliFunctionResult = functionResults.get(0);
+
+      final TabularResultData tabularResult = ResultBuilder.createTabularResultData();
+      tabularResult.accumulate("Member", cliFunctionResult.getMemberIdOrName());
+      if (cliFunctionResult.isSuccessful()) {
+        tabularResult.accumulate("Status",
+            indexName == null
+                ? CliStrings.format(
+                    LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FOR_REGION_0,
+                    new Object[] {regionPath})
+                : CliStrings.format(
+                    LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FOR_REGION_1,
+                    new Object[] {indexName, regionPath}));
+      } else {
+        tabularResult.accumulate("Status", "Failed: " + cliFunctionResult.getMessage());
+      }
+      result = ResultBuilder.buildResult(tabularResult);
+      if (cliFunctionResult.isSuccessful()) {
+        persistClusterConfiguration(result, () -> {
+          // Update the xml entity (region entity) to remove the async event id(s) and index(es)
+          getSharedConfiguration().addXmlEntity((XmlEntity) cliFunctionResult.getXmlEntity(), null);
+        });
+      }
+    } catch (FunctionInvocationTargetException ignore) {
+      result = ResultBuilder.createGemFireErrorResult(CliStrings.format(
+          CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN, LuceneCliStrings.LUCENE_DESTROY_INDEX));
+    } catch (VirtualMachineError e) {
+      SystemFailure.initiateFailure(e);
+      throw e;
+    } catch (IllegalArgumentException e) {
+      result = ResultBuilder.createInfoResult(e.getMessage());
+    } catch (Throwable t) {
+      SystemFailure.checkFailure();
+      getCache().getLogger().warning(LuceneCliStrings.LUCENE_DESTROY_INDEX__EXCEPTION_MESSAGE, t);
+      result = ResultBuilder.createGemFireErrorResult(t.getMessage());
+    }
+    return result;
+  }
+
   private Result displayResults(int pageSize, boolean keysOnly) throws Exception {
     if (searchResults.size() == 0) {
       return ResultBuilder
@@ -428,25 +494,30 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
 
   protected ResultCollector<?, ?> executeFunctionOnGroups(FunctionAdapter function, String[] groups,
       final LuceneIndexInfo indexInfo) throws IllegalArgumentException, CommandResultException {
-    final Set<DistributedMember> targetMembers;
+    ResultCollector<?, ?> results = null;
     if (function != createIndexFunction) {
-      targetMembers =
-          CliUtil.getMembersForeRegionViaFunction(getCache(), indexInfo.getRegionPath(), true);
-      if (targetMembers.isEmpty()) {
-        throw new IllegalArgumentException("Region not found.");
-      }
+      results = executeFunction(function, indexInfo, true);
     } else {
-      targetMembers = CliUtil.findMembersOrThrow(groups, null);
+      Set<DistributedMember> targetMembers = CliUtil.findMembersOrThrow(groups, null);
+      results = CliUtil.executeFunction(function, indexInfo, targetMembers);
     }
-    return CliUtil.executeFunction(function, indexInfo, targetMembers);
+    return results;
   }
 
   protected ResultCollector<?, ?> executeSearch(final LuceneQueryInfo queryInfo) throws Exception {
-    final Set<DistributedMember> targetMembers =
-        CliUtil.getMembersForeRegionViaFunction(getCache(), queryInfo.getRegionPath(), false);
-    if (targetMembers.isEmpty())
-      throw new IllegalArgumentException("Region not found.");
-    return CliUtil.executeFunction(searchIndexFunction, queryInfo, targetMembers);
+    return executeFunction(searchIndexFunction, queryInfo, false);
+  }
+
+  protected ResultCollector<?, ?> executeFunction(Function function,
+      LuceneFunctionSerializable functionArguments, boolean returnAllMembers) {
+    Set<DistributedMember> targetMembers = CliUtil.getMembersForeRegionViaFunction(getCache(),
+        functionArguments.getRegionPath(), returnAllMembers);
+    if (targetMembers.isEmpty()) {
+      throw new IllegalArgumentException(CliStrings.format(
+          LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__COULDNOT_FIND_MEMBERS_FOR_REGION_0,
+          new Object[] {functionArguments.getRegionPath()}));
+    }
+    return CliUtil.executeFunction(function, functionArguments, targetMembers);
   }
 
   @CliAvailabilityIndicator({LuceneCliStrings.LUCENE_SEARCH_INDEX,

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
index 02a19a1..b2b0466 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
@@ -29,10 +29,9 @@ import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
 
 import org.apache.lucene.analysis.Analyzer;
 
-public class LuceneIndexDetails implements Comparable<LuceneIndexDetails>, Serializable {
+public class LuceneIndexDetails extends LuceneFunctionSerializable
+    implements Comparable<LuceneIndexDetails> {
   private static final long serialVersionUID = 1L;
-  private final String indexName;
-  private final String regionPath;
   private final String serverName;
   private final String[] searchableFieldNames;
   private Map<String, String> fieldAnalyzers = null;
@@ -42,8 +41,7 @@ public class LuceneIndexDetails implements Comparable<LuceneIndexDetails>, Seria
   public LuceneIndexDetails(final String indexName, final String regionPath,
       final String[] searchableFieldNames, final Map<String, Analyzer> fieldAnalyzers,
       LuceneIndexStats indexStats, boolean initialized, final String serverName) {
-    this.indexName = indexName;
-    this.regionPath = regionPath;
+    super(indexName, regionPath);
     this.serverName = serverName;
     this.searchableFieldNames = searchableFieldNames;
     this.fieldAnalyzers = getFieldAnalyzerStrings(fieldAnalyzers);
@@ -141,14 +139,6 @@ public class LuceneIndexDetails implements Comparable<LuceneIndexDetails>, Seria
     return initialized;
   }
 
-  public String getIndexName() {
-    return indexName;
-  }
-
-  public String getRegionPath() {
-    return regionPath;
-  }
-
   private static <T extends Comparable<T>> int compare(final T obj1, final T obj2) {
     return (obj1 == null && obj2 == null ? 0
         : (obj1 == null ? 1 : (obj2 == null ? -1 : obj1.compareTo(obj2))));

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java
index b714ff1..41b066e 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java
@@ -24,18 +24,15 @@ import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
 
 import org.apache.lucene.analysis.Analyzer;
 
-public class LuceneIndexInfo implements Serializable {
+public class LuceneIndexInfo extends LuceneFunctionSerializable {
   private static final long serialVersionUID = 1L;
 
-  private final String indexName;
-  private final String regionPath;
   private final String[] searchableFieldNames;
   private final String[] fieldAnalyzers;
 
   public LuceneIndexInfo(final String indexName, final String regionPath,
       final String[] searchableFieldNames, String[] fieldAnalyzers) {
-    this.indexName = indexName;
-    this.regionPath = regionPath;
+    super(indexName, regionPath);
     this.searchableFieldNames = searchableFieldNames;
     this.fieldAnalyzers = fieldAnalyzers;
   }
@@ -44,14 +41,6 @@ public class LuceneIndexInfo implements Serializable {
     this(indexName, regionPath, null, null);
   }
 
-  public String getIndexName() {
-    return indexName;
-  }
-
-  public String getRegionPath() {
-    return regionPath;
-  }
-
   public String[] getSearchableFieldNames() {
     return searchableFieldNames;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneQueryInfo.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneQueryInfo.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneQueryInfo.java
index 8d34e2e..e57badb 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneQueryInfo.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneQueryInfo.java
@@ -19,10 +19,8 @@ import java.io.Serializable;
 
 import org.apache.geode.cache.lucene.LuceneQueryFactory;
 
-public class LuceneQueryInfo implements Serializable {
+public class LuceneQueryInfo extends LuceneFunctionSerializable {
   private static final long serialVersionUID = 1L;
-  private String indexName;
-  private String regionPath;
   private String queryString;
   private String defaultField;
   private int limit;
@@ -30,22 +28,13 @@ public class LuceneQueryInfo implements Serializable {
 
   public LuceneQueryInfo(final String indexName, final String regionPath, final String queryString,
       final String defaultField, final int limit, final boolean keysOnly) {
-    this.indexName = indexName;
-    this.regionPath = regionPath;
+    super(indexName, regionPath);
     this.queryString = queryString;
     this.defaultField = defaultField;
     this.limit = limit;
     this.keysOnly = keysOnly;
   }
 
-  public String getIndexName() {
-    return indexName;
-  }
-
-  public String getRegionPath() {
-    return regionPath;
-  }
-
   public String getQueryString() {
     return queryString;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDestroyIndexFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDestroyIndexFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDestroyIndexFunction.java
new file mode 100644
index 0000000..1535637
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDestroyIndexFunction.java
@@ -0,0 +1,57 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.cli.functions;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.lucene.LuceneService;
+import org.apache.geode.cache.lucene.LuceneServiceProvider;
+import org.apache.geode.cache.lucene.internal.cli.LuceneIndexInfo;
+import org.apache.geode.internal.InternalEntity;
+import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+
+public class LuceneDestroyIndexFunction implements Function, InternalEntity {
+
+  public void execute(final FunctionContext context) {
+    String memberId = getCache().getDistributedSystem().getDistributedMember().getId();
+    try {
+      LuceneIndexInfo indexInfo = (LuceneIndexInfo) context.getArguments();
+      String indexName = indexInfo.getIndexName();
+      String regionPath = indexInfo.getRegionPath();
+      LuceneService service = LuceneServiceProvider.get(getCache());
+      if (indexName == null) {
+        service.destroyIndexes(regionPath);
+      } else {
+        service.destroyIndex(indexName, regionPath);
+      }
+      context.getResultSender()
+          .lastResult(new CliFunctionResult(memberId, getXmlEntity(regionPath)));
+    } catch (Exception e) {
+      context.getResultSender().lastResult(new CliFunctionResult(memberId, e, e.getMessage()));
+    }
+  }
+
+  protected XmlEntity getXmlEntity(String regionPath) {
+    return new XmlEntity(CacheXml.REGION, "name", regionPath);
+  }
+
+  protected Cache getCache() {
+    return CacheFactory.getAnyInstance();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
new file mode 100644
index 0000000..6260075
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexDestroyDUnitTest.java
@@ -0,0 +1,247 @@
+/*
+ * 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 org.apache.geode.cache.lucene;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion;
+import org.apache.geode.cache.lucene.internal.LuceneServiceImpl;
+import org.apache.geode.cache.lucene.test.TestObject;
+import org.apache.geode.internal.cache.LocalRegion;
+import org.apache.geode.test.dunit.AsyncInvocation;
+import org.apache.geode.test.dunit.SerializableRunnableIF;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.awaitility.Awaitility;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
+import static org.apache.geode.internal.Assert.fail;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+@Category(DistributedTest.class)
+@RunWith(JUnitParamsRunner.class)
+public class LuceneIndexDestroyDUnitTest extends LuceneDUnitTest {
+
+  private volatile boolean STOP_PUTS = false;
+
+  private final Object[] parametersForIndexDestroys() {
+    String[] destroyDataRegionParameters = {"true", "false"};
+    RegionTestableType[] regionTestTypes = getListOfRegionTestTypes();
+    return parameterCombiner(destroyDataRegionParameters, regionTestTypes);
+  }
+
+  @Test
+  @Parameters(method = "parametersForIndexDestroys")
+  public void verifyDestroySingleIndex(boolean destroyDataRegion, RegionTestableType regionType) {
+    // Create index and region
+    dataStore1.invoke(() -> initDataStore(createIndex(), regionType));
+    dataStore2.invoke(() -> initDataStore(createIndex(), regionType));
+
+    // Verify index created
+    dataStore1.invoke(() -> verifyIndexCreated());
+    dataStore2.invoke(() -> verifyIndexCreated());
+
+    // Attempt to destroy data region (should fail)
+    if (destroyDataRegion) {
+      dataStore1.invoke(() -> destroyDataRegion(false));
+    }
+
+    // Destroy index (only needs to be done on one member)
+    dataStore1.invoke(() -> destroyIndex());
+
+    // Verify index destroyed
+    dataStore1.invoke(() -> verifyIndexDestroyed());
+    dataStore2.invoke(() -> verifyIndexDestroyed());
+
+    // Attempt to destroy data region (should succeed)
+    if (destroyDataRegion) {
+      dataStore1.invoke(() -> destroyDataRegion(true));
+    }
+  }
+
+  @Test
+  @Parameters(method = "parametersForIndexDestroys")
+  public void verifyDestroyAllIndexes(boolean destroyDataRegion, RegionTestableType regionType) {
+    // Create indexes and region
+    dataStore1.invoke(() -> initDataStore(createIndexes(), regionType));
+    dataStore2.invoke(() -> initDataStore(createIndexes(), regionType));
+
+    // Verify indexes created
+    dataStore1.invoke(() -> verifyIndexesCreated());
+    dataStore2.invoke(() -> verifyIndexesCreated());
+
+    // Attempt to destroy data region (should fail)
+    if (destroyDataRegion) {
+      dataStore1.invoke(() -> destroyDataRegion(false));
+    }
+
+    // Destroy indexes (only needs to be done on one member)
+    dataStore1.invoke(() -> destroyIndexes());
+
+    // Verify indexes destroyed
+    dataStore1.invoke(() -> verifyIndexesDestroyed());
+    dataStore2.invoke(() -> verifyIndexesDestroyed());
+
+    // Attempt to destroy data region (should succeed)
+    if (destroyDataRegion) {
+      dataStore1.invoke(() -> destroyDataRegion(true));
+    }
+  }
+
+  @Ignore
+  // Destroying an index while puts are occurring currently fails with a
+  // GatewaySenderConfigurationException.
+  @Parameters(method = "getListOfServerRegionTestTypes")
+  public void verifyDestroySingleIndexWhileDoingPuts(RegionTestableType regionType)
+      throws Exception {
+    // Create index and region
+    dataStore1.invoke(() -> initDataStore(createIndex(), regionType));
+    dataStore2.invoke(() -> initDataStore(createIndex(), regionType));
+
+    // Verify index created
+    dataStore1.invoke(() -> verifyIndexCreated());
+    dataStore2.invoke(() -> verifyIndexCreated());
+
+    // Start puts
+    AsyncInvocation putter = dataStore1.invokeAsync(() -> doPuts());
+
+    // Wait until puts have started
+    dataStore1.invoke(() -> waitUntilPutsHaveStarted());
+
+    // Destroy index (only needs to be done on one member)
+    dataStore1.invoke(() -> destroyIndex());
+
+    // Verify index destroyed
+    dataStore1.invoke(() -> verifyIndexDestroyed());
+    dataStore2.invoke(() -> verifyIndexDestroyed());
+
+    // End puts
+    dataStore1.invoke(() -> stopPuts());
+    putter.join();
+  }
+
+
+  private SerializableRunnableIF createIndex() {
+    return () -> {
+      LuceneService luceneService = LuceneServiceProvider.get(getCache());
+      luceneService.createIndex(INDEX_NAME, REGION_NAME, "text");
+    };
+  }
+
+  private SerializableRunnableIF createIndexes() {
+    return () -> {
+      LuceneService luceneService = LuceneServiceProvider.get(getCache());
+      luceneService.createIndex(INDEX_NAME + "0", REGION_NAME, "text");
+      luceneService.createIndex(INDEX_NAME + "1", REGION_NAME, "text");
+    };
+  }
+
+  private void verifyIndexCreated() {
+    LuceneService luceneService = LuceneServiceProvider.get(getCache());
+    assertNotNull(luceneService.getIndex(INDEX_NAME, REGION_NAME));
+  }
+
+  private void verifyIndexesCreated() {
+    LuceneService luceneService = LuceneServiceProvider.get(getCache());
+    assertNotNull(luceneService.getIndex(INDEX_NAME + "0", REGION_NAME));
+    assertNotNull(luceneService.getIndex(INDEX_NAME + "1", REGION_NAME));
+  }
+
+  private void doPuts() throws Exception {
+    Region region = getCache().getRegion(REGION_NAME);
+    int i = 0;
+    while (!STOP_PUTS) {
+      region.put(i++, new TestObject());
+      // Thread.sleep(50);
+    }
+  }
+
+  private void stopPuts() {
+    STOP_PUTS = true;
+  }
+
+  private void waitUntilPutsHaveStarted() {
+    Awaitility.waitAtMost(30, TimeUnit.SECONDS)
+        .until(() -> getCache().getRegion(REGION_NAME).size() > 0);
+  }
+
+  private void destroyDataRegion(boolean shouldSucceed) {
+    Region region = getCache().getRegion(REGION_NAME);
+    assertNotNull(region);
+    try {
+      region.destroyRegion();
+      if (!shouldSucceed) {
+        fail("should not have been able to destroy data region named " + region.getFullPath());
+      }
+    } catch (IllegalStateException e) {
+      if (shouldSucceed) {
+        fail(e);
+      }
+    }
+  }
+
+  private void destroyIndex() {
+    LuceneService luceneService = LuceneServiceProvider.get(getCache());
+    luceneService.destroyIndex(INDEX_NAME, REGION_NAME);
+  }
+
+  private void destroyIndexes() {
+    LuceneService luceneService = LuceneServiceProvider.get(getCache());
+    luceneService.destroyIndexes(REGION_NAME);
+  }
+
+  private void verifyIndexDestroyed() {
+    verifyIndexDestroyed(INDEX_NAME);
+  }
+
+  private void verifyIndexesDestroyed() {
+    verifyIndexDestroyed(INDEX_NAME + "0");
+    verifyIndexDestroyed(INDEX_NAME + "1");
+  }
+
+  private void verifyIndexDestroyed(String indexName) {
+    LuceneService luceneService = LuceneServiceProvider.get(getCache());
+
+    // Verify the index itself no longer exists
+    assertNull(luceneService.getIndex(indexName, REGION_NAME));
+
+    // Verify the underlying files region no longer exists
+    String filesRegionName = LuceneServiceImpl.getUniqueIndexRegionName(indexName, REGION_NAME,
+        LuceneIndexForPartitionedRegion.FILES_REGION_SUFFIX);
+    assertNull(getCache().getRegion(filesRegionName));
+
+    // Verify the underlying chunks region no longer exists
+    String chunksRegionName = LuceneServiceImpl.getUniqueIndexRegionName(indexName, REGION_NAME,
+        LuceneIndexForPartitionedRegion.CHUNKS_REGION_SUFFIX);
+    assertNull(getCache().getRegion(chunksRegionName));
+
+    // Verify the underlying AsyncEventQueue no longer exists
+    String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, REGION_NAME);
+    assertNull(getCache().getAsyncEventQueue(aeqId));
+
+    // Verify the data region extension no longer exists
+    LocalRegion region = (LocalRegion) getCache().getRegion(REGION_NAME);
+    assertFalse(region.getExtensionPoint().getExtensions().iterator().hasNext());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
index 49aa057..efc11ab 100755
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
@@ -28,6 +28,7 @@ import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.cli.Result.Status;
 import org.apache.geode.management.internal.cli.CommandManager;
 import org.apache.geode.management.internal.cli.commands.CliCommandTestBase;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
@@ -349,7 +350,7 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase {
     csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "notAnIndex");
     csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
     String resultAsString = executeCommandAndLogResult(csb);
-    assertTrue(resultAsString.contains("Region not found"));
+    assertTrue(resultAsString.contains(getRegionNotFoundErrorMessage(REGION_NAME)));
   }
 
   @Test
@@ -498,7 +499,7 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase {
     csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field2");
 
     String resultAsString = executeCommandAndLogResult(csb);
-    assertTrue(resultAsString.contains("Region not found"));
+    assertTrue(resultAsString.contains(getRegionNotFoundErrorMessage(REGION_NAME)));
   }
 
   @Test
@@ -552,6 +553,45 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase {
 
   }
 
+  @Test
+  public void destroySingleIndexOnRegion() throws Exception {
+    final VM vm1 = Host.getHost(0).getVM(1);
+    createIndex(vm1);
+    CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance());
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    String resultAsString = executeCommandAndLogResult(csb);
+    String expectedStatus = CliStrings.format(
+        LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FOR_REGION_1,
+        new Object[] {INDEX_NAME, REGION_NAME});
+    assertTrue(resultAsString.contains(expectedStatus));
+  }
+
+  @Test
+  public void destroyAllIndexesOnRegion() throws Exception {
+    final VM vm1 = Host.getHost(0).getVM(1);
+    createIndex(vm1);
+    CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance());
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    String resultAsString = executeCommandAndLogResult(csb);
+    String expectedStatus = CliStrings.format(
+        LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FOR_REGION_0,
+        new Object[] {REGION_NAME});
+    assertTrue(resultAsString.contains(expectedStatus));
+  }
+
+  @Test
+  public void destroyIndexWithoutRegionShouldReturnError() throws Exception {
+    final VM vm1 = Host.getHost(0).getVM(1);
+    createIndexWithoutRegion(vm1);
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    String resultAsString = executeCommandAndLogResult(csb);
+    assertTrue(resultAsString.contains(getRegionNotFoundErrorMessage(REGION_NAME)));
+  }
+
   private void createRegion() {
     getCache().createRegionFactory(RegionShortcut.PARTITION).create(REGION_NAME);
   }
@@ -628,6 +668,12 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase {
     });
   }
 
+  private String getRegionNotFoundErrorMessage(String regionPath) {
+    return CliStrings.format(
+        LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__COULDNOT_FIND_MEMBERS_FOR_REGION_0,
+        new Object[] {regionPath});
+  }
+
   protected class TestObject implements Serializable {
     private String field1;
     private String field2;

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
index 6ddef9e..9e8d7a9 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -41,6 +42,7 @@ import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
 import org.apache.geode.cache.lucene.internal.cli.functions.LuceneCreateIndexFunction;
 import org.apache.geode.cache.lucene.internal.cli.functions.LuceneDescribeIndexFunction;
+import org.apache.geode.cache.lucene.internal.cli.functions.LuceneDestroyIndexFunction;
 import org.apache.geode.cache.lucene.internal.cli.functions.LuceneListIndexFunction;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
@@ -401,6 +403,57 @@ public class LuceneIndexCommandsJUnitTest {
     assertEquals(queryResults.size(), data.retrieveAllValues("key").size());
   }
 
+  @Test
+  public void testDestroySingleIndexOnRegion() throws Exception {
+    LuceneIndexCommands commands = createTestLuceneIndexCommandsForDestroyIndex();
+    String indexName = "index";
+    String regionPath = "regionPath";
+    CommandResult result = (CommandResult) commands.destroyIndex(indexName, regionPath);
+    String expectedMember = "member";
+    String expectedStatus = CliStrings.format(
+        LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FOR_REGION_1,
+        new Object[] {indexName, regionPath});
+    verifyDestroyIndexCommandResult(result, expectedMember, expectedStatus);
+  }
+
+  @Test
+  public void testDestroyAllIndexesOnRegion() throws Exception {
+    LuceneIndexCommands commands = createTestLuceneIndexCommandsForDestroyIndex();
+    String indexName = null;
+    String regionPath = "regionPath";
+    CommandResult result = (CommandResult) commands.destroyIndex(indexName, regionPath);
+    String expectedMember = "member";
+    String expectedStatus = CliStrings.format(
+        LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FOR_REGION_0,
+        new Object[] {regionPath});
+    verifyDestroyIndexCommandResult(result, expectedMember, expectedStatus);
+  }
+
+  private LuceneIndexCommands createTestLuceneIndexCommandsForDestroyIndex() {
+    final Cache mockCache = mock(Cache.class);
+    final ResultCollector mockResultCollector = mock(ResultCollector.class);
+    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
+
+    final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
+    cliFunctionResults.add(new CliFunctionResult("member", true, "Index Destroyed"));
+
+    doReturn(mockResultCollector).when(commands).executeFunction(
+        isA(LuceneDestroyIndexFunction.class), any(LuceneIndexInfo.class), eq(false));
+    doReturn(cliFunctionResults).when(mockResultCollector).getResult();
+    return commands;
+  }
+
+  private void verifyDestroyIndexCommandResult(CommandResult result, String expectedMember,
+      String expectedStatus) {
+    assertEquals(Status.OK, result.getStatus());
+    TabularResultData data = (TabularResultData) result.getResultData();
+    List<String> members = data.retrieveAllValues("Member");
+    List<String> status = data.retrieveAllValues("Status");
+    assertTrue(members.size() == 1);
+    assertEquals(expectedMember, members.get(0));
+    assertEquals(expectedStatus, status.get(0));
+  }
+
   private String getPage(final LuceneSearchResults[] expectedResults, int[] indexList) {
     final TabularResultData data = ResultBuilder.createTabularResultData();
     for (int i : indexList) {

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDestroyIndexFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDestroyIndexFunctionJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDestroyIndexFunctionJUnitTest.java
new file mode 100644
index 0000000..f86f4a1
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDestroyIndexFunctionJUnitTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.cli.functions;
+
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.cache.lucene.internal.InternalLuceneService;
+import org.apache.geode.cache.lucene.internal.cli.LuceneIndexInfo;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+import org.apache.geode.test.fake.Fakes;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.ArgumentCaptor;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.*;
+
+@Category(UnitTest.class)
+public class LuceneDestroyIndexFunctionJUnitTest {
+
+  private InternalLuceneService service;
+  private GemFireCacheImpl cache;
+  private String member;
+  private FunctionContext context;
+  private ResultSender resultSender;
+
+  @Before
+  public void prepare() {
+    this.cache = Fakes.cache();
+    this.member = Fakes.distributedSystem().getDistributedMember().getId();
+    this.service = mock(InternalLuceneService.class);
+    when(this.cache.getService(InternalLuceneService.class)).thenReturn(this.service);
+    this.context = mock(FunctionContext.class);
+    this.resultSender = mock(ResultSender.class);
+    when(this.context.getResultSender()).thenReturn(this.resultSender);
+  }
+
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testExecuteWithRegionAndIndex() throws Throwable {
+    LuceneIndexInfo indexInfo = new LuceneIndexInfo("index1", "/region1");
+    when(this.context.getArguments()).thenReturn(indexInfo);
+    LuceneDestroyIndexFunction function = new LuceneDestroyIndexFunction();
+    function = spy(function);
+    doReturn(this.cache).when(function).getCache();
+    doReturn(mock(XmlEntity.class)).when(function).getXmlEntity(any());
+    function.execute(this.context);
+    verify(this.service).destroyIndex(eq("index1"), eq("/region1"));
+    verify(this.service, never()).destroyIndexes(eq("/region1"));
+    ArgumentCaptor<CliFunctionResult> resultCaptor =
+        ArgumentCaptor.forClass(CliFunctionResult.class);
+    verify(resultSender).lastResult(resultCaptor.capture());
+    CliFunctionResult result = resultCaptor.getValue();
+    assertEquals(this.member, result.getMemberIdOrName());
+    assertEquals(true, result.isSuccessful());
+  }
+
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testExecuteWithRegion() throws Throwable {
+    LuceneIndexInfo indexInfo = new LuceneIndexInfo(null, "/region1");
+    when(this.context.getArguments()).thenReturn(indexInfo);
+    LuceneDestroyIndexFunction function = new LuceneDestroyIndexFunction();
+    function = spy(function);
+    doReturn(this.cache).when(function).getCache();
+    doReturn(mock(XmlEntity.class)).when(function).getXmlEntity(any());
+    function.execute(this.context);
+    verify(this.service).destroyIndexes(eq("/region1"));
+    verify(this.service, never()).destroyIndex(any(), eq("/region1"));
+    ArgumentCaptor<CliFunctionResult> resultCaptor =
+        ArgumentCaptor.forClass(CliFunctionResult.class);
+    verify(resultSender).lastResult(resultCaptor.capture());
+    CliFunctionResult result = resultCaptor.getValue();
+    assertEquals(this.member, result.getMemberIdOrName());
+    assertEquals(true, result.isSuccessful());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/11521a82/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
index 875422c..1a344db 100755
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java
@@ -17,10 +17,7 @@ package org.apache.geode.cache.lucene.internal.configuration;
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
 
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.lucene.LuceneIndex;
@@ -28,9 +25,14 @@ import org.apache.geode.cache.lucene.LuceneService;
 import org.apache.geode.cache.lucene.LuceneServiceProvider;
 import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
 import org.apache.geode.cache.lucene.internal.cli.LuceneIndexCommands;
+import org.apache.geode.cache.lucene.internal.xml.LuceneXmlConstants;
+import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.management.internal.cli.CommandManager;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.management.internal.configuration.domain.Configuration;
+import org.apache.geode.test.dunit.SerializableRunnableIF;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
@@ -231,6 +233,78 @@ public class LuceneClusterConfigurationDUnitTest {
     });
   }
 
+  @Test
+  public void verifyClusterConfigurationAfterDestroyIndex() throws Exception {
+    Member vm1 = startNodeUsingClusterConfiguration(1, false);
+
+    // Connect Gfsh to locator.
+    gfshConnector.connectAndVerify(locator);
+
+    // Create and add indexes
+    createAndAddIndexes();
+
+    // Destroy one index
+    destroyLuceneIndexUsingGfsh(INDEX_NAME + "0");
+
+    // Destroy other index
+    destroyLuceneIndexUsingGfsh(INDEX_NAME + "1");
+
+    // Verify cluster configuration no longer contains any indexes
+    locator.invoke(verifyClusterConfiguration(false));
+  }
+
+  @Test
+  public void verifyClusterConfigurationAfterDestroyIndexes() throws Exception {
+    Member vm1 = startNodeUsingClusterConfiguration(1, false);
+
+    // Connect Gfsh to locator.
+    gfshConnector.connectAndVerify(locator);
+
+    // Create and add indexes
+    createAndAddIndexes();
+
+    // Destroy all indexes
+    destroyLuceneIndexUsingGfsh(null);
+
+    // Verify cluster configuration no longer contains indexes
+    locator.invoke(verifyClusterConfiguration(false));
+  }
+
+  private void createAndAddIndexes() throws Exception {
+    // Create lucene index.
+    createLuceneIndexUsingGfsh(INDEX_NAME + "0", false);
+
+    // Create another lucene index.
+    createLuceneIndexUsingGfsh(INDEX_NAME + "1", false);
+
+    // Create region
+    createRegionUsingGfsh(REGION_NAME, RegionShortcut.PARTITION, null);
+
+    // Verify cluster configuration contains the indexes
+    locator.invoke(verifyClusterConfiguration(true));
+  }
+
+  private SerializableRunnableIF verifyClusterConfiguration(boolean verifyIndexesExist) {
+    return () -> {
+      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
+      ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
+      Configuration config = sc.getConfiguration(ClusterConfigurationService.CLUSTER_CONFIG);
+      String xmlContent = config.getCacheXmlContent();
+      String luceneIndex0Config = "<" + LuceneXmlConstants.PREFIX + ":" + LuceneXmlConstants.INDEX
+          + " xmlns:lucene=\"" + LuceneXmlConstants.NAMESPACE + "\" " + LuceneXmlConstants.NAME
+          + "=\"" + INDEX_NAME + "0" + "\">";
+      String luceneIndex1Config = "<" + LuceneXmlConstants.PREFIX + ":" + LuceneXmlConstants.INDEX
+          + " xmlns:lucene=\"" + LuceneXmlConstants.NAMESPACE + "\" " + LuceneXmlConstants.NAME
+          + "=\"" + INDEX_NAME + "1" + "\">";
+      if (verifyIndexesExist) {
+        assertTrue(xmlContent.contains(luceneIndex0Config));
+        assertTrue(xmlContent.contains(luceneIndex1Config));
+      } else {
+        assertFalse(xmlContent.contains(luceneIndex0Config));
+        assertFalse(xmlContent.contains(luceneIndex1Config));
+      }
+    };
+  }
 
   private Member startNodeUsingClusterConfiguration(int vmIndex, boolean addGroup)
       throws Exception {
@@ -242,10 +316,14 @@ public class LuceneClusterConfigurationDUnitTest {
   }
 
   private void createLuceneIndexUsingGfsh(boolean addGroup) throws Exception {
+    createLuceneIndexUsingGfsh(INDEX_NAME, addGroup);
+  }
+
+  private void createLuceneIndexUsingGfsh(String indexName, boolean addGroup) throws Exception {
     // Execute Gfsh command to create lucene index.
     CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance());
     CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, indexName);
     csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
     if (addGroup) {
       csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__GROUP, groupName);
@@ -273,6 +351,17 @@ public class LuceneClusterConfigurationDUnitTest {
     gfshConnector.executeAndVerifyCommand(csb.toString());
   }
 
+  private void destroyLuceneIndexUsingGfsh(String indexName) throws Exception {
+    // Execute Gfsh command to destroy lucene index.
+    CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance());
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
+    if (indexName != null) {
+      csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, indexName);
+    }
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    gfshConnector.executeAndVerifyCommand(csb.toString());
+  }
+
   private void createRegionUsingGfsh(String regionName, RegionShortcut regionShortCut, String group)
       throws Exception {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);


[18/51] [abbrv] geode git commit: GEODE-2142: Removing JSON licence stuff from NOTICE files

Posted by ds...@apache.org.
GEODE-2142: Removing JSON licence stuff from NOTICE files


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/f2262d13
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/f2262d13
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/f2262d13

Branch: refs/heads/feature/GEM-1195
Commit: f2262d13a81c59918f06a78c1073c76062e7f238
Parents: abeaa24
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed Feb 22 15:41:45 2017 -0800
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Mon Feb 27 07:19:32 2017 -0800

----------------------------------------------------------------------
 geode-assembly/src/main/dist/NOTICE           | 2 --
 geode-pulse/src/main/webapp/META-INF/NOTICE   | 2 --
 geode-web-api/src/main/webapp/META-INF/NOTICE | 2 --
 geode-web/src/main/webapp/META-INF/NOTICE     | 2 --
 4 files changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f2262d13/geode-assembly/src/main/dist/NOTICE
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/NOTICE b/geode-assembly/src/main/dist/NOTICE
index 097bd7f..2cdda71 100644
--- a/geode-assembly/src/main/dist/NOTICE
+++ b/geode-assembly/src/main/dist/NOTICE
@@ -20,8 +20,6 @@ Copyright 2016 AddThis
 This product includes software developed by the MX4J
 project (http://mx4j.sourceforge.net).
 
-This project includes software licensed under the JSON license.
-
 Java ClassMate library was originally written by Tatu Saloranta (tatu.saloranta@iki.fi)
 
   Other developers who have contributed code are:

http://git-wip-us.apache.org/repos/asf/geode/blob/f2262d13/geode-pulse/src/main/webapp/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/webapp/META-INF/NOTICE b/geode-pulse/src/main/webapp/META-INF/NOTICE
index dbbba76..166a9ee 100644
--- a/geode-pulse/src/main/webapp/META-INF/NOTICE
+++ b/geode-pulse/src/main/webapp/META-INF/NOTICE
@@ -20,8 +20,6 @@ Copyright 2016 AddThis
 This product includes software developed by the MX4J
 project (http://mx4j.sourceforge.net).
 
-This project includes software licensed under the JSON license.
-
 Jackson Core 2.8.0
 
   # Jackson JSON processor

http://git-wip-us.apache.org/repos/asf/geode/blob/f2262d13/geode-web-api/src/main/webapp/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/webapp/META-INF/NOTICE b/geode-web-api/src/main/webapp/META-INF/NOTICE
index 67ccc2c..8e1775b 100644
--- a/geode-web-api/src/main/webapp/META-INF/NOTICE
+++ b/geode-web-api/src/main/webapp/META-INF/NOTICE
@@ -20,8 +20,6 @@ Copyright 2016 AddThis
 This product includes software developed by the MX4J
 project (http://mx4j.sourceforge.net).
 
-This project includes software licensed under the JSON license.
-
 Java ClassMate library was originally written by Tatu Saloranta (tatu.saloranta@iki.fi)
 
   Other developers who have contributed code are:

http://git-wip-us.apache.org/repos/asf/geode/blob/f2262d13/geode-web/src/main/webapp/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/geode-web/src/main/webapp/META-INF/NOTICE b/geode-web/src/main/webapp/META-INF/NOTICE
index 2591148..8a36d55 100644
--- a/geode-web/src/main/webapp/META-INF/NOTICE
+++ b/geode-web/src/main/webapp/META-INF/NOTICE
@@ -20,8 +20,6 @@ Copyright 2016 AddThis
 This product includes software developed by the MX4J
 project (http://mx4j.sourceforge.net).
 
-This project includes software licensed under the JSON license.
-
 Spring Framework 4.3.6.RELEASE
 Copyright (c) 2002-2017 Pivotal, Inc.
 


[12/51] [abbrv] geode git commit: GEODE-2142: spotless

Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/eac0bb8c/geode-json/src/test/java/org/json/JSONObjectTest.java
----------------------------------------------------------------------
diff --git a/geode-json/src/test/java/org/json/JSONObjectTest.java b/geode-json/src/test/java/org/json/JSONObjectTest.java
index 393a2d0..c795551 100755
--- a/geode-json/src/test/java/org/json/JSONObjectTest.java
+++ b/geode-json/src/test/java/org/json/JSONObjectTest.java
@@ -1,17 +1,15 @@
 /*
  * Copyright (C) 2010 The Android Open Source Project
  *
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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 org.json;
@@ -43,1156 +41,1150 @@ import static org.junit.Assert.*;
  * This black box test was written without inspecting the non-free org.json sourcecode.
  */
 public class JSONObjectTest {
-    @Test
-    public void testKeyset() throws Exception {
-        JSONObject x = new JSONObject("{'a':1, 'b':2, 'c':3}");
-        Set<String> k = new TreeSet<String>();
-        for (String kx : Arrays.asList("a", "b", "c")) {
-            k.add(kx);
-        }
-        assertEquals(x.keySet(), k);
-        x = new JSONObject("{}");
-        assertEquals(x.keySet().size(), 0);
-    }
-
-    @Test
-    public void testEmptyObject() throws JSONException {
-        JSONObject object = new JSONObject();
-        assertEquals(0, object.length());
-
-        // bogus (but documented) behaviour: returns null rather than the empty object!
-        assertNull(object.names());
-
-        // returns null rather than an empty array!
-        assertNull(object.toJSONArray(new JSONArray()));
-        assertEquals("{}", object.toString());
-        assertEquals("{}", object.toString(5));
-        try {
-            object.get("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.getBoolean("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.getDouble("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.getInt("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.getJSONArray("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.getJSONObject("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.getLong("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.getString("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertFalse(object.has("foo"));
-        assertTrue(object.isNull("foo")); // isNull also means "is not present"
-        assertNull(object.opt("foo"));
-        assertEquals(false, object.optBoolean("foo"));
-        assertEquals(true, object.optBoolean("foo", true));
-        assertEquals(Double.NaN, object.optDouble("foo"), 0);
-        assertEquals(5.0, object.optDouble("foo", 5.0), 0);
-        assertEquals(0, object.optInt("foo"));
-        assertEquals(5, object.optInt("foo", 5));
-        assertEquals(null, object.optJSONArray("foo"));
-        assertEquals(null, object.optJSONObject("foo"));
-        assertEquals(0, object.optLong("foo"));
-        assertEquals(Long.MAX_VALUE - 1, object.optLong("foo", Long.MAX_VALUE - 1));
-        assertEquals("", object.optString("foo")); // empty string is default!
-        assertEquals("bar", object.optString("foo", "bar"));
-        assertNull(object.remove("foo"));
-    }
-
-    @Test
-    public void testEqualsAndHashCode() throws JSONException {
-        JSONObject a = new JSONObject();
-        JSONObject b = new JSONObject();
-
-        // JSON object doesn't override either equals or hashCode (!)
-        assertFalse(a.equals(b));
-        assertEquals(a.hashCode(), System.identityHashCode(a));
-    }
-
-    @Test
-    public void testGet() throws JSONException {
-        JSONObject object = new JSONObject();
-        Object value = new Object();
-        object.put("foo", value);
-        object.put("bar", new Object());
-        object.put("baz", new Object());
-        assertSame(value, object.get("foo"));
-        try {
-            object.get("FOO");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.put(null, value);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.get(null);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testPut() throws JSONException {
-        JSONObject object = new JSONObject();
-        assertSame(object, object.put("foo", true));
-        object.put("foo", false);
-        assertEquals(false, object.get("foo"));
-
-        object.put("foo", 5.0d);
-        assertEquals(5.0d, object.get("foo"));
-        object.put("foo", 0);
-        assertEquals(0, object.get("foo"));
-        object.put("bar", Long.MAX_VALUE - 1);
-        assertEquals(Long.MAX_VALUE - 1, object.get("bar"));
-        object.put("baz", "x");
-        assertEquals("x", object.get("baz"));
-        object.put("bar", JSONObject.NULL);
-        assertSame(JSONObject.NULL, object.get("bar"));
-    }
-
-    @Test
-    public void testPutNullRemoves() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", "bar");
-        object.put("foo", null);
-        assertEquals(0, object.length());
-        assertFalse(object.has("foo"));
-        try {
-            object.get("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testPutOpt() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", "bar");
-        object.putOpt("foo", null);
-        assertEquals("bar", object.get("foo"));
-        object.putOpt(null, null);
-        assertEquals(1, object.length());
-        object.putOpt(null, "bar");
-        assertEquals(1, object.length());
-    }
-
-    @Test
-    public void testPutOptUnsupportedNumbers() throws JSONException {
-        JSONObject object = new JSONObject();
-        try {
-            object.putOpt("foo", Double.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.putOpt("foo", Double.NEGATIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.putOpt("foo", Double.POSITIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testRemove() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", "bar");
-        assertEquals(null, object.remove(null));
-        assertEquals(null, object.remove(""));
-        assertEquals(null, object.remove("bar"));
-        assertEquals("bar", object.remove("foo"));
-        assertEquals(null, object.remove("foo"));
-    }
-
-    @Test
-    public void testBooleans() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", true);
-        object.put("bar", false);
-        object.put("baz", "true");
-        object.put("quux", "false");
-        assertEquals(4, object.length());
-        assertEquals(true, object.getBoolean("foo"));
-        assertEquals(false, object.getBoolean("bar"));
-        assertEquals(true, object.getBoolean("baz"));
-        assertEquals(false, object.getBoolean("quux"));
-        assertFalse(object.isNull("foo"));
-        assertFalse(object.isNull("quux"));
-        assertTrue(object.has("foo"));
-        assertTrue(object.has("quux"));
-        assertFalse(object.has("missing"));
-        assertEquals(true, object.optBoolean("foo"));
-        assertEquals(false, object.optBoolean("bar"));
-        assertEquals(true, object.optBoolean("baz"));
-        assertEquals(false, object.optBoolean("quux"));
-        assertEquals(false, object.optBoolean("missing"));
-        assertEquals(true, object.optBoolean("foo", true));
-        assertEquals(false, object.optBoolean("bar", true));
-        assertEquals(true, object.optBoolean("baz", true));
-        assertEquals(false, object.optBoolean("quux", true));
-        assertEquals(true, object.optBoolean("missing", true));
-
-        object.put("foo", "truE");
-        object.put("bar", "FALSE");
-        assertEquals(true, object.getBoolean("foo"));
-        assertEquals(false, object.getBoolean("bar"));
-        assertEquals(true, object.optBoolean("foo"));
-        assertEquals(false, object.optBoolean("bar"));
-        assertEquals(true, object.optBoolean("foo", false));
-        assertEquals(false, object.optBoolean("bar", false));
-    }
-
-    // http://code.google.com/p/android/issues/detail?id=16411
-    @Test
-    public void testCoerceStringToBoolean() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", "maybe");
-        try {
-            object.getBoolean("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals(false, object.optBoolean("foo"));
-        assertEquals(true, object.optBoolean("foo", true));
-    }
-
-    @Test
-    public void testNumbers() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", Double.MIN_VALUE);
-        object.put("bar", 9223372036854775806L);
-        object.put("baz", Double.MAX_VALUE);
-        object.put("quux", -0d);
-        assertEquals(4, object.length());
-
-        String toString = object.toString();
-        assertTrue(toString, toString.contains("\"foo\":4.9E-324"));
-        assertTrue(toString, toString.contains("\"bar\":9223372036854775806"));
-        assertTrue(toString, toString.contains("\"baz\":1.7976931348623157E308"));
-
-        // toString() and getString() return different values for -0d!
-        assertTrue(toString, toString.contains("\"quux\":-0}") // no trailing decimal point
-                || toString.contains("\"quux\":-0,"));
-
-        assertEquals(Double.MIN_VALUE, object.get("foo"));
-        assertEquals(9223372036854775806L, object.get("bar"));
-        assertEquals(Double.MAX_VALUE, object.get("baz"));
-        assertEquals(-0d, object.get("quux"));
-        assertEquals(Double.MIN_VALUE, object.getDouble("foo"), 0);
-        assertEquals(9.223372036854776E18, object.getDouble("bar"), 0);
-        assertEquals(Double.MAX_VALUE, object.getDouble("baz"), 0);
-        assertEquals(-0d, object.getDouble("quux"), 0);
-        assertEquals(0, object.getLong("foo"));
-        assertEquals(9223372036854775806L, object.getLong("bar"));
-        assertEquals(Long.MAX_VALUE, object.getLong("baz"));
-        assertEquals(0, object.getLong("quux"));
-        assertEquals(0, object.getInt("foo"));
-        assertEquals(-2, object.getInt("bar"));
-        assertEquals(Integer.MAX_VALUE, object.getInt("baz"));
-        assertEquals(0, object.getInt("quux"));
-        assertEquals(Double.MIN_VALUE, object.opt("foo"));
-        assertEquals(9223372036854775806L, object.optLong("bar"));
-        assertEquals(Double.MAX_VALUE, object.optDouble("baz"), 0);
-        assertEquals(0, object.optInt("quux"));
-        assertEquals(Double.MIN_VALUE, object.opt("foo"));
-        assertEquals(9223372036854775806L, object.optLong("bar"));
-        assertEquals(Double.MAX_VALUE, object.optDouble("baz"), 0);
-        assertEquals(0, object.optInt("quux"));
-        assertEquals(Double.MIN_VALUE, object.optDouble("foo", 5.0d), 0);
-        assertEquals(9223372036854775806L, object.optLong("bar", 1L));
-        assertEquals(Long.MAX_VALUE, object.optLong("baz", 1L));
-        assertEquals(0, object.optInt("quux", -1));
-        assertEquals("4.9E-324", object.getString("foo"));
-        assertEquals("9223372036854775806", object.getString("bar"));
-        assertEquals("1.7976931348623157E308", object.getString("baz"));
-        assertEquals("-0.0", object.getString("quux"));
-    }
-
-    @Test
-    public void testFloats() throws JSONException {
-        JSONObject object = new JSONObject();
-        try {
-            object.put("foo", (Float) Float.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.put("foo", (Float) Float.NEGATIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.put("foo", (Float) Float.POSITIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testOtherNumbers() throws JSONException {
-        Number nan = new Number() {
-            public int intValue() {
-                throw new UnsupportedOperationException();
-            }
-
-            public long longValue() {
-                throw new UnsupportedOperationException();
-            }
-
-            public float floatValue() {
-                throw new UnsupportedOperationException();
-            }
-
-            public double doubleValue() {
-                return Double.NaN;
-            }
-
-            @Override
-            public String toString() {
-                return "x";
-            }
-        };
-
-        JSONObject object = new JSONObject();
-        try {
-            object.put("foo", nan);
-            fail("Object.put() accepted a NaN (via a custom Number class)");
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testForeignObjects() throws JSONException {
-        Object foreign = new Object() {
-            @Override
-            public String toString() {
-                return "x";
-            }
-        };
-
-        // foreign object types are accepted and treated as Strings!
-        JSONObject object = new JSONObject();
-        object.put("foo", foreign);
-        assertEquals("{\"foo\":\"x\"}", object.toString());
-    }
-
-    @Test
-    public void testNullKeys() {
-        try {
-            new JSONObject().put(null, false);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONObject().put(null, 0.0d);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONObject().put(null, 5);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONObject().put(null, 5L);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            new JSONObject().put(null, "foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testStrings() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", "true");
-        object.put("bar", "5.5");
-        object.put("baz", "9223372036854775806");
-        object.put("quux", "null");
-        object.put("height", "5\"8' tall");
-
-        assertTrue(object.toString().contains("\"foo\":\"true\""));
-        assertTrue(object.toString().contains("\"bar\":\"5.5\""));
-        assertTrue(object.toString().contains("\"baz\":\"9223372036854775806\""));
-        assertTrue(object.toString().contains("\"quux\":\"null\""));
-        assertTrue(object.toString().contains("\"height\":\"5\\\"8' tall\""));
-
-        assertEquals("true", object.get("foo"));
-        assertEquals("null", object.getString("quux"));
-        assertEquals("5\"8' tall", object.getString("height"));
-        assertEquals("true", object.opt("foo"));
-        assertEquals("5.5", object.optString("bar"));
-        assertEquals("true", object.optString("foo", "x"));
-        assertFalse(object.isNull("foo"));
-
-        assertEquals(true, object.getBoolean("foo"));
-        assertEquals(true, object.optBoolean("foo"));
-        assertEquals(true, object.optBoolean("foo", false));
-        assertEquals(0, object.optInt("foo"));
-        assertEquals(-2, object.optInt("foo", -2));
-
-        assertEquals(5.5d, object.getDouble("bar"), 0);
-        assertEquals(5L, object.getLong("bar"));
-        assertEquals(5, object.getInt("bar"));
-        assertEquals(5, object.optInt("bar", 3));
-
-        // The last digit of the string is a 6 but getLong returns a 7. It's probably parsing as a
-        // double and then converting that to a long. This is consistent with JavaScript.
-        assertEquals(9223372036854775807L, object.getLong("baz"));
-        assertEquals(9.223372036854776E18, object.getDouble("baz"), 0);
-        assertEquals(Integer.MAX_VALUE, object.getInt("baz"));
-
-        assertFalse(object.isNull("quux"));
-        try {
-            object.getDouble("quux");
-            fail();
-        } catch (JSONException e) {
-            // expected
-        }
-        assertEquals(Double.NaN, object.optDouble("quux"), 0);
-        assertEquals(-1.0d, object.optDouble("quux", -1.0d), 0);
-
-        object.put("foo", "TRUE");
-        assertEquals(true, object.getBoolean("foo"));
-    }
-
-    @Test
-    public void testJSONObjects() throws JSONException {
-        JSONObject object = new JSONObject();
-
-        JSONArray a = new JSONArray();
-        JSONObject b = new JSONObject();
-        object.put("foo", a);
-        object.put("bar", b);
-
-        assertSame(a, object.getJSONArray("foo"));
-        assertSame(b, object.getJSONObject("bar"));
-        try {
-            object.getJSONObject("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.getJSONArray("bar");
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals(a, object.optJSONArray("foo"));
-        assertEquals(b, object.optJSONObject("bar"));
-        assertEquals(null, object.optJSONArray("bar"));
-        assertEquals(null, object.optJSONObject("foo"));
-    }
-
-    @Test
-    public void testNullCoercionToString() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", JSONObject.NULL);
-        assertEquals("null", object.getString("foo"));
-    }
-
-    @Test
-    public void testArrayCoercion() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", "[true]");
-        try {
-            object.getJSONArray("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testObjectCoercion() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", "{}");
-        try {
-            object.getJSONObject("foo");
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testAccumulateValueChecking() throws JSONException {
-        JSONObject object = new JSONObject();
-        try {
-            object.accumulate("foo", Double.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        object.accumulate("foo", 1);
-        try {
-            object.accumulate("foo", Double.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        object.accumulate("foo", 2);
-        try {
-            object.accumulate("foo", Double.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testToJSONArray() throws JSONException {
-        JSONObject object = new JSONObject();
-        Object value = new Object();
-        object.put("foo", true);
-        object.put("bar", 5.0d);
-        object.put("baz", -0.0d);
-        object.put("quux", value);
-
-        JSONArray names = new JSONArray();
-        names.put("baz");
-        names.put("quux");
-        names.put("foo");
-
-        JSONArray array = object.toJSONArray(names);
-        assertEquals(-0.0d, array.get(0));
-        assertEquals(value, array.get(1));
-        assertEquals(true, array.get(2));
-
-        object.put("foo", false);
-        assertEquals(true, array.get(2));
-    }
-
-    @Test
-    public void testToJSONArrayMissingNames() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", true);
-        object.put("bar", 5.0d);
-        object.put("baz", JSONObject.NULL);
-
-        JSONArray names = new JSONArray();
-        names.put("bar");
-        names.put("foo");
-        names.put("quux");
-        names.put("baz");
-
-        JSONArray array = object.toJSONArray(names);
-        assertEquals(4, array.length());
-
-        assertEquals(5.0d, array.get(0));
-        assertEquals(true, array.get(1));
-        try {
-            array.get(2);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals(JSONObject.NULL, array.get(3));
-    }
-
-    @Test
-    public void testToJSONArrayNull() throws JSONException {
-        JSONObject object = new JSONObject();
-        assertEquals(null, object.toJSONArray(null));
-        object.put("foo", 5);
-        try {
-            object.toJSONArray(null);
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testToJSONArrayEndsUpEmpty() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", 5);
-        JSONArray array = new JSONArray();
-        array.put("bar");
-        assertEquals(1, object.toJSONArray(array).length());
-    }
-
-    @Test
-    public void testToJSONArrayNonString() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", 5);
-        object.put("null", 10);
-        object.put("false", 15);
-
-        JSONArray names = new JSONArray();
-        names.put(JSONObject.NULL);
-        names.put(false);
-        names.put("foo");
-
-        // array elements are converted to strings to do name lookups on the map!
-        JSONArray array = object.toJSONArray(names);
-        assertEquals(3, array.length());
-        assertEquals(10, array.get(0));
-        assertEquals(15, array.get(1));
-        assertEquals(5, array.get(2));
-    }
-
-    @Test
-    public void testPutUnsupportedNumbers() throws JSONException {
-        JSONObject object = new JSONObject();
-        try {
-            object.put("foo", Double.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.put("foo", Double.NEGATIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.put("foo", Double.POSITIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testPutUnsupportedNumbersAsObjects() throws JSONException {
-        JSONObject object = new JSONObject();
-        try {
-            object.put("foo", (Double) Double.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.put("foo", (Double) Double.NEGATIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            object.put("foo", (Double) Double.POSITIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    /**
-     * Although JSONObject is usually defensive about which numbers it accepts,
-     * it doesn't check inputs in its constructor.
-     */
-    @Test
-    public void testCreateWithUnsupportedNumbers() throws JSONException {
-        Map<String, Object> contents = new HashMap<String, Object>();
-        contents.put("foo", Double.NaN);
-        contents.put("bar", Double.NEGATIVE_INFINITY);
-        contents.put("baz", Double.POSITIVE_INFINITY);
-
-        JSONObject object = new JSONObject(contents);
-        assertEquals(Double.NaN, object.get("foo"));
-        assertEquals(Double.NEGATIVE_INFINITY, object.get("bar"));
-        assertEquals(Double.POSITIVE_INFINITY, object.get("baz"));
-    }
-
-    @Test
-    public void testToStringWithUnsupportedNumbers() {
-        // when the object contains an unsupported number, toString returns null!
-        JSONObject object = new JSONObject(Collections.singletonMap("foo", Double.NaN));
-        assertEquals(null, object.toString());
-    }
-
-    @Test
-    public void testMapConstructorCopiesContents() throws JSONException {
-        Map<String, Object> contents = new HashMap<String, Object>();
-        contents.put("foo", 5);
-        JSONObject object = new JSONObject(contents);
-        contents.put("foo", 10);
-        assertEquals(5, object.get("foo"));
-    }
-
-    @Test
-    public void testMapConstructorWithBogusEntries() {
-        Map<Object, Object> contents = new HashMap<Object, Object>();
-        contents.put(5, 5);
-
-        try {
-            new JSONObject(contents);
-            fail("JSONObject constructor doesn't validate its input!");
-        } catch (Exception ignored) {
-        }
-    }
-
-    @Test
-    public void testTokenerConstructor() throws JSONException {
-        JSONObject object = new JSONObject(new JSONTokener("{\"foo\": false}"));
-        assertEquals(1, object.length());
-        assertEquals(false, object.get("foo"));
-    }
-
-    @Test
-    public void testTokenerConstructorWrongType() throws JSONException {
-        try {
-            new JSONObject(new JSONTokener("[\"foo\", false]"));
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testTokenerConstructorNull() throws JSONException {
-        try {
-            new JSONObject((JSONTokener) null);
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-    }
-
-    @Test
-    public void testTokenerConstructorParseFail() {
-        try {
-            new JSONObject(new JSONTokener("{"));
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testStringConstructor() throws JSONException {
-        JSONObject object = new JSONObject("{\"foo\": false}");
-        assertEquals(1, object.length());
-        assertEquals(false, object.get("foo"));
-    }
-
-    @Test
-    public void testStringConstructorWrongType() throws JSONException {
-        try {
-            new JSONObject("[\"foo\", false]");
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testStringConstructorNull() throws JSONException {
-        try {
-            new JSONObject((String) null);
-            fail();
-        } catch (NullPointerException ignored) {
-        }
-    }
-
-    @Test
-    public void testStringConstructorParseFail() {
-        try {
-            new JSONObject("{");
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testCopyConstructor() throws JSONException {
-        JSONObject source = new JSONObject();
-        source.put("a", JSONObject.NULL);
-        source.put("b", false);
-        source.put("c", 5);
-
-        JSONObject copy = new JSONObject(source, new String[]{"a", "c"});
-        assertEquals(2, copy.length());
-        assertEquals(JSONObject.NULL, copy.get("a"));
-        assertEquals(5, copy.get("c"));
-        assertEquals(null, copy.opt("b"));
-    }
-
-    @Test
-    public void testCopyConstructorMissingName() throws JSONException {
-        JSONObject source = new JSONObject();
-        source.put("a", JSONObject.NULL);
-        source.put("b", false);
-        source.put("c", 5);
-
-        JSONObject copy = new JSONObject(source, new String[]{"a", "c", "d"});
-        assertEquals(2, copy.length());
-        assertEquals(JSONObject.NULL, copy.get("a"));
-        assertEquals(5, copy.get("c"));
-        assertEquals(0, copy.optInt("b"));
-    }
-
-    @Test
-    public void testAccumulateMutatesInPlace() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", 5);
-        object.accumulate("foo", 6);
-        JSONArray array = object.getJSONArray("foo");
-        assertEquals("[5,6]", array.toString());
-        object.accumulate("foo", 7);
-        assertEquals("[5,6,7]", array.toString());
-    }
-
-    @Test
-    public void testAccumulateExistingArray() throws JSONException {
-        JSONArray array = new JSONArray();
-        JSONObject object = new JSONObject();
-        object.put("foo", array);
-        object.accumulate("foo", 5);
-        assertEquals("[5]", array.toString());
-    }
-
-    @Test
-    public void testAccumulatePutArray() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.accumulate("foo", 5);
-        assertEquals("{\"foo\":5}", object.toString());
-        object.accumulate("foo", new JSONArray());
-        assertEquals("{\"foo\":[5,[]]}", object.toString());
-    }
-
-    @Test
-    public void testAccumulateNull() {
-        JSONObject object = new JSONObject();
-        try {
-            object.accumulate(null, 5);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testEmptyStringKey() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("", 5);
-        assertEquals(5, object.get(""));
-        assertEquals("{\"\":5}", object.toString());
-    }
-
-    @Test
-    public void testNullValue() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", JSONObject.NULL);
-        object.put("bar", null);
-
-        // there are two ways to represent null; each behaves differently!
-        assertTrue(object.has("foo"));
-        assertFalse(object.has("bar"));
-        assertTrue(object.isNull("foo"));
-        assertTrue(object.isNull("bar"));
-    }
-
-    @Test
-    public void testNullValue_equalsAndHashCode() {
-        //noinspection ObjectEqualsNull
-        assertTrue(JSONObject.NULL.equals(null)); // guaranteed by javadoc
-        // not guaranteed by javadoc, but seems like a good idea
-        assertEquals(Objects.hashCode(null), JSONObject.NULL.hashCode());
-    }
-
-    @Test
-    public void testHas() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", 5);
-        assertTrue(object.has("foo"));
-        assertFalse(object.has("bar"));
-        assertFalse(object.has(null));
-    }
-
-    @Test
-    public void testOptNull() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", "bar");
-        assertEquals(null, object.opt(null));
-        assertEquals(false, object.optBoolean(null));
-        assertEquals(Double.NaN, object.optDouble(null), 0);
-        assertEquals(0, object.optInt(null));
-        assertEquals(0L, object.optLong(null));
-        assertEquals(null, object.optJSONArray(null));
-        assertEquals(null, object.optJSONObject(null));
-        assertEquals("", object.optString(null));
-        assertEquals(true, object.optBoolean(null, true));
-        assertEquals(0.0d, object.optDouble(null, 0.0d), 0);
-        assertEquals(1, object.optInt(null, 1));
-        assertEquals(1L, object.optLong(null, 1L));
-        assertEquals("baz", object.optString(null, "baz"));
-    }
-
-    @Test
-    public void testToStringWithIndentFactor() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", new JSONArray(Arrays.asList(5, 6)));
-        object.put("bar", new JSONObject());
-        String foobar = "{\n" +
-                "     \"foo\": [\n" +
-                "          5,\n" +
-                "          6\n" +
-                "     ],\n" +
-                "     \"bar\": {}\n" +
-                "}";
-        String barfoo = "{\n" +
-                "     \"bar\": {},\n" +
-                "     \"foo\": [\n" +
-                "          5,\n" +
-                "          6\n" +
-                "     ]\n" +
-                "}";
-        String string = object.toString(5);
-        assertTrue(string, foobar.equals(string) || barfoo.equals(string));
-    }
-
-    @Test
-    public void testNames() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", 5);
-        object.put("bar", 6);
-        object.put("baz", 7);
-        JSONArray array = object.names();
-        assertTrue(array.toString().contains("foo"));
-        assertTrue(array.toString().contains("bar"));
-        assertTrue(array.toString().contains("baz"));
-    }
-
-    @Test
-    public void testKeysEmptyObject() {
-        JSONObject object = new JSONObject();
-        assertFalse(object.keys().hasNext());
-        try {
-            object.keys().next();
-            fail();
-        } catch (NoSuchElementException ignored) {
-        }
-    }
-
-    @Test
-    public void testKeys() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", 5);
-        object.put("bar", 6);
-        object.put("foo", 7);
-
-        @SuppressWarnings("unchecked")
-        Iterator<String> keys = object.keys();
-        Set<String> result = new HashSet<String>();
-        assertTrue(keys.hasNext());
-        result.add(keys.next());
-        assertTrue(keys.hasNext());
-        result.add(keys.next());
-        assertFalse(keys.hasNext());
-        assertEquals(new HashSet<String>(Arrays.asList("foo", "bar")), result);
-
-        try {
-            keys.next();
-            fail();
-        } catch (NoSuchElementException ignored) {
-        }
-    }
-
-    @Test
-    public void testMutatingKeysMutatesObject() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", 5);
-        Iterator keys = object.keys();
-        keys.next();
-        keys.remove();
-        assertEquals(0, object.length());
-    }
-
-    @Test
-    public void testQuote() {
-        // covered by JSONStringerTest.testEscaping
-    }
-
-    @Test
-    public void testQuoteNull() throws JSONException {
-        assertEquals("\"\"", JSONObject.quote(null));
-    }
-
-    @Test
-    public void testNumberToString() throws JSONException {
-        assertEquals("5", JSONObject.numberToString(5));
-        assertEquals("-0", JSONObject.numberToString(-0.0d));
-        assertEquals("9223372036854775806", JSONObject.numberToString(9223372036854775806L));
-        assertEquals("4.9E-324", JSONObject.numberToString(Double.MIN_VALUE));
-        assertEquals("1.7976931348623157E308", JSONObject.numberToString(Double.MAX_VALUE));
-        try {
-            JSONObject.numberToString(Double.NaN);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            JSONObject.numberToString(Double.NEGATIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        try {
-            JSONObject.numberToString(Double.POSITIVE_INFINITY);
-            fail();
-        } catch (JSONException ignored) {
-        }
-        assertEquals("0.001", JSONObject.numberToString(new BigDecimal("0.001")));
-        assertEquals("9223372036854775806",
-                JSONObject.numberToString(new BigInteger("9223372036854775806")));
-        try {
-            JSONObject.numberToString(null);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void test_wrap() throws Exception {
-        assertEquals(JSONObject.NULL, JSONObject.wrap(null));
-
-        JSONArray a = new JSONArray();
-        assertEquals(a, JSONObject.wrap(a));
-
-        JSONObject o = new JSONObject();
-        assertEquals(o, JSONObject.wrap(o));
-
-        assertEquals(JSONObject.NULL, JSONObject.wrap(JSONObject.NULL));
-
-        assertTrue(JSONObject.wrap(new byte[0]) instanceof JSONArray);
-        assertTrue(JSONObject.wrap(new ArrayList<String>()) instanceof JSONArray);
-        assertTrue(JSONObject.wrap(new HashMap<String, String>()) instanceof JSONObject);
-        assertTrue(JSONObject.wrap(0.0) instanceof Double);
-        assertTrue(JSONObject.wrap("hello") instanceof String);
-    }
-
-    // https://code.google.com/p/android/issues/detail?id=55114
-    @Test
-    public void test_toString_listAsMapValue() throws Exception {
-        ArrayList<Object> list = new ArrayList<Object>();
-        list.add("a");
-        list.add(new ArrayList<String>());
-        Map<String, Object> map = new TreeMap<String, Object>();
-        map.put("x", "l");
-        map.put("y", list);
-        assertEquals("{\"x\":\"l\",\"y\":[\"a\",[]]}", new JSONObject(map).toString());
-    }
-
-    @Test
-    public void testAppendExistingInvalidKey() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.put("foo", 5);
-        try {
-            object.append("foo", 6);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testAppendExistingArray() throws JSONException {
-        JSONArray array = new JSONArray();
-        JSONObject object = new JSONObject();
-        object.put("foo", array);
-        object.append("foo", 5);
-        assertEquals("[5]", array.toString());
-    }
-
-    @Test
-    public void testAppendPutArray() throws JSONException {
-        JSONObject object = new JSONObject();
-        object.append("foo", 5);
-        assertEquals("{\"foo\":[5]}", object.toString());
-        object.append("foo", new JSONArray());
-        assertEquals("{\"foo\":[5,[]]}", object.toString());
-    }
-
-    @Test
-    public void testAppendNull() {
-        JSONObject object = new JSONObject();
-        try {
-            object.append(null, 5);
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    // https://code.google.com/p/android/issues/detail?id=103641
-    @Test
-    public void testInvalidUnicodeEscape() {
-        try {
-            new JSONObject("{\"q\":\"\\u\", \"r\":[]}");
-            fail();
-        } catch (JSONException ignored) {
-        }
-    }
-
-    @Test
-    public void testBeanThings() throws IllegalAccessException, IntrospectionException, InvocationTargetException {
-        Foo f = new Foo();
-        assertEquals("{\"a\":1,\"b\":1,\"c\":\"c\",\"d\":[{\"e\":\"echo\"}]}", new JSONObject(f).toString());
-    }
-
-    @Test
-    public void testGetNames() throws Exception {
-        assertArrayEquals(new String[]{"a", "b", "c", "d"}, JSONObject.getNames(new JSONObject(new Foo())));
-    }
-
-    private static class Foo {
-        public double getA() {
-            return 1.0;
-        }
-
-        public int getB() {
-            return 1;
-        }
-
-        public String getC() {
-            return "c";
-        }
-
-        public List<Bar> getD() {
-            ArrayList<Bar> r = new ArrayList<Bar>();
-            r.add(new Bar());
-            return r;
-        }
-    }
-
-    private static class Bar {
-        public String getE() {
-            return "echo";
-        }
-    }
-
-    @Test
-    public void testEnumWrapper() throws Exception {
-        Object y = JSONObject.wrap(E.A);
-        assertEquals("A", y);
-        assertTrue(y instanceof String);
-    }
-
-    enum E {
-        A {
-            int key() {
-                return 1;
-            }
-        }, B {
-            int key() {
-                return 2;
-            }
-        };
-        int key() {
-            return -1;
-        }
-    }
+  @Test
+  public void testKeyset() throws Exception {
+    JSONObject x = new JSONObject("{'a':1, 'b':2, 'c':3}");
+    Set<String> k = new TreeSet<String>();
+    for (String kx : Arrays.asList("a", "b", "c")) {
+      k.add(kx);
+    }
+    assertEquals(x.keySet(), k);
+    x = new JSONObject("{}");
+    assertEquals(x.keySet().size(), 0);
+  }
+
+  @Test
+  public void testEmptyObject() throws JSONException {
+    JSONObject object = new JSONObject();
+    assertEquals(0, object.length());
+
+    // bogus (but documented) behaviour: returns null rather than the empty object!
+    assertNull(object.names());
+
+    // returns null rather than an empty array!
+    assertNull(object.toJSONArray(new JSONArray()));
+    assertEquals("{}", object.toString());
+    assertEquals("{}", object.toString(5));
+    try {
+      object.get("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.getBoolean("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.getDouble("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.getInt("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.getJSONArray("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.getJSONObject("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.getLong("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.getString("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertFalse(object.has("foo"));
+    assertTrue(object.isNull("foo")); // isNull also means "is not present"
+    assertNull(object.opt("foo"));
+    assertEquals(false, object.optBoolean("foo"));
+    assertEquals(true, object.optBoolean("foo", true));
+    assertEquals(Double.NaN, object.optDouble("foo"), 0);
+    assertEquals(5.0, object.optDouble("foo", 5.0), 0);
+    assertEquals(0, object.optInt("foo"));
+    assertEquals(5, object.optInt("foo", 5));
+    assertEquals(null, object.optJSONArray("foo"));
+    assertEquals(null, object.optJSONObject("foo"));
+    assertEquals(0, object.optLong("foo"));
+    assertEquals(Long.MAX_VALUE - 1, object.optLong("foo", Long.MAX_VALUE - 1));
+    assertEquals("", object.optString("foo")); // empty string is default!
+    assertEquals("bar", object.optString("foo", "bar"));
+    assertNull(object.remove("foo"));
+  }
+
+  @Test
+  public void testEqualsAndHashCode() throws JSONException {
+    JSONObject a = new JSONObject();
+    JSONObject b = new JSONObject();
+
+    // JSON object doesn't override either equals or hashCode (!)
+    assertFalse(a.equals(b));
+    assertEquals(a.hashCode(), System.identityHashCode(a));
+  }
+
+  @Test
+  public void testGet() throws JSONException {
+    JSONObject object = new JSONObject();
+    Object value = new Object();
+    object.put("foo", value);
+    object.put("bar", new Object());
+    object.put("baz", new Object());
+    assertSame(value, object.get("foo"));
+    try {
+      object.get("FOO");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.put(null, value);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.get(null);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testPut() throws JSONException {
+    JSONObject object = new JSONObject();
+    assertSame(object, object.put("foo", true));
+    object.put("foo", false);
+    assertEquals(false, object.get("foo"));
+
+    object.put("foo", 5.0d);
+    assertEquals(5.0d, object.get("foo"));
+    object.put("foo", 0);
+    assertEquals(0, object.get("foo"));
+    object.put("bar", Long.MAX_VALUE - 1);
+    assertEquals(Long.MAX_VALUE - 1, object.get("bar"));
+    object.put("baz", "x");
+    assertEquals("x", object.get("baz"));
+    object.put("bar", JSONObject.NULL);
+    assertSame(JSONObject.NULL, object.get("bar"));
+  }
+
+  @Test
+  public void testPutNullRemoves() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", "bar");
+    object.put("foo", null);
+    assertEquals(0, object.length());
+    assertFalse(object.has("foo"));
+    try {
+      object.get("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testPutOpt() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", "bar");
+    object.putOpt("foo", null);
+    assertEquals("bar", object.get("foo"));
+    object.putOpt(null, null);
+    assertEquals(1, object.length());
+    object.putOpt(null, "bar");
+    assertEquals(1, object.length());
+  }
+
+  @Test
+  public void testPutOptUnsupportedNumbers() throws JSONException {
+    JSONObject object = new JSONObject();
+    try {
+      object.putOpt("foo", Double.NaN);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.putOpt("foo", Double.NEGATIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.putOpt("foo", Double.POSITIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testRemove() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", "bar");
+    assertEquals(null, object.remove(null));
+    assertEquals(null, object.remove(""));
+    assertEquals(null, object.remove("bar"));
+    assertEquals("bar", object.remove("foo"));
+    assertEquals(null, object.remove("foo"));
+  }
+
+  @Test
+  public void testBooleans() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", true);
+    object.put("bar", false);
+    object.put("baz", "true");
+    object.put("quux", "false");
+    assertEquals(4, object.length());
+    assertEquals(true, object.getBoolean("foo"));
+    assertEquals(false, object.getBoolean("bar"));
+    assertEquals(true, object.getBoolean("baz"));
+    assertEquals(false, object.getBoolean("quux"));
+    assertFalse(object.isNull("foo"));
+    assertFalse(object.isNull("quux"));
+    assertTrue(object.has("foo"));
+    assertTrue(object.has("quux"));
+    assertFalse(object.has("missing"));
+    assertEquals(true, object.optBoolean("foo"));
+    assertEquals(false, object.optBoolean("bar"));
+    assertEquals(true, object.optBoolean("baz"));
+    assertEquals(false, object.optBoolean("quux"));
+    assertEquals(false, object.optBoolean("missing"));
+    assertEquals(true, object.optBoolean("foo", true));
+    assertEquals(false, object.optBoolean("bar", true));
+    assertEquals(true, object.optBoolean("baz", true));
+    assertEquals(false, object.optBoolean("quux", true));
+    assertEquals(true, object.optBoolean("missing", true));
+
+    object.put("foo", "truE");
+    object.put("bar", "FALSE");
+    assertEquals(true, object.getBoolean("foo"));
+    assertEquals(false, object.getBoolean("bar"));
+    assertEquals(true, object.optBoolean("foo"));
+    assertEquals(false, object.optBoolean("bar"));
+    assertEquals(true, object.optBoolean("foo", false));
+    assertEquals(false, object.optBoolean("bar", false));
+  }
+
+  // http://code.google.com/p/android/issues/detail?id=16411
+  @Test
+  public void testCoerceStringToBoolean() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", "maybe");
+    try {
+      object.getBoolean("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals(false, object.optBoolean("foo"));
+    assertEquals(true, object.optBoolean("foo", true));
+  }
+
+  @Test
+  public void testNumbers() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", Double.MIN_VALUE);
+    object.put("bar", 9223372036854775806L);
+    object.put("baz", Double.MAX_VALUE);
+    object.put("quux", -0d);
+    assertEquals(4, object.length());
+
+    String toString = object.toString();
+    assertTrue(toString, toString.contains("\"foo\":4.9E-324"));
+    assertTrue(toString, toString.contains("\"bar\":9223372036854775806"));
+    assertTrue(toString, toString.contains("\"baz\":1.7976931348623157E308"));
+
+    // toString() and getString() return different values for -0d!
+    assertTrue(toString, toString.contains("\"quux\":-0}") // no trailing decimal point
+        || toString.contains("\"quux\":-0,"));
+
+    assertEquals(Double.MIN_VALUE, object.get("foo"));
+    assertEquals(9223372036854775806L, object.get("bar"));
+    assertEquals(Double.MAX_VALUE, object.get("baz"));
+    assertEquals(-0d, object.get("quux"));
+    assertEquals(Double.MIN_VALUE, object.getDouble("foo"), 0);
+    assertEquals(9.223372036854776E18, object.getDouble("bar"), 0);
+    assertEquals(Double.MAX_VALUE, object.getDouble("baz"), 0);
+    assertEquals(-0d, object.getDouble("quux"), 0);
+    assertEquals(0, object.getLong("foo"));
+    assertEquals(9223372036854775806L, object.getLong("bar"));
+    assertEquals(Long.MAX_VALUE, object.getLong("baz"));
+    assertEquals(0, object.getLong("quux"));
+    assertEquals(0, object.getInt("foo"));
+    assertEquals(-2, object.getInt("bar"));
+    assertEquals(Integer.MAX_VALUE, object.getInt("baz"));
+    assertEquals(0, object.getInt("quux"));
+    assertEquals(Double.MIN_VALUE, object.opt("foo"));
+    assertEquals(9223372036854775806L, object.optLong("bar"));
+    assertEquals(Double.MAX_VALUE, object.optDouble("baz"), 0);
+    assertEquals(0, object.optInt("quux"));
+    assertEquals(Double.MIN_VALUE, object.opt("foo"));
+    assertEquals(9223372036854775806L, object.optLong("bar"));
+    assertEquals(Double.MAX_VALUE, object.optDouble("baz"), 0);
+    assertEquals(0, object.optInt("quux"));
+    assertEquals(Double.MIN_VALUE, object.optDouble("foo", 5.0d), 0);
+    assertEquals(9223372036854775806L, object.optLong("bar", 1L));
+    assertEquals(Long.MAX_VALUE, object.optLong("baz", 1L));
+    assertEquals(0, object.optInt("quux", -1));
+    assertEquals("4.9E-324", object.getString("foo"));
+    assertEquals("9223372036854775806", object.getString("bar"));
+    assertEquals("1.7976931348623157E308", object.getString("baz"));
+    assertEquals("-0.0", object.getString("quux"));
+  }
+
+  @Test
+  public void testFloats() throws JSONException {
+    JSONObject object = new JSONObject();
+    try {
+      object.put("foo", (Float) Float.NaN);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.put("foo", (Float) Float.NEGATIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.put("foo", (Float) Float.POSITIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testOtherNumbers() throws JSONException {
+    Number nan = new Number() {
+      public int intValue() {
+        throw new UnsupportedOperationException();
+      }
+
+      public long longValue() {
+        throw new UnsupportedOperationException();
+      }
+
+      public float floatValue() {
+        throw new UnsupportedOperationException();
+      }
+
+      public double doubleValue() {
+        return Double.NaN;
+      }
+
+      @Override
+      public String toString() {
+        return "x";
+      }
+    };
+
+    JSONObject object = new JSONObject();
+    try {
+      object.put("foo", nan);
+      fail("Object.put() accepted a NaN (via a custom Number class)");
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testForeignObjects() throws JSONException {
+    Object foreign = new Object() {
+      @Override
+      public String toString() {
+        return "x";
+      }
+    };
+
+    // foreign object types are accepted and treated as Strings!
+    JSONObject object = new JSONObject();
+    object.put("foo", foreign);
+    assertEquals("{\"foo\":\"x\"}", object.toString());
+  }
+
+  @Test
+  public void testNullKeys() {
+    try {
+      new JSONObject().put(null, false);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      new JSONObject().put(null, 0.0d);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      new JSONObject().put(null, 5);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      new JSONObject().put(null, 5L);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      new JSONObject().put(null, "foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testStrings() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", "true");
+    object.put("bar", "5.5");
+    object.put("baz", "9223372036854775806");
+    object.put("quux", "null");
+    object.put("height", "5\"8' tall");
+
+    assertTrue(object.toString().contains("\"foo\":\"true\""));
+    assertTrue(object.toString().contains("\"bar\":\"5.5\""));
+    assertTrue(object.toString().contains("\"baz\":\"9223372036854775806\""));
+    assertTrue(object.toString().contains("\"quux\":\"null\""));
+    assertTrue(object.toString().contains("\"height\":\"5\\\"8' tall\""));
+
+    assertEquals("true", object.get("foo"));
+    assertEquals("null", object.getString("quux"));
+    assertEquals("5\"8' tall", object.getString("height"));
+    assertEquals("true", object.opt("foo"));
+    assertEquals("5.5", object.optString("bar"));
+    assertEquals("true", object.optString("foo", "x"));
+    assertFalse(object.isNull("foo"));
+
+    assertEquals(true, object.getBoolean("foo"));
+    assertEquals(true, object.optBoolean("foo"));
+    assertEquals(true, object.optBoolean("foo", false));
+    assertEquals(0, object.optInt("foo"));
+    assertEquals(-2, object.optInt("foo", -2));
+
+    assertEquals(5.5d, object.getDouble("bar"), 0);
+    assertEquals(5L, object.getLong("bar"));
+    assertEquals(5, object.getInt("bar"));
+    assertEquals(5, object.optInt("bar", 3));
+
+    // The last digit of the string is a 6 but getLong returns a 7. It's probably parsing as a
+    // double and then converting that to a long. This is consistent with JavaScript.
+    assertEquals(9223372036854775807L, object.getLong("baz"));
+    assertEquals(9.223372036854776E18, object.getDouble("baz"), 0);
+    assertEquals(Integer.MAX_VALUE, object.getInt("baz"));
+
+    assertFalse(object.isNull("quux"));
+    try {
+      object.getDouble("quux");
+      fail();
+    } catch (JSONException e) {
+      // expected
+    }
+    assertEquals(Double.NaN, object.optDouble("quux"), 0);
+    assertEquals(-1.0d, object.optDouble("quux", -1.0d), 0);
+
+    object.put("foo", "TRUE");
+    assertEquals(true, object.getBoolean("foo"));
+  }
+
+  @Test
+  public void testJSONObjects() throws JSONException {
+    JSONObject object = new JSONObject();
+
+    JSONArray a = new JSONArray();
+    JSONObject b = new JSONObject();
+    object.put("foo", a);
+    object.put("bar", b);
+
+    assertSame(a, object.getJSONArray("foo"));
+    assertSame(b, object.getJSONObject("bar"));
+    try {
+      object.getJSONObject("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.getJSONArray("bar");
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals(a, object.optJSONArray("foo"));
+    assertEquals(b, object.optJSONObject("bar"));
+    assertEquals(null, object.optJSONArray("bar"));
+    assertEquals(null, object.optJSONObject("foo"));
+  }
+
+  @Test
+  public void testNullCoercionToString() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", JSONObject.NULL);
+    assertEquals("null", object.getString("foo"));
+  }
+
+  @Test
+  public void testArrayCoercion() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", "[true]");
+    try {
+      object.getJSONArray("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testObjectCoercion() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", "{}");
+    try {
+      object.getJSONObject("foo");
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testAccumulateValueChecking() throws JSONException {
+    JSONObject object = new JSONObject();
+    try {
+      object.accumulate("foo", Double.NaN);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    object.accumulate("foo", 1);
+    try {
+      object.accumulate("foo", Double.NaN);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    object.accumulate("foo", 2);
+    try {
+      object.accumulate("foo", Double.NaN);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testToJSONArray() throws JSONException {
+    JSONObject object = new JSONObject();
+    Object value = new Object();
+    object.put("foo", true);
+    object.put("bar", 5.0d);
+    object.put("baz", -0.0d);
+    object.put("quux", value);
+
+    JSONArray names = new JSONArray();
+    names.put("baz");
+    names.put("quux");
+    names.put("foo");
+
+    JSONArray array = object.toJSONArray(names);
+    assertEquals(-0.0d, array.get(0));
+    assertEquals(value, array.get(1));
+    assertEquals(true, array.get(2));
+
+    object.put("foo", false);
+    assertEquals(true, array.get(2));
+  }
+
+  @Test
+  public void testToJSONArrayMissingNames() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", true);
+    object.put("bar", 5.0d);
+    object.put("baz", JSONObject.NULL);
+
+    JSONArray names = new JSONArray();
+    names.put("bar");
+    names.put("foo");
+    names.put("quux");
+    names.put("baz");
+
+    JSONArray array = object.toJSONArray(names);
+    assertEquals(4, array.length());
+
+    assertEquals(5.0d, array.get(0));
+    assertEquals(true, array.get(1));
+    try {
+      array.get(2);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals(JSONObject.NULL, array.get(3));
+  }
+
+  @Test
+  public void testToJSONArrayNull() throws JSONException {
+    JSONObject object = new JSONObject();
+    assertEquals(null, object.toJSONArray(null));
+    object.put("foo", 5);
+    try {
+      object.toJSONArray(null);
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testToJSONArrayEndsUpEmpty() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", 5);
+    JSONArray array = new JSONArray();
+    array.put("bar");
+    assertEquals(1, object.toJSONArray(array).length());
+  }
+
+  @Test
+  public void testToJSONArrayNonString() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", 5);
+    object.put("null", 10);
+    object.put("false", 15);
+
+    JSONArray names = new JSONArray();
+    names.put(JSONObject.NULL);
+    names.put(false);
+    names.put("foo");
+
+    // array elements are converted to strings to do name lookups on the map!
+    JSONArray array = object.toJSONArray(names);
+    assertEquals(3, array.length());
+    assertEquals(10, array.get(0));
+    assertEquals(15, array.get(1));
+    assertEquals(5, array.get(2));
+  }
+
+  @Test
+  public void testPutUnsupportedNumbers() throws JSONException {
+    JSONObject object = new JSONObject();
+    try {
+      object.put("foo", Double.NaN);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.put("foo", Double.NEGATIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.put("foo", Double.POSITIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testPutUnsupportedNumbersAsObjects() throws JSONException {
+    JSONObject object = new JSONObject();
+    try {
+      object.put("foo", (Double) Double.NaN);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.put("foo", (Double) Double.NEGATIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      object.put("foo", (Double) Double.POSITIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  /**
+   * Although JSONObject is usually defensive about which numbers it accepts, it doesn't check
+   * inputs in its constructor.
+   */
+  @Test
+  public void testCreateWithUnsupportedNumbers() throws JSONException {
+    Map<String, Object> contents = new HashMap<String, Object>();
+    contents.put("foo", Double.NaN);
+    contents.put("bar", Double.NEGATIVE_INFINITY);
+    contents.put("baz", Double.POSITIVE_INFINITY);
+
+    JSONObject object = new JSONObject(contents);
+    assertEquals(Double.NaN, object.get("foo"));
+    assertEquals(Double.NEGATIVE_INFINITY, object.get("bar"));
+    assertEquals(Double.POSITIVE_INFINITY, object.get("baz"));
+  }
+
+  @Test
+  public void testToStringWithUnsupportedNumbers() {
+    // when the object contains an unsupported number, toString returns null!
+    JSONObject object = new JSONObject(Collections.singletonMap("foo", Double.NaN));
+    assertEquals(null, object.toString());
+  }
+
+  @Test
+  public void testMapConstructorCopiesContents() throws JSONException {
+    Map<String, Object> contents = new HashMap<String, Object>();
+    contents.put("foo", 5);
+    JSONObject object = new JSONObject(contents);
+    contents.put("foo", 10);
+    assertEquals(5, object.get("foo"));
+  }
+
+  @Test
+  public void testMapConstructorWithBogusEntries() {
+    Map<Object, Object> contents = new HashMap<Object, Object>();
+    contents.put(5, 5);
+
+    try {
+      new JSONObject(contents);
+      fail("JSONObject constructor doesn't validate its input!");
+    } catch (Exception ignored) {
+    }
+  }
+
+  @Test
+  public void testTokenerConstructor() throws JSONException {
+    JSONObject object = new JSONObject(new JSONTokener("{\"foo\": false}"));
+    assertEquals(1, object.length());
+    assertEquals(false, object.get("foo"));
+  }
+
+  @Test
+  public void testTokenerConstructorWrongType() throws JSONException {
+    try {
+      new JSONObject(new JSONTokener("[\"foo\", false]"));
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testTokenerConstructorNull() throws JSONException {
+    try {
+      new JSONObject((JSONTokener) null);
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+  }
+
+  @Test
+  public void testTokenerConstructorParseFail() {
+    try {
+      new JSONObject(new JSONTokener("{"));
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testStringConstructor() throws JSONException {
+    JSONObject object = new JSONObject("{\"foo\": false}");
+    assertEquals(1, object.length());
+    assertEquals(false, object.get("foo"));
+  }
+
+  @Test
+  public void testStringConstructorWrongType() throws JSONException {
+    try {
+      new JSONObject("[\"foo\", false]");
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testStringConstructorNull() throws JSONException {
+    try {
+      new JSONObject((String) null);
+      fail();
+    } catch (NullPointerException ignored) {
+    }
+  }
+
+  @Test
+  public void testStringConstructorParseFail() {
+    try {
+      new JSONObject("{");
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testCopyConstructor() throws JSONException {
+    JSONObject source = new JSONObject();
+    source.put("a", JSONObject.NULL);
+    source.put("b", false);
+    source.put("c", 5);
+
+    JSONObject copy = new JSONObject(source, new String[] {"a", "c"});
+    assertEquals(2, copy.length());
+    assertEquals(JSONObject.NULL, copy.get("a"));
+    assertEquals(5, copy.get("c"));
+    assertEquals(null, copy.opt("b"));
+  }
+
+  @Test
+  public void testCopyConstructorMissingName() throws JSONException {
+    JSONObject source = new JSONObject();
+    source.put("a", JSONObject.NULL);
+    source.put("b", false);
+    source.put("c", 5);
+
+    JSONObject copy = new JSONObject(source, new String[] {"a", "c", "d"});
+    assertEquals(2, copy.length());
+    assertEquals(JSONObject.NULL, copy.get("a"));
+    assertEquals(5, copy.get("c"));
+    assertEquals(0, copy.optInt("b"));
+  }
+
+  @Test
+  public void testAccumulateMutatesInPlace() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", 5);
+    object.accumulate("foo", 6);
+    JSONArray array = object.getJSONArray("foo");
+    assertEquals("[5,6]", array.toString());
+    object.accumulate("foo", 7);
+    assertEquals("[5,6,7]", array.toString());
+  }
+
+  @Test
+  public void testAccumulateExistingArray() throws JSONException {
+    JSONArray array = new JSONArray();
+    JSONObject object = new JSONObject();
+    object.put("foo", array);
+    object.accumulate("foo", 5);
+    assertEquals("[5]", array.toString());
+  }
+
+  @Test
+  public void testAccumulatePutArray() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.accumulate("foo", 5);
+    assertEquals("{\"foo\":5}", object.toString());
+    object.accumulate("foo", new JSONArray());
+    assertEquals("{\"foo\":[5,[]]}", object.toString());
+  }
+
+  @Test
+  public void testAccumulateNull() {
+    JSONObject object = new JSONObject();
+    try {
+      object.accumulate(null, 5);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testEmptyStringKey() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("", 5);
+    assertEquals(5, object.get(""));
+    assertEquals("{\"\":5}", object.toString());
+  }
+
+  @Test
+  public void testNullValue() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", JSONObject.NULL);
+    object.put("bar", null);
+
+    // there are two ways to represent null; each behaves differently!
+    assertTrue(object.has("foo"));
+    assertFalse(object.has("bar"));
+    assertTrue(object.isNull("foo"));
+    assertTrue(object.isNull("bar"));
+  }
+
+  @Test
+  public void testNullValue_equalsAndHashCode() {
+    // noinspection ObjectEqualsNull
+    assertTrue(JSONObject.NULL.equals(null)); // guaranteed by javadoc
+    // not guaranteed by javadoc, but seems like a good idea
+    assertEquals(Objects.hashCode(null), JSONObject.NULL.hashCode());
+  }
+
+  @Test
+  public void testHas() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", 5);
+    assertTrue(object.has("foo"));
+    assertFalse(object.has("bar"));
+    assertFalse(object.has(null));
+  }
+
+  @Test
+  public void testOptNull() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", "bar");
+    assertEquals(null, object.opt(null));
+    assertEquals(false, object.optBoolean(null));
+    assertEquals(Double.NaN, object.optDouble(null), 0);
+    assertEquals(0, object.optInt(null));
+    assertEquals(0L, object.optLong(null));
+    assertEquals(null, object.optJSONArray(null));
+    assertEquals(null, object.optJSONObject(null));
+    assertEquals("", object.optString(null));
+    assertEquals(true, object.optBoolean(null, true));
+    assertEquals(0.0d, object.optDouble(null, 0.0d), 0);
+    assertEquals(1, object.optInt(null, 1));
+    assertEquals(1L, object.optLong(null, 1L));
+    assertEquals("baz", object.optString(null, "baz"));
+  }
+
+  @Test
+  public void testToStringWithIndentFactor() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", new JSONArray(Arrays.asList(5, 6)));
+    object.put("bar", new JSONObject());
+    String foobar = "{\n" + "     \"foo\": [\n" + "          5,\n" + "          6\n" + "     ],\n"
+        + "     \"bar\": {}\n" + "}";
+    String barfoo = "{\n" + "     \"bar\": {},\n" + "     \"foo\": [\n" + "          5,\n"
+        + "          6\n" + "     ]\n" + "}";
+    String string = object.toString(5);
+    assertTrue(string, foobar.equals(string) || barfoo.equals(string));
+  }
+
+  @Test
+  public void testNames() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", 5);
+    object.put("bar", 6);
+    object.put("baz", 7);
+    JSONArray array = object.names();
+    assertTrue(array.toString().contains("foo"));
+    assertTrue(array.toString().contains("bar"));
+    assertTrue(array.toString().contains("baz"));
+  }
+
+  @Test
+  public void testKeysEmptyObject() {
+    JSONObject object = new JSONObject();
+    assertFalse(object.keys().hasNext());
+    try {
+      object.keys().next();
+      fail();
+    } catch (NoSuchElementException ignored) {
+    }
+  }
+
+  @Test
+  public void testKeys() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", 5);
+    object.put("bar", 6);
+    object.put("foo", 7);
+
+    @SuppressWarnings("unchecked")
+    Iterator<String> keys = object.keys();
+    Set<String> result = new HashSet<String>();
+    assertTrue(keys.hasNext());
+    result.add(keys.next());
+    assertTrue(keys.hasNext());
+    result.add(keys.next());
+    assertFalse(keys.hasNext());
+    assertEquals(new HashSet<String>(Arrays.asList("foo", "bar")), result);
+
+    try {
+      keys.next();
+      fail();
+    } catch (NoSuchElementException ignored) {
+    }
+  }
+
+  @Test
+  public void testMutatingKeysMutatesObject() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", 5);
+    Iterator keys = object.keys();
+    keys.next();
+    keys.remove();
+    assertEquals(0, object.length());
+  }
+
+  @Test
+  public void testQuote() {
+    // covered by JSONStringerTest.testEscaping
+  }
+
+  @Test
+  public void testQuoteNull() throws JSONException {
+    assertEquals("\"\"", JSONObject.quote(null));
+  }
+
+  @Test
+  public void testNumberToString() throws JSONException {
+    assertEquals("5", JSONObject.numberToString(5));
+    assertEquals("-0", JSONObject.numberToString(-0.0d));
+    assertEquals("9223372036854775806", JSONObject.numberToString(9223372036854775806L));
+    assertEquals("4.9E-324", JSONObject.numberToString(Double.MIN_VALUE));
+    assertEquals("1.7976931348623157E308", JSONObject.numberToString(Double.MAX_VALUE));
+    try {
+      JSONObject.numberToString(Double.NaN);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      JSONObject.numberToString(Double.NEGATIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    try {
+      JSONObject.numberToString(Double.POSITIVE_INFINITY);
+      fail();
+    } catch (JSONException ignored) {
+    }
+    assertEquals("0.001", JSONObject.numberToString(new BigDecimal("0.001")));
+    assertEquals("9223372036854775806",
+        JSONObject.numberToString(new BigInteger("9223372036854775806")));
+    try {
+      JSONObject.numberToString(null);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void test_wrap() throws Exception {
+    assertEquals(JSONObject.NULL, JSONObject.wrap(null));
+
+    JSONArray a = new JSONArray();
+    assertEquals(a, JSONObject.wrap(a));
+
+    JSONObject o = new JSONObject();
+    assertEquals(o, JSONObject.wrap(o));
+
+    assertEquals(JSONObject.NULL, JSONObject.wrap(JSONObject.NULL));
+
+    assertTrue(JSONObject.wrap(new byte[0]) instanceof JSONArray);
+    assertTrue(JSONObject.wrap(new ArrayList<String>()) instanceof JSONArray);
+    assertTrue(JSONObject.wrap(new HashMap<String, String>()) instanceof JSONObject);
+    assertTrue(JSONObject.wrap(0.0) instanceof Double);
+    assertTrue(JSONObject.wrap("hello") instanceof String);
+  }
+
+  // https://code.google.com/p/android/issues/detail?id=55114
+  @Test
+  public void test_toString_listAsMapValue() throws Exception {
+    ArrayList<Object> list = new ArrayList<Object>();
+    list.add("a");
+    list.add(new ArrayList<String>());
+    Map<String, Object> map = new TreeMap<String, Object>();
+    map.put("x", "l");
+    map.put("y", list);
+    assertEquals("{\"x\":\"l\",\"y\":[\"a\",[]]}", new JSONObject(map).toString());
+  }
+
+  @Test
+  public void testAppendExistingInvalidKey() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.put("foo", 5);
+    try {
+      object.append("foo", 6);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testAppendExistingArray() throws JSONException {
+    JSONArray array = new JSONArray();
+    JSONObject object = new JSONObject();
+    object.put("foo", array);
+    object.append("foo", 5);
+    assertEquals("[5]", array.toString());
+  }
+
+  @Test
+  public void testAppendPutArray() throws JSONException {
+    JSONObject object = new JSONObject();
+    object.append("foo", 5);
+    assertEquals("{\"foo\":[5]}", object.toString());
+    object.append("foo", new JSONArray());
+    assertEquals("{\"foo\":[5,[]]}", object.toString());
+  }
+
+  @Test
+  public void testAppendNull() {
+    JSONObject object = new JSONObject();
+    try {
+      object.append(null, 5);
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  // https://code.google.com/p/android/issues/detail?id=103641
+  @Test
+  public void testInvalidUnicodeEscape() {
+    try {
+      new JSONObject("{\"q\":\"\\u\", \"r\":[]}");
+      fail();
+    } catch (JSONException ignored) {
+    }
+  }
+
+  @Test
+  public void testBeanThings()
+      throws IllegalAccessException, IntrospectionException, InvocationTargetException {
+    Foo f = new Foo();
+    assertEquals("{\"a\":1,\"b\":1,\"c\":\"c\",\"d\":[{\"e\":\"echo\"}]}",
+        new JSONObject(f).toString());
+  }
+
+  @Test
+  public void testGetNames() throws Exception {
+    assertArrayEquals(new String[] {"a", "b", "c", "d"},
+        JSONObject.getNames(new JSONObject(new Foo())));
+  }
+
+  private static class Foo {
+    public double getA() {
+      return 1.0;
+    }
+
+    public int getB() {
+      return 1;
+    }
+
+    public String getC() {
+      return "c";
+    }
+
+    public List<Bar> getD() {
+      ArrayList<Bar> r = new ArrayList<Bar>();
+      r.add(new Bar());
+      return r;
+    }
+  }
+
+  private static class Bar {
+    public String getE() {
+      return "echo";
+    }
+  }
+
+  @Test
+  public void testEnumWrapper() throws Exception {
+    Object y = JSONObject.wrap(E.A);
+    assertEquals("A", y);
+    assertTrue(y instanceof String);
+  }
+
+  enum E {
+    A {
+      int key() {
+        return 1;
+      }
+    },
+    B {
+      int key() {
+        return 2;
+      }
+    };
+    int key() {
+      return -1;
+    }
+  }
 }


[25/51] [abbrv] geode git commit: GEODE-2460: update dependency versions

Posted by ds...@apache.org.
GEODE-2460: update dependency versions

* com.fasterxml.jackson.core:jackson-annotation:2.8.6
* com.fasterxml.jackson.core:jackson-core:2.8.6
* com.fasterxml.jackson.core:jackson-databind:2.8.6
* com.fasterxml.jackson.module:jackson-module-scala_2.10:2.8.6
* org.eclipse.persistence:javax.persistence:2.1.1
* fix dependency versions in NOTICE files


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/bc32a76c
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/bc32a76c
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/bc32a76c

Branch: refs/heads/feature/GEM-1195
Commit: bc32a76c223d7a2b407fed72595af4056a78e433
Parents: 5ec0d47
Author: Kirk Lund <kl...@apache.org>
Authored: Fri Feb 24 17:13:08 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Feb 28 11:30:53 2017 -0800

----------------------------------------------------------------------
 geode-assembly/src/main/dist/NOTICE           | 10 +++++-----
 geode-pulse/src/main/webapp/META-INF/NOTICE   |  4 ++--
 geode-web-api/src/main/webapp/META-INF/NOTICE |  4 ++--
 gradle/dependency-versions.properties         |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/bc32a76c/geode-assembly/src/main/dist/NOTICE
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/NOTICE b/geode-assembly/src/main/dist/NOTICE
index 2cdda71..0985dc2 100644
--- a/geode-assembly/src/main/dist/NOTICE
+++ b/geode-assembly/src/main/dist/NOTICE
@@ -26,7 +26,7 @@ Java ClassMate library was originally written by Tatu Saloranta (tatu.saloranta@
   
   * Brian Langel
 
-Jackson Core 2.8.2
+Jackson Core 2.8.6
 
   # Jackson JSON processor
 
@@ -131,8 +131,8 @@ Copyright (c) 2002-2017 Pivotal, Inc.
   these subcomponents is subject to the terms and conditions of the
   subcomponent's license, as noted in the license.txt file.
 
-Spring Hateoas 0.21.0
-Copyright (c) [2012-2014] Pivotal Software, Inc.
+Spring Hateoas 0.23.0.RELEASE
+Copyright (c) [2012-2017] Pivotal Software, Inc.
 
   This product is licensed to you under the Apache License, Version 2.0 (the "License").  
   You may not use this product except in compliance with the License.  
@@ -142,12 +142,12 @@ Copyright (c) [2012-2014] Pivotal Software, Inc.
   code for the these subcomponents is subject to the terms and
   conditions of the subcomponent's license, as noted in the LICENSE file.
 
-Spring LDAP Core 2.1.0
+Spring LDAP Core 2.3.1.RELEASE
 
    This product includes software developed by the Spring LDAP
    Project (http://www.springframework.org/ldap).
 
-Spring Shell 1.2.0
+Spring Shell 1.2.0.RELEASE
 
    This product includes software developed by the Spring Framework
    Project (http://www.springframework.org).

http://git-wip-us.apache.org/repos/asf/geode/blob/bc32a76c/geode-pulse/src/main/webapp/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/webapp/META-INF/NOTICE b/geode-pulse/src/main/webapp/META-INF/NOTICE
index 166a9ee..1d161e9 100644
--- a/geode-pulse/src/main/webapp/META-INF/NOTICE
+++ b/geode-pulse/src/main/webapp/META-INF/NOTICE
@@ -20,7 +20,7 @@ Copyright 2016 AddThis
 This product includes software developed by the MX4J
 project (http://mx4j.sourceforge.net).
 
-Jackson Core 2.8.0
+Jackson Core 2.8.6
 
   # Jackson JSON processor
   
@@ -55,7 +55,7 @@ Copyright (c) 2002-2017 Pivotal, Inc.
   these subcomponents is subject to the terms and conditions of the
   subcomponent's license, as noted in the license.txt file.
 
-Spring LDAP Core 2.1.0.RELEASE
+Spring LDAP Core 2.3.1.RELEASE
 
    This product includes software developed by the Spring LDAP
    Project (http://www.springframework.org/ldap).

http://git-wip-us.apache.org/repos/asf/geode/blob/bc32a76c/geode-web-api/src/main/webapp/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/webapp/META-INF/NOTICE b/geode-web-api/src/main/webapp/META-INF/NOTICE
index 8e1775b..8070e9b 100644
--- a/geode-web-api/src/main/webapp/META-INF/NOTICE
+++ b/geode-web-api/src/main/webapp/META-INF/NOTICE
@@ -26,7 +26,7 @@ Java ClassMate library was originally written by Tatu Saloranta (tatu.saloranta@
   
   * Brian Langel
 
-Jackson Core 2.8.2
+Jackson Core 2.8.6
 
   # Jackson JSON processor
   
@@ -61,7 +61,7 @@ Copyright (c) 2002-2017 Pivotal, Inc.
   these subcomponents is subject to the terms and conditions of the
   subcomponent's license, as noted in the license.txt file.
 
-Spring Hateoas 0.21.0
+Spring Hateoas 0.23.0.RELEASE
 Copyright (c) [2012-2014] Pivotal Software, Inc.
 
   This product is licensed to you under the Apache License, Version 2.0 (the "License").  

http://git-wip-us.apache.org/repos/asf/geode/blob/bc32a76c/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index be828af..d4a104e 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -40,14 +40,14 @@ hamcrest-all.version = 1.3
 httpclient.version = 4.5.3
 httpcore.version = 4.4.6
 httpunit.version = 1.7.2
-jackson.version = 2.8.2
-jackson-module-scala_2.10.version = 2.8.2
+jackson.version = 2.8.6
+jackson-module-scala_2.10.version = 2.8.6
 jansi.version = 1.14
 javassist.version = 3.21.0-GA
 javax.ejb-api.version = 3.0
 javax.jsr250-api.version = 1.0
 javax.mail-api.version = 1.4.7
-javax.persistence-api.version = 2.0.0
+javax.persistence-api.version = 2.1.1
 javax.resource-api.version = 1.7
 javax.servlet-api.version = 3.1.0
 javax.transaction-api.version = 1.2


[43/51] [abbrv] geode git commit: GEODE-2541: Fixed ClassCastException failure

Posted by ds...@apache.org.
GEODE-2541: Fixed ClassCastException failure

Fixed in HeadlessGfsh, and added new test for handling a command response
that's not a CommandResult object


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/de0dab30
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/de0dab30
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/de0dab30

Branch: refs/heads/feature/GEM-1195
Commit: de0dab309129044c23d122b57d56506add7d847e
Parents: 479c0a1
Author: Ken Howe <kh...@pivotal.io>
Authored: Wed Mar 1 13:04:05 2017 -0800
Committer: Ken Howe <kh...@pivotal.io>
Committed: Thu Mar 2 09:58:12 2017 -0800

----------------------------------------------------------------------
 .../management/internal/cli/HeadlessGfsh.java   | 16 +++++
 .../cli/HeadlessGfshIntegrationTest.java        | 69 +++++++++++++++-----
 2 files changed, 68 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/de0dab30/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
index 72be0c7..76e986d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfsh.java
@@ -15,6 +15,7 @@
 package org.apache.geode.management.internal.cli;
 
 import jline.console.ConsoleReader;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.shell.GfshConfig;
 import org.apache.geode.management.internal.cli.shell.jline.GfshUnsupportedTerminal;
@@ -122,6 +123,13 @@ public class HeadlessGfsh implements ResultHandler {
     try {
       Object result = queue.poll(timeout, TimeUnit.SECONDS);
       queue.clear();
+      if (!(result instanceof org.apache.geode.management.internal.cli.result.CommandResult)) {
+        if (result == null) {
+          return ResultBuilder.createBadResponseErrorResult("command response was null");
+        } else {
+          return ResultBuilder.createBadResponseErrorResult(result.toString());
+        }
+      }
       return result;
     } catch (InterruptedException e) {
       e.printStackTrace();
@@ -159,6 +167,14 @@ public class HeadlessGfsh implements ResultHandler {
     return shell.errorString;
   }
 
+  /**
+   * Method for tests to access the results queue
+   *
+   */
+  LinkedBlockingQueue getQueue() {
+    return queue;
+  }
+
   public static class HeadlessGfshShell extends Gfsh {
 
     private ResultHandler handler = null;

http://git-wip-us.apache.org/repos/asf/geode/blob/de0dab30/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java
index 2ea8d99..e9fbd75 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java
@@ -14,10 +14,25 @@
  */
 package org.apache.geode.management.internal.cli;
 
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.internal.AvailablePort.SOCKET;
+import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -26,18 +41,17 @@ import org.junit.rules.TestName;
 
 import java.io.IOException;
 import java.util.Properties;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.internal.AvailablePort.SOCKET;
-import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import java.util.concurrent.LinkedBlockingQueue;
 
 /**
  * TODO : Add more tests for error-catch, different type of results etc
  */
 @Category(IntegrationTest.class)
 public class HeadlessGfshIntegrationTest {
+  private int port;
+  private DistributedSystem ds;
+  private GemFireCacheImpl cache;
+  private HeadlessGfsh gfsh;
 
   @Rule
   public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -45,11 +59,9 @@ public class HeadlessGfshIntegrationTest {
   @Rule
   public TestName testName = new TestName();
 
-  @SuppressWarnings({"deprecation"})
-  @Test
-  public void testHeadlessGfshTest()
-      throws ClassNotFoundException, IOException, InterruptedException {
-    int port = getRandomAvailablePort(SOCKET);
+  @Before
+  public void setup() throws IOException, ClassNotFoundException {
+    port = getRandomAvailablePort(SOCKET);
 
     Properties properties = new Properties();
     properties.put(NAME, this.testName.getMethodName());
@@ -59,11 +71,24 @@ public class HeadlessGfshIntegrationTest {
     properties.put(HTTP_SERVICE_PORT, "0");
     properties.put(MCAST_PORT, "0");
 
-    DistributedSystem ds = DistributedSystem.connect(properties);
-    GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.create(ds);
+    ds = DistributedSystem.connect(properties);
+    cache = (GemFireCacheImpl) CacheFactory.create(ds);
 
-    HeadlessGfsh gfsh = new HeadlessGfsh("Test", 25,
+    gfsh = new HeadlessGfsh("Test", 25,
         this.temporaryFolder.newFolder("gfsh_files").getCanonicalPath());
+  }
+
+  @SuppressWarnings({"deprecation"})
+  @After
+  public void cleanup() {
+    gfsh.terminate();
+    cache.close();
+    ds.disconnect();
+  }
+
+  @Test
+  public void testHeadlessGfshTest() throws InterruptedException {
+
     for (int i = 0; i < 5; i++) {
       gfsh.executeCommand("connect --jmx-manager=localhost[" + port + "]");
       Object result = gfsh.getResult();
@@ -83,9 +108,19 @@ public class HeadlessGfshIntegrationTest {
     gfsh.getResult();
     long l3 = System.currentTimeMillis();
     System.out.println("L3-l2=" + (l3 - l2) + " Total time= " + (l3 - l1) / 1000);
-    gfsh.terminate();
-    cache.close();
-    ds.disconnect();
   }
 
+  @Test
+  public void testStringResultReturnedAsCommandResult() throws InterruptedException {
+    gfsh.clear();
+    gfsh.executeCommand("list members");
+
+    LinkedBlockingQueue headlessQueue = gfsh.getQueue();
+    headlessQueue.clear();
+    headlessQueue.put("ERROR RESULT");
+    Object result = gfsh.getResult();
+    assertNotNull(result);
+    assertTrue(((CommandResult) result).getStatus() == Result.Status.ERROR);
+    System.out.println(((CommandResult) result).toString());
+  }
 }


[17/51] [abbrv] geode git commit: GEODE-2142: Refactoring of tests to work with new JSONObject class. Changing file export to use Base64 encoding.

Posted by ds...@apache.org.
GEODE-2142: Refactoring of tests to work with new JSONObject class.
Changing file export to use Base64 encoding.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/7c8794cb
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/7c8794cb
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/7c8794cb

Branch: refs/heads/feature/GEM-1195
Commit: 7c8794cb8889d1c2847545bfcfeaea6d6c17e515
Parents: fdde618
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Feb 17 15:12:55 2017 -0800
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Mon Feb 27 07:18:55 2017 -0800

----------------------------------------------------------------------
 .../geode/management/internal/cli/CliUtil.java  |  5 --
 .../internal/cli/result/AbstractResultData.java | 56 ++++++++------------
 2 files changed, 21 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/7c8794cb/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
index 8525b58..8cd098d 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
@@ -440,11 +440,6 @@ public class CliUtil {
 
       compressedDataLength = compresser.deflate(buffer);
       totalCompressedDataLength += compressedDataLength;
-      // System.out.println(compressedDataLength);
-      // System.out.println("uc: b "+buffer.length);
-      // System.out.println("uc: r "+result.length);
-      // System.out.println("uc: nr "+newResult.length);
-      // System.out.println();
       System.arraycopy(buffer, 0, newResult, result.length, buffer.length);
       result = newResult;
     } while (compressedDataLength != 0);

http://git-wip-us.apache.org/repos/asf/geode/blob/7c8794cb/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
index e08d9b7..81ab511 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/AbstractResultData.java
@@ -20,7 +20,10 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 import java.text.MessageFormat;
+import java.util.Base64;
 import java.util.zip.DataFormatException;
 
 import org.apache.geode.management.cli.Result.Status;
@@ -151,26 +154,10 @@ public abstract class AbstractResultData implements ResultData {
     if (addTimeStampToName) {
       fileName = addTimeStampBeforeLastDot(fileName);
     }
-    return addAsFile(fileName.getBytes(), bytes, fileType, message);
+    return addAsFile(fileName, bytes, fileType, message);
   }
 
-  public ResultData addByteDataFromFileFile(String filePath, int fileType, String message,
-      boolean addTimeStampToName) throws FileNotFoundException, IOException {
-    byte[][] filesToBytes = CliUtil.filesToBytes(new String[] {filePath});
-
-    byte[] bytes = filesToBytes[0];
-    if (addTimeStampToName) {
-      String fileName = new String(filesToBytes[0]);
-      fileName = addTimeStampBeforeLastDot(fileName);
-      bytes = fileName.getBytes();
-    }
-    return addAsFile(bytes, filesToBytes[1], fileType, message);
-  }
-
-  private ResultData addAsFile(byte[] fileName, byte[] data, int fileType, String message) {
-    // System.out.println("fileType :: "+fileType);
-    // System.out.println("FILE_TYPE_BINARY :: "+FILE_TYPE_BINARY);
-    // System.out.println("FILE_TYPE_TEXT :: "+FILE_TYPE_TEXT);
+  private ResultData addAsFile(String fileName, byte[] data, int fileType, String message) {
     if (fileType != FILE_TYPE_BINARY && fileType != FILE_TYPE_TEXT) {
       throw new IllegalArgumentException("Unsupported file type is specified.");
     }
@@ -186,14 +173,12 @@ public abstract class AbstractResultData implements ResultData {
 
       sectionData.put(FILE_NAME_FIELD, fileName);
       sectionData.put(FILE_TYPE_FIELD, fileType);
-      sectionData.put(FILE_MESSAGE, message.getBytes());
-      sectionData.putAsJSONObject(FILE_DATA_FIELD, CliUtil.compressBytes(data));
-      // System.out.println(data);
-      // sectionData.put(FILE_DATA_FIELD, Base64.encodeBytes(data, Base64.GZIP));
+      sectionData.put(FILE_MESSAGE, message);
+      DeflaterInflaterData deflaterInflaterData = CliUtil.compressBytes(data);
+      sectionData.put(FILE_DATA_FIELD, Base64.getEncoder().encodeToString(deflaterInflaterData.getData()));
+      sectionData.put(DATA_LENGTH_FIELD,deflaterInflaterData.getDataLength());
     } catch (GfJsonException e) {
       throw new ResultDataException(e.getMessage());
-      // } catch (IOException e) {
-      // e.printStackTrace();
     }
     return this;
   }
@@ -223,29 +208,30 @@ public abstract class AbstractResultData implements ResultData {
 
       // build file name
       byte[] fileNameBytes = null;
+      String fileName = null;
       GfJsonArray fileNameJsonBytes = object.getJSONArray(FILE_NAME_FIELD);
       if (fileNameJsonBytes != null) { // if in gfsh
         fileNameBytes = GfJsonArray.toByteArray(fileNameJsonBytes);
+        fileName = new String(fileNameBytes);
       } else { // if on member
-        fileNameBytes = (byte[]) object.get(FILE_NAME_FIELD);
+        fileName = (String) object.get(FILE_NAME_FIELD);
       }
-      String fileName = new String(fileNameBytes);
 
       // build file message
       byte[] fileMessageBytes = null;
+      String fileMessage = null;
       GfJsonArray fileMessageJsonBytes = object.getJSONArray(FILE_MESSAGE);
       if (fileMessageJsonBytes != null) { // if in gfsh
         fileMessageBytes = GfJsonArray.toByteArray(fileMessageJsonBytes);
+        fileMessage = new String(fileMessageBytes);
       } else { // if on member
-        fileMessageBytes = (byte[]) object.get(FILE_MESSAGE);
+        fileMessage = (String) object.get(FILE_MESSAGE);
       }
-      String fileMessage = new String(fileMessageBytes);
 
-      GfJsonObject fileDataBytes = object.getJSONObject(FILE_DATA_FIELD);
-      byte[] byteArray = GfJsonArray.toByteArray(fileDataBytes.getJSONArray(DATA_FIELD));
-      int dataLength = fileDataBytes.getInt(DATA_LENGTH_FIELD);
-      DeflaterInflaterData uncompressBytes = CliUtil.uncompressBytes(byteArray, dataLength);
-      byte[] uncompressed = uncompressBytes.getData();
+      String fileDataString = (String) object.get(FILE_DATA_FIELD);
+      int fileDataLength = (int) object.get(DATA_LENGTH_FIELD);
+      byte[] byteArray = Base64.getDecoder().decode(fileDataString);
+      byte[] uncompressBytes = CliUtil.uncompressBytes(byteArray,fileDataLength).getData();
 
       boolean isGfshVM = CliUtil.isGfshVM();
       File fileToDumpData = new File(fileName);
@@ -299,13 +285,13 @@ public abstract class AbstractResultData implements ResultData {
       if (fileType == FILE_TYPE_TEXT) {
         FileWriter fw = new FileWriter(fileToDumpData);
         BufferedWriter bw = new BufferedWriter(fw);
-        bw.write(new String(uncompressed));
+        bw.write(new String(uncompressBytes));
         bw.flush();
         fw.flush();
         fw.close();
       } else if (fileType == FILE_TYPE_BINARY) {
         FileOutputStream fos = new FileOutputStream(fileToDumpData);
-        fos.write(uncompressed);
+        fos.write(uncompressBytes);
         fos.flush();
         fos.close();
       }


[39/51] [abbrv] geode git commit: Revert "GEODE-2562 Revise Main Features paragraph per review"

Posted by ds...@apache.org.
Revert "GEODE-2562 Revise Main Features paragraph per review"

This reverts commit c0d43b35ee78dfbfb2fee767bc552ed924da6eb7.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/81276592
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/81276592
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/81276592

Branch: refs/heads/feature/GEM-1195
Commit: 812765920cd4ff5a7a950e00a1626e64e379b2e8
Parents: 45c150d
Author: Karen Miller <km...@pivotal.io>
Authored: Wed Mar 1 16:00:51 2017 -0800
Committer: Karen Miller <km...@pivotal.io>
Committed: Wed Mar 1 16:00:51 2017 -0800

----------------------------------------------------------------------
 geode-docs/getting_started/product_intro.html.md.erb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/81276592/geode-docs/getting_started/product_intro.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/getting_started/product_intro.html.md.erb b/geode-docs/getting_started/product_intro.html.md.erb
index 063fd08..103b2dd 100644
--- a/geode-docs/getting_started/product_intro.html.md.erb
+++ b/geode-docs/getting_started/product_intro.html.md.erb
@@ -37,8 +37,7 @@ This section summarizes main features and key functionality.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_CF0E3E5C4F884374B8F2F536DD2A375C" class="no-quick-link"></a>High Read-and-Write Throughput
 
-Concurrent main-memory data structures and a highly optimized distribution infrastructure provide read-and-write throughput.
-Applications can make copies of data dynamically in memory through synchronous or asynchronous replication for high read throughput or partition the data across many system members to achieve high read-and-write throughput. Data partitioning doubles the aggregate throughput if the data access is fairly balanced across the entire data set. Linear increase in throughput is limited only by the backbone network capacity.
+Read-and-write throughput is provided by concurrent main-memory data structures and a highly optimized distribution infrastructure. Applications can make copies of data dynamically in memory through synchronous or asynchronous replication for high read throughput or partition the data across many system members to achieve high read-and-write throughput. Data partitioning doubles the aggregate throughput if the data access is fairly balanced across the entire data set. Linear increase in throughput is limited only by the backbone network capacity.
 
 ## <a id="concept_3B5E445B19884680900161BDF25E32C9__section_9C5D669B583646F1B817284EB494DDA7" class="no-quick-link"></a>Low and Predictable Latency
 


[27/51] [abbrv] geode git commit: GEODE-2526: Enhance log statement to include ResourceTypeName

Posted by ds...@apache.org.
GEODE-2526: Enhance log statement to include ResourceTypeName

This closes #406


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/fb1fdf90
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/fb1fdf90
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/fb1fdf90

Branch: refs/heads/feature/GEM-1195
Commit: fb1fdf90198e4767114e32c53c9fc61ceb4c4645
Parents: 4fbc641
Author: Srikanth Manvi <sr...@gmail.com>
Authored: Wed Feb 22 17:15:43 2017 -0500
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Feb 28 15:32:59 2017 -0800

----------------------------------------------------------------------
 .../org/apache/geode/internal/statistics/StatArchiveReader.java  | 4 ++--
 .../StatArchiveWithMissingResourceTypeRegressionTest.java        | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/fb1fdf90/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java
index 9fba511..65e4370 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java
@@ -3230,8 +3230,8 @@ public class StatArchiveReader implements StatArchiveFormat {
       }
       ResourceType type = resourceTypeTable[resourceTypeId];
       if (type == null) {
-        throw new IllegalStateException(
-            "ResourceType is missing for resourceTypeId " + resourceTypeId);
+        throw new IllegalStateException("ResourceType is missing for resourceTypeId "
+            + resourceTypeId + ", resourceName " + name);
       }
       boolean loadInstance = loadInstance(name, id, resourceTypeTable[resourceTypeId]);
       resourceInstTable[resourceInstId] = new ResourceInst(this, resourceInstId, name, id,

http://git-wip-us.apache.org/repos/asf/geode/blob/fb1fdf90/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java b/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java
index 73d6739..7a265d6 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java
@@ -59,7 +59,8 @@ public class StatArchiveWithMissingResourceTypeRegressionTest {
   public void throwsIllegalStateExceptionWithMessage() throws Exception {
     assertThatThrownBy(() -> new StatArchiveReader(new File[] {this.archiveFile}, null, true))
         .isExactlyInstanceOf(IllegalStateException.class) // was NullPointerException
-        .hasMessage("ResourceType is missing for resourceTypeId 0"); // was null
+        .hasMessageStartingWith("ResourceType is missing for resourceTypeId 0")
+        .hasMessageContaining("resourceName statistics1");
   }
 
 }


[30/51] [abbrv] geode git commit: GEODE-2538: Don't deserialize values on the server when getting results

Posted by ds...@apache.org.
GEODE-2538: Don't deserialize values on the server when getting results

If values on the server are in serialized form, leave them that way and
only deserialize the values on the clients.

This is implemented by having the LuceneGetPageFunction extract the
serialized value and return the results in a new PageResults class,
which handles the deserialization and upwrapping of the value if
necessary.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/8b762bed
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/8b762bed
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/8b762bed

Branch: refs/heads/feature/GEM-1195
Commit: 8b762bede8e064704ea67ba986491184066c2b56
Parents: b5cbaed
Author: Dan Smith <up...@apache.org>
Authored: Mon Feb 27 18:03:18 2017 -0800
Committer: Dan Smith <up...@apache.org>
Committed: Tue Feb 28 17:41:04 2017 -0800

----------------------------------------------------------------------
 .../geode/internal/DataSerializableFixedID.java |  1 +
 .../lucene/internal/LuceneServiceImpl.java      |  3 +
 .../internal/results/LuceneGetPageFunction.java | 55 +++++------
 .../internal/results/MapResultCollector.java    | 11 ++-
 .../lucene/internal/results/PageEntry.java      | 98 ++++++++++++++++++++
 .../lucene/internal/results/PageResults.java    | 60 ++++++++++++
 .../results/LuceneGetPageFunctionJUnitTest.java | 12 ++-
 .../internal/results/PageEntryJUnitTest.java    | 93 +++++++++++++++++++
 .../internal/results/PageResultsJUnitTest.java  | 44 +++++++++
 9 files changed, 336 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
index 457af2f..63a95a5 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/DataSerializableFixedID.java
@@ -810,6 +810,7 @@ public interface DataSerializableFixedID extends SerializationVersions {
   public static final short LUCENE_TOP_ENTRIES_COLLECTOR = 2176;
   public static final short WAIT_UNTIL_FLUSHED_FUNCTION_CONTEXT = 2177;
   public static final short DESTROY_LUCENE_INDEX_MESSAGE = 2178;
+  public static final short LUCENE_PAGE_RESULTS = 2179;
 
   // NOTE, codes > 65535 will take 4 bytes to serialize
 

http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index dd32000..a1a6ef3 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -22,6 +22,7 @@ import org.apache.geode.cache.lucene.internal.distributed.LuceneQueryFunction;
 import org.apache.geode.cache.lucene.internal.management.LuceneServiceMBean;
 import org.apache.geode.cache.lucene.internal.management.ManagementIndexListener;
 import org.apache.geode.cache.lucene.internal.results.LuceneGetPageFunction;
+import org.apache.geode.cache.lucene.internal.results.PageResults;
 import org.apache.geode.management.internal.beans.CacheServiceMBeanBase;
 import org.apache.logging.log4j.Logger;
 import org.apache.lucene.analysis.Analyzer;
@@ -373,6 +374,8 @@ public class LuceneServiceImpl implements InternalLuceneService {
 
     DSFIDFactory.registerDSFID(DataSerializableFixedID.DESTROY_LUCENE_INDEX_MESSAGE,
         DestroyLuceneIndexMessage.class);
+
+    DSFIDFactory.registerDSFID(DataSerializableFixedID.LUCENE_PAGE_RESULTS, PageResults.class);
   }
 
   public Collection<LuceneIndexCreationProfile> getAllDefinedIndexes() {

http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java
index f5c2b99..0addf48 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunction.java
@@ -15,40 +15,18 @@
 
 package org.apache.geode.cache.lucene.internal.results;
 
-import org.apache.geode.cache.EntryDestroyedException;
 import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Region.Entry;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.cache.execute.FunctionException;
 import org.apache.geode.cache.execute.RegionFunctionContext;
-import org.apache.geode.cache.execute.ResultSender;
-import org.apache.geode.cache.lucene.LuceneQueryException;
-import org.apache.geode.cache.lucene.LuceneQueryProvider;
-import org.apache.geode.cache.lucene.LuceneService;
-import org.apache.geode.cache.lucene.LuceneServiceProvider;
-import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
-import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
-import org.apache.geode.cache.lucene.internal.distributed.CollectorManager;
-import org.apache.geode.cache.lucene.internal.distributed.LuceneFunctionContext;
-import org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollector;
-import org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollectorManager;
-import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
-import org.apache.geode.cache.lucene.internal.repository.IndexResultCollector;
-import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
 import org.apache.geode.cache.partition.PartitionRegionHelper;
 import org.apache.geode.internal.InternalEntity;
-import org.apache.geode.internal.cache.BucketNotFoundException;
-import org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException;
+import org.apache.geode.internal.cache.EntrySnapshot;
+import org.apache.geode.internal.cache.Token;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.logging.log4j.Logger;
-import org.apache.lucene.search.Query;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -67,22 +45,31 @@ public class LuceneGetPageFunction implements Function, InternalEntity {
     Region region = PartitionRegionHelper.getLocalDataForContext(ctx);
     Set<?> keys = ctx.getFilter();
 
-    Map<Object, Object> results = new HashMap<>(keys.size());
+    List<PageEntry> results = new PageResults(keys.size());
 
     for (Object key : keys) {
-      final Entry entry = region.getEntry(key);
-      try {
-        Object value = entry == null ? null : entry.getValue();
-        if (value != null) {
-          results.put(key, value);
-        }
-      } catch (EntryDestroyedException e) {
-        // skip
+      PageEntry entry = getEntry(region, key);
+      if (entry != null) {
+        results.add(entry);
       }
     }
     ctx.getResultSender().lastResult(results);
   }
 
+  protected PageEntry getEntry(final Region region, final Object key) {
+    final EntrySnapshot entry = (EntrySnapshot) region.getEntry(key);
+    if (entry == null) {
+      return null;
+    }
+
+    final Object value = entry.getRegionEntry().getValue(null);
+    if (value == null || Token.isInvalidOrRemoved(value)) {
+      return null;
+    }
+
+    return new PageEntry(key, value);
+  }
+
 
   @Override
   public String getId() {

http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java
index 9264126..0a9b110 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/MapResultCollector.java
@@ -19,10 +19,11 @@ import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-public class MapResultCollector implements ResultCollector<Map<?, ?>, Map<Object, Object>> {
+public class MapResultCollector implements ResultCollector<List<PageEntry>, Map<Object, Object>> {
   private final Map<Object, Object> results = new HashMap<>();
 
   @Override
@@ -37,9 +38,11 @@ public class MapResultCollector implements ResultCollector<Map<?, ?>, Map<Object
   }
 
   @Override
-  public void addResult(final DistributedMember memberID, final Map<?, ?> resultOfSingleExecution) {
-    this.results.putAll(resultOfSingleExecution);
-
+  public void addResult(final DistributedMember memberID,
+      final List<PageEntry> resultOfSingleExecution) {
+    for (PageEntry entry : resultOfSingleExecution) {
+      results.put(entry.getKey(), entry.getValue());
+    }
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/PageEntry.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/PageEntry.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/PageEntry.java
new file mode 100644
index 0000000..1f52c2e
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/PageEntry.java
@@ -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 org.apache.geode.cache.lucene.internal.results;
+
+import org.apache.geode.DataSerializable;
+import org.apache.geode.DataSerializer;
+import org.apache.geode.internal.cache.CachedDeserializable;
+import org.apache.geode.internal.offheap.StoredObject;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+public class PageEntry {
+
+  public Object key;
+  public Object value;
+
+  public PageEntry() {}
+
+  public PageEntry(final Object key, final Object value) {
+    this.key = key;
+    this.value = value;
+  }
+
+  public Object getKey() {
+    return key;
+  }
+
+  public Object getValue() {
+    if (value instanceof CachedDeserializable) {
+      return ((CachedDeserializable) value).getDeserializedValue(null, null);
+    }
+
+    return value;
+  }
+
+  public void toData(final DataOutput out) throws IOException {
+
+    DataSerializer.writeObject(key, out);
+    if (value instanceof StoredObject) {
+      ((StoredObject) value).sendTo(out);
+      return;
+    }
+
+    if (value instanceof CachedDeserializable) {
+      value = ((CachedDeserializable) value).getValue();
+      if (value instanceof byte[]) {
+        out.write((byte[]) value);
+        return;
+      }
+    }
+
+    DataSerializer.writeObject(value, out);
+  }
+
+  public void fromData(final DataInput in) throws IOException, ClassNotFoundException {
+    key = DataSerializer.readObject(in);
+    value = DataSerializer.readObject(in);
+  }
+
+  @Override
+  public boolean equals(final Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    final PageEntry pageEntry = (PageEntry) o;
+
+    if (!getKey().equals(pageEntry.getKey())) {
+      return false;
+    }
+    return getValue().equals(pageEntry.getValue());
+
+  }
+
+  @Override
+  public int hashCode() {
+    int result = getKey().hashCode();
+    result = 31 * result + getValue().hashCode();
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/PageResults.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/PageResults.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/PageResults.java
new file mode 100644
index 0000000..fcacff2
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/results/PageResults.java
@@ -0,0 +1,60 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.results;
+
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.Version;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class PageResults extends ArrayList<PageEntry> implements DataSerializableFixedID {
+
+  public PageResults(final int initialCapacity) {
+    super(initialCapacity);
+  }
+
+  public PageResults() {}
+
+  @Override
+  public int getDSFID() {
+    return DataSerializableFixedID.LUCENE_PAGE_RESULTS;
+  }
+
+  @Override
+  public void toData(final DataOutput out) throws IOException {
+    out.writeInt(this.size());
+    for (PageEntry entry : this) {
+      entry.toData(out);
+    }
+  }
+
+  @Override
+  public void fromData(final DataInput in) throws IOException, ClassNotFoundException {
+    int size = in.readInt();
+    for (int i = 0; i < size; i++) {
+      PageEntry entry = new PageEntry();
+      entry.fromData(in);
+      add(entry);
+    }
+  }
+
+  @Override
+  public Version[] getSerializationVersions() {
+    return new Version[0];
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java
index c62082c..5f1ca3f 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/LuceneGetPageFunctionJUnitTest.java
@@ -26,7 +26,9 @@ import org.apache.geode.cache.Region.Entry;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.RegionFunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.internal.cache.EntrySnapshot;
 import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.RegionEntry;
 import org.apache.geode.internal.cache.execute.InternalRegionFunctionContext;
 import org.apache.geode.test.junit.categories.UnitTest;
 import org.junit.Test;
@@ -47,13 +49,17 @@ public class LuceneGetPageFunctionJUnitTest {
     when(context.getResultSender()).thenReturn(resultSender);
     LuceneGetPageFunction function = new LuceneGetPageFunction();
     when(context.getLocalDataSet(any())).thenReturn(region);
-    final Entry entry = mock(Entry.class);
+    final EntrySnapshot entry = mock(EntrySnapshot.class);
     when(region.getEntry(any())).thenReturn(entry);
-    when(entry.getValue()).thenReturn("value");
+    final RegionEntry regionEntry = mock(RegionEntry.class);
+    when(entry.getRegionEntry()).thenReturn(regionEntry);
+    when(regionEntry.getValue(any())).thenReturn("value");
     when(context.getFilter()).thenReturn((Set) Collections.singleton("key"));
     function.execute(context);
 
-    verify(resultSender).lastResult(eq(Collections.singletonMap("key", "value")));
+    PageResults expectedResults = new PageResults();
+    expectedResults.add(new PageEntry("key", "value"));
+    verify(resultSender).lastResult(eq(expectedResults));
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/PageEntryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/PageEntryJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/PageEntryJUnitTest.java
new file mode 100644
index 0000000..6e26942
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/PageEntryJUnitTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.results;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.geode.internal.ByteArrayDataInput;
+import org.apache.geode.internal.HeapDataOutputStream;
+import org.apache.geode.internal.Version;
+import org.apache.geode.internal.cache.CachedDeserializable;
+import org.apache.geode.internal.cache.PreferBytesCachedDeserializable;
+import org.apache.geode.internal.util.BlobHelper;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+@Category(UnitTest.class)
+public class PageEntryJUnitTest {
+
+  @Test
+  public void getValueShouldReturnObjectValue() {
+    PageEntry entry = new PageEntry("key", "value");
+    assertEquals("value", entry.getValue());
+  }
+
+  @Test
+  public void getValueShouldReturnObjectFromCachedDeserializableValue() {
+    CachedDeserializable cachedDeserializable = new PreferBytesCachedDeserializable("value");
+    PageEntry entry = new PageEntry("key", cachedDeserializable);
+    assertEquals("value", entry.getValue());
+  }
+
+  @Test
+  public void getValueShouldReturnBytesFromBytesValue() {
+    byte[] bytes = new byte[10];
+    Arrays.fill(bytes, (byte) 5);
+    PageEntry entry = new PageEntry("key", bytes);
+    assertArrayEquals(bytes, (byte[]) entry.getValue());
+  }
+
+  @Test
+  public void serializationWithObjectValueShouldNotModifyValue()
+      throws IOException, ClassNotFoundException {
+    PageEntry entry = new PageEntry("key", "value");
+    assertEquals("value", copy(entry).getValue());
+  }
+
+  @Test
+  public void serializationReturnObjectFromCachedDeserializableValue()
+      throws IOException, ClassNotFoundException {
+    CachedDeserializable cachedDeserializable = new PreferBytesCachedDeserializable("value");
+    PageEntry entry = new PageEntry("key", cachedDeserializable);
+    assertEquals("value", copy(entry).getValue());
+  }
+
+  @Test
+  public void serializationShouldReturnsBytesFromByteValue()
+      throws IOException, ClassNotFoundException {
+    byte[] bytes = new byte[10];
+    Arrays.fill(bytes, (byte) 5);
+    PageEntry entry = new PageEntry("key", bytes);
+    assertArrayEquals(bytes, (byte[]) copy(entry).getValue());
+  }
+
+  public PageEntry copy(PageEntry entry) throws IOException, ClassNotFoundException {
+    HeapDataOutputStream out = new HeapDataOutputStream((Version) null);
+    entry.toData(out);
+    final byte[] bytes = out.toByteArray();
+    ByteArrayDataInput in = new ByteArrayDataInput();
+    in.initialize(bytes, null);
+    PageEntry newEntry = new PageEntry();
+    newEntry.fromData(in);
+    return newEntry;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/8b762bed/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/PageResultsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/PageResultsJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/PageResultsJUnitTest.java
new file mode 100644
index 0000000..778e372
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/results/PageResultsJUnitTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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 org.apache.geode.cache.lucene.internal.results;
+
+import static org.junit.Assert.*;
+
+import org.apache.geode.internal.DSFIDFactory;
+import org.apache.geode.internal.DataSerializableFixedID;
+import org.apache.geode.internal.util.BlobHelper;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+
+@Category(UnitTest.class)
+public class PageResultsJUnitTest {
+
+  @Test
+  public void serializationShouldNotChangeObject() throws IOException, ClassNotFoundException {
+    DSFIDFactory.registerDSFID(DataSerializableFixedID.LUCENE_PAGE_RESULTS, PageResults.class);
+    PageResults results = new PageResults();
+    results.add(new PageEntry("key1", "value1"));
+    results.add(new PageEntry("key2", "value2"));
+
+    byte[] serialized = BlobHelper.serializeToBlob(results);
+    PageResults newResults = (PageResults) BlobHelper.deserializeBlob(serialized);
+
+    assertEquals(newResults, results);
+  }
+
+}


[04/51] [abbrv] geode git commit: GEODE-2142: Adding JSON library from the https://github.com/tdunning/open-json project

Posted by ds...@apache.org.
GEODE-2142: Adding JSON library from the https://github.com/tdunning/open-json project


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/b34e47ff
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/b34e47ff
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/b34e47ff

Branch: refs/heads/feature/GEM-1195
Commit: b34e47ffaa92007cf059ae5257e481bfb048bfb3
Parents: a2f47b7
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Feb 17 14:30:37 2017 -0800
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Mon Feb 27 07:18:55 2017 -0800

----------------------------------------------------------------------
 geode-json/build.gradle                         |   22 +
 geode-json/src/main/java/org/json/JSON.java     |  116 ++
 .../src/main/java/org/json/JSONArray.java       |  759 +++++++++++
 .../src/main/java/org/json/JSONException.java   |   57 +
 .../src/main/java/org/json/JSONObject.java      |  993 +++++++++++++++
 .../src/main/java/org/json/JSONString.java      |   18 +
 .../src/main/java/org/json/JSONStringer.java    |  470 +++++++
 .../src/main/java/org/json/JSONTokener.java     |  658 ++++++++++
 geode-json/src/test/java/org/json/FileTest.java |  287 +++++
 .../src/test/java/org/json/JSONArrayTest.java   |  608 +++++++++
 .../java/org/json/JSONFunctionTestObject.java   |   17 +
 .../src/test/java/org/json/JSONObjectTest.java  | 1198 ++++++++++++++++++
 .../test/java/org/json/JSONStringerTest.java    |  421 ++++++
 .../src/test/java/org/json/JSONTokenerTest.java |  621 +++++++++
 .../src/test/java/org/json/ParsingTest.java     |  294 +++++
 .../src/test/java/org/json/SelfUseTest.java     |  276 ++++
 geode-json/src/test/resources/sample-01.json    |  227 ++++
 17 files changed, 7042 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/build.gradle
----------------------------------------------------------------------
diff --git a/geode-json/build.gradle b/geode-json/build.gradle
new file mode 100644
index 0000000..5715685
--- /dev/null
+++ b/geode-json/build.gradle
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+dependencies {
+    compile project(':geode-core')
+    compile project(':geode-common')
+    testCompile files(project(':geode-core').sourceSets.test.output)
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/main/java/org/json/JSON.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSON.java b/geode-json/src/main/java/org/json/JSON.java
new file mode 100755
index 0000000..1b32e69
--- /dev/null
+++ b/geode-json/src/main/java/org/json/JSON.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+class JSON {
+    /**
+     * Returns the input if it is a JSON-permissible value; throws otherwise.
+     */
+    static double checkDouble(double d) throws JSONException {
+        if (Double.isInfinite(d) || Double.isNaN(d)) {
+            throw new JSONException("Forbidden numeric value: " + d);
+        }
+        return d;
+    }
+
+    static Boolean toBoolean(Object value) {
+        if (value instanceof Boolean) {
+            return (Boolean) value;
+        } else if (value instanceof String) {
+            String stringValue = (String) value;
+            if ("true".equalsIgnoreCase(stringValue)) {
+                return true;
+            } else if ("false".equalsIgnoreCase(stringValue)) {
+                return false;
+            }
+        }
+        return null;
+    }
+
+    static Double toDouble(Object value) {
+        if (value instanceof Double) {
+            return (Double) value;
+        } else if (value instanceof Number) {
+            return ((Number) value).doubleValue();
+        } else if (value instanceof String) {
+            try {
+                return Double.valueOf((String) value);
+            } catch (NumberFormatException ignored) {
+            }
+        }
+        return null;
+    }
+
+    static Integer toInteger(Object value) {
+        if (value instanceof Integer) {
+            return (Integer) value;
+        } else if (value instanceof Number) {
+            return ((Number) value).intValue();
+        } else if (value instanceof String) {
+            try {
+                return (int) Double.parseDouble((String) value);
+            } catch (NumberFormatException ignored) {
+            }
+        }
+        return null;
+    }
+
+    static Long toLong(Object value) {
+        if (value instanceof Long) {
+            return (Long) value;
+        } else if (value instanceof Number) {
+            return ((Number) value).longValue();
+        } else if (value instanceof String) {
+            try {
+                return (long) Double.parseDouble((String) value);
+            } catch (NumberFormatException ignored) {
+            }
+        }
+        return null;
+    }
+
+    static String toString(Object value) {
+        if (value instanceof String) {
+            return (String) value;
+        } else if (value != null) {
+            return String.valueOf(value);
+        }
+        return null;
+    }
+
+    public static JSONException typeMismatch(Object indexOrName, Object actual,
+            String requiredType) throws JSONException {
+        if (actual == null) {
+            throw new JSONException("Value at " + indexOrName + " is null.");
+        } else {
+            throw new JSONException("Value " + actual + " at " + indexOrName
+                    + " of type " + actual.getClass().getName()
+                    + " cannot be converted to " + requiredType);
+        }
+    }
+
+    public static JSONException typeMismatch(Object actual, String requiredType)
+            throws JSONException {
+        if (actual == null) {
+            throw new JSONException("Value is null.");
+        } else {
+            throw new JSONException("Value " + actual
+                    + " of type " + actual.getClass().getName()
+                    + " cannot be converted to " + requiredType);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/main/java/org/json/JSONArray.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONArray.java b/geode-json/src/main/java/org/json/JSONArray.java
new file mode 100755
index 0000000..074624d
--- /dev/null
+++ b/geode-json/src/main/java/org/json/JSONArray.java
@@ -0,0 +1,759 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+// Note: this class was written without inspecting the non-free org.json sourcecode.
+
+/**
+ * A dense indexed sequence of values. Values may be any mix of
+ * {@link JSONObject JSONObjects}, other {@link JSONArray JSONArrays}, Strings,
+ * Booleans, Integers, Longs, Doubles, {@code null} or {@link JSONObject#NULL}.
+ * Values may not be {@link Double#isNaN() NaNs}, {@link Double#isInfinite()
+ * infinities}, or of any type not listed here.
+ *
+ * {@code JSONArray} has the same type coercion behavior and
+ * optional/mandatory accessors as {@link JSONObject}. See that class'
+ * documentation for details.
+ *
+ * <strong>Warning:</strong> this class represents null in two incompatible
+ * ways: the standard Java {@code null} reference, and the sentinel value {@link
+ * JSONObject#NULL}. In particular, {@code get} fails if the requested index
+ * holds the null reference, but succeeds if it holds {@code JSONObject.NULL}.
+ *
+ * Instances of this class are not thread safe. Although this class is
+ * non-final, it was not designed for inheritance and should not be subclassed.
+ * In particular, self-use by overridable methods is not specified. See
+ * <i>Effective Java</i> Item 17, "Design and Document or inheritance or else
+ * prohibit it" for further information.
+ */
+public class JSONArray {
+
+    private final List<Object> values;
+
+    /**
+     * Creates a {@code JSONArray} with no values.
+     */
+    public JSONArray() {
+        values = new ArrayList<Object>();
+    }
+
+    /**
+     * Creates a new {@code JSONArray} by copying all values from the given
+     * collection.
+     *
+     * @param copyFrom a collection whose values are of supported types.
+     *                 Unsupported values are not permitted and will yield an array in an
+     *                 inconsistent state.
+     */
+    /* Accept a raw type for API compatibility */
+    public JSONArray(Collection<?> copyFrom) {
+        this();
+        if (copyFrom != null) {
+            for (Object aCopyFrom : copyFrom) {
+                put(JSONObject.wrap(aCopyFrom));
+            }
+        }
+    }
+
+    /**
+     * Creates a new {@code JSONArray} with values from the next array in the
+     * tokener.
+     *
+     * @param readFrom a tokener whose nextValue() method will yield a
+     *                 {@code JSONArray}.
+     * @throws JSONException if the parse fails or doesn't yield a
+     *                       {@code JSONArray}.
+     */
+    public JSONArray(JSONTokener readFrom) throws JSONException {
+        /*
+         * Getting the parser to populate this could get tricky. Instead, just
+         * parse to temporary JSONArray and then steal the data from that.
+         */
+        Object object = readFrom.nextValue();
+        if (object instanceof JSONArray) {
+            values = ((JSONArray) object).values;
+        } else {
+            throw JSON.typeMismatch(object, "JSONArray");
+        }
+    }
+
+    /**
+     * Creates a new {@code JSONArray} with values from the JSON string.
+     *
+     * @param json a JSON-encoded string containing an array.
+     * @throws JSONException if the parse fails or doesn't yield a {@code
+     *                       JSONArray}.
+     */
+    public JSONArray(String json) throws JSONException {
+        this(new JSONTokener(json));
+    }
+
+    /**
+     * Creates a new {@code JSONArray} with values from the given primitive array.
+     *
+     * @param array The values to use.
+     * @throws JSONException if any of the values are non-finite double values (i.e. NaN or infinite)
+     */
+    public JSONArray(Object array) throws JSONException {
+        if (!array.getClass().isArray()) {
+            throw new JSONException("Not a primitive array: " + array.getClass());
+        }
+        final int length = Array.getLength(array);
+        values = new ArrayList<Object>(length);
+        for (int i = 0; i < length; ++i) {
+            put(JSONObject.wrap(Array.get(array, i)));
+        }
+    }
+
+    /**
+     * @return Returns the number of values in this array.
+     */
+    public int length() {
+        return values.size();
+    }
+
+    /**
+     * Appends {@code value} to the end of this array.
+     *
+     * @param value The value to append.
+     * @return this array.
+     */
+    public JSONArray put(boolean value) {
+        values.add(value);
+        return this;
+    }
+
+    /**
+     * Appends {@code value} to the end of this array.
+     *
+     * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
+     *              {@link Double#isInfinite() infinities}.
+     * @return this array.
+     * @throws JSONException If the value is unacceptable.
+     */
+    public JSONArray put(double value) throws JSONException {
+        values.add(JSON.checkDouble(value));
+        return this;
+    }
+
+    /**
+     * Appends {@code value} to the end of this array.
+     *
+     * @param value The value to append.
+     * @return this array.
+     */
+    public JSONArray put(int value) {
+        values.add(value);
+        return this;
+    }
+
+    /**
+     * Appends {@code value} to the end of this array.
+     *
+     * @param value The value to append.
+     * @return this array.
+     */
+    public JSONArray put(long value) {
+        values.add(value);
+        return this;
+    }
+
+    /**
+     * Appends {@code value} wrapped by {@link JSONArray} to the end of this array.
+     *
+     * @param value any collection.
+     * @return this array.
+     */
+    public JSONArray put(Collection<?> value) {
+        if (value == null) {
+            return put((Object)null);
+        }
+        values.add(new JSONArray(value));
+        return this;
+    }
+
+    /**
+     * Appends {@code value} to the end of this array.
+     *
+     * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
+     *              Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May
+     *              not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
+     *              infinities}. Unsupported values are not permitted and will cause the
+     *              array to be in an inconsistent state.
+     * @return this array.
+     */
+    public JSONArray put(Object value) {
+        values.add(value);
+        return this;
+    }
+
+    /**
+     * Same as {@link #put}, with added validity checks.
+     *
+     * @param value The value to append.
+     */
+    void checkedPut(Object value) throws JSONException {
+        if (value instanceof Number) {
+            JSON.checkDouble(((Number) value).doubleValue());
+        }
+
+        put(value);
+    }
+
+    /**
+     * Sets the value at {@code index} to {@code value}, null padding this array
+     * to the required length if necessary. If a value already exists at {@code
+     * index}, it will be replaced.
+     *
+     * @param index Where to put the value.
+     * @param value The value to set.
+     * @return this array.
+     * @throws JSONException This should never happen.
+     */
+    public JSONArray put(int index, boolean value) throws JSONException {
+        return put(index, (Boolean) value);
+    }
+
+    /**
+     * Sets the value at {@code index} to {@code value}, null padding this array
+     * to the required length if necessary. If a value already exists at {@code
+     * index}, it will be replaced.
+     *
+     * @param index Where to put the value.
+     * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
+     *              {@link Double#isInfinite() infinities}.
+     * @return this array.
+     * @throws JSONException If the value is not a finite value.
+     */
+    public JSONArray put(int index, double value) throws JSONException {
+        return put(index, (Double) value);
+    }
+
+    /**
+     * Sets the value at {@code index} to {@code value}, null padding this array
+     * to the required length if necessary. If a value already exists at {@code
+     * index}, it will be replaced.
+     *
+     * @param index Where to put the value.
+     * @param value The value to set.
+     * @return this array.
+     * @throws JSONException Should never actually happen.
+     */
+    public JSONArray put(int index, int value) throws JSONException {
+        return put(index, (Integer) value);
+    }
+
+    /**
+     * Sets the value at {@code index} to {@code value}, null padding this array
+     * to the required length if necessary. If a value already exists at {@code
+     * index}, it will be replaced.
+     *
+     * @param index Where to put the value.
+     * @param value The value to set.
+     * @return this array.
+     * @throws JSONException Should never actually happen.
+     */
+    public JSONArray put(int index, long value) throws JSONException {
+        return put(index, (Long) value);
+    }
+
+    /**
+     * Sets the value at {@code index} to {@code value} wrapped into {@link JSONArray},
+     * null padding this array to the required length if necessary. If a value already
+     * exists at {@code index}, it will be replaced.
+     *
+     * @param index Where to put the value.
+     * @param value The value to set.
+     * @return this array.
+     * @throws JSONException Should never actually happen.
+     */
+    public JSONArray put(int index, Collection<?> value) throws JSONException {
+        if (value == null) {
+            return put(index, (Object)null);
+        }
+        return put(index, new JSONArray(value));
+    }
+
+    /**
+     * Sets the value at {@code index} to {@code value}, null padding this array
+     * to the required length if necessary. If a value already exists at {@code
+     * index}, it will be replaced.
+     *
+     * @param index Where to put the value.
+     * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
+     *              Integer, Long, Double, {@link JSONObject#NULL}, or {@code null}. May
+     *              not be {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
+     *              infinities}.
+     * @return this array.
+     * @throws JSONException If the value cannot be represented as a finite double value.
+     */
+    public JSONArray put(int index, Object value) throws JSONException {
+        if (value instanceof Number) {
+            // deviate from the original by checking all Numbers, not just floats & doubles
+            JSON.checkDouble(((Number) value).doubleValue());
+        }
+        while (values.size() <= index) {
+            values.add(null);
+        }
+        values.set(index, value);
+        return this;
+    }
+
+    /**
+     * Returns true if this array has no value at {@code index}, or if its value
+     * is the {@code null} reference or {@link JSONObject#NULL}.
+     *
+     * @param index Which value to check.
+     * @return true if the value is null.
+     */
+    public boolean isNull(int index) {
+        Object value = opt(index);
+        return value == null || value == JSONObject.NULL;
+    }
+
+    /**
+     * Returns the value at {@code index}.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     * @throws JSONException if this array has no value at {@code index}, or if
+     *                       that value is the {@code null} reference. This method returns
+     *                       normally if the value is {@code JSONObject#NULL}.
+     */
+    public Object get(int index) throws JSONException {
+        try {
+            Object value = values.get(index);
+            if (value == null) {
+                throw new JSONException("Value at " + index + " is null.");
+            }
+            return value;
+        } catch (IndexOutOfBoundsException e) {
+            throw new JSONException("Index " + index + " out of range [0.." + values.size() + ")");
+        }
+    }
+
+    /**
+     * Returns the value at {@code index}, or null if the array has no value
+     * at {@code index}.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     */
+    public Object opt(int index) {
+        if (index < 0 || index >= values.size()) {
+            return null;
+        }
+        return values.get(index);
+    }
+
+    /**
+     * Removes and returns the value at {@code index}, or null if the array has no value
+     * at {@code index}.
+     *
+     * @param index Which value to remove.
+     * @return The value previously at the specified location.
+     */
+    public Object remove(int index) {
+        if (index < 0 || index >= values.size()) {
+            return null;
+        }
+        return values.remove(index);
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a boolean or can
+     * be coerced to a boolean.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     * @throws JSONException if the value at {@code index} doesn't exist or
+     *                       cannot be coerced to a boolean.
+     */
+    public boolean getBoolean(int index) throws JSONException {
+        Object object = get(index);
+        Boolean result = JSON.toBoolean(object);
+        if (result == null) {
+            throw JSON.typeMismatch(index, object, "boolean");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a boolean or can
+     * be coerced to a boolean. Returns false otherwise.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     */
+    public boolean optBoolean(int index) {
+        return optBoolean(index, false);
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a boolean or can
+     * be coerced to a boolean. Returns {@code fallback} otherwise.
+     *
+     * @param index    Which value to get.
+     * @param fallback the fallback value to return if no value exists.
+     * @return the value at the specified location or the fallback value.
+     */
+    public boolean optBoolean(int index, boolean fallback) {
+        Object object = opt(index);
+        Boolean result = JSON.toBoolean(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a double or can
+     * be coerced to a double.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     * @throws JSONException if the value at {@code index} doesn't exist or
+     *                       cannot be coerced to a double.
+     */
+    public double getDouble(int index) throws JSONException {
+        Object object = get(index);
+        Double result = JSON.toDouble(object);
+        if (result == null) {
+            throw JSON.typeMismatch(index, object, "double");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a double or can
+     * be coerced to a double. Returns {@code NaN} otherwise.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     */
+    public double optDouble(int index) {
+        return optDouble(index, Double.NaN);
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a double or can
+     * be coerced to a double. Returns {@code fallback} otherwise.
+     *
+     * @param index    Which value to get.
+     * @param fallback The fallback value to use if no value is at the specified location.
+     * @return the value at the specified location or the fallback value.
+     */
+    public double optDouble(int index, double fallback) {
+        Object object = opt(index);
+        Double result = JSON.toDouble(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is an int or
+     * can be coerced to an int.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     * @throws JSONException if the value at {@code index} doesn't exist or
+     *                       cannot be coerced to a int.
+     */
+    public int getInt(int index) throws JSONException {
+        Object object = get(index);
+        Integer result = JSON.toInteger(object);
+        if (result == null) {
+            throw JSON.typeMismatch(index, object, "int");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is an int or
+     * can be coerced to an int. Returns 0 otherwise.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     */
+    public int optInt(int index) {
+        return optInt(index, 0);
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is an int or
+     * can be coerced to an int. Returns {@code fallback} otherwise.
+     *
+     * @param index    Which value to get.
+     * @param fallback The fallback value to use if no value is at the specified location.
+     * @return the value at the specified location or the fallback value.
+     */
+    public int optInt(int index, int fallback) {
+        Object object = opt(index);
+        Integer result = JSON.toInteger(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a long or
+     * can be coerced to a long.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     * @throws JSONException if the value at {@code index} doesn't exist or
+     *                       cannot be coerced to a long.
+     */
+    public long getLong(int index) throws JSONException {
+        Object object = get(index);
+        Long result = JSON.toLong(object);
+        if (result == null) {
+            throw JSON.typeMismatch(index, object, "long");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a long or
+     * can be coerced to a long. Returns 0 otherwise.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     */
+    public long optLong(int index) {
+        return optLong(index, 0L);
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a long or
+     * can be coerced to a long. Returns {@code fallback} otherwise.
+     *
+     * @param index    Which value to get.
+     * @param fallback The fallback value to use if no value is at the specified location.
+     * @return the value at the specified location or the fallback value.
+     */
+    public long optLong(int index, long fallback) {
+        Object object = opt(index);
+        Long result = JSON.toLong(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists, coercing it if
+     * necessary.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     * @throws JSONException if no such value exists.
+     */
+    public String getString(int index) throws JSONException {
+        Object object = get(index);
+        String result = JSON.toString(object);
+        if (result == null) {
+            throw JSON.typeMismatch(index, object, "String");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists, coercing it if
+     * necessary. Returns the empty string if no such value exists.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     */
+    public String optString(int index) {
+        return optString(index, "");
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists, coercing it if
+     * necessary. Returns {@code fallback} if no such value exists.
+     *
+     * @param index    Which value to get.
+     * @param fallback The fallback value to use if no value is at the specified location.
+     * @return the value at the specified location or the fallback value.
+     */
+    public String optString(int index, String fallback) {
+        Object object = opt(index);
+        String result = JSON.toString(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a {@code
+     * JSONArray}.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     * @throws JSONException if the value doesn't exist or is not a {@code
+     *                       JSONArray}.
+     */
+    public JSONArray getJSONArray(int index) throws JSONException {
+        Object object = get(index);
+        if (object instanceof JSONArray) {
+            return (JSONArray) object;
+        } else {
+            throw JSON.typeMismatch(index, object, "JSONArray");
+        }
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a {@code
+     * JSONArray}. Returns null otherwise.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     */
+    public JSONArray optJSONArray(int index) {
+        Object object = opt(index);
+        return object instanceof JSONArray ? (JSONArray) object : null;
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a {@code
+     * JSONObject}.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     * @throws JSONException if the value doesn't exist or is not a {@code
+     *                       JSONObject}.
+     */
+    public JSONObject getJSONObject(int index) throws JSONException {
+        Object object = get(index);
+        if (object instanceof JSONObject) {
+            return (JSONObject) object;
+        } else {
+            throw JSON.typeMismatch(index, object, "JSONObject");
+        }
+    }
+
+    /**
+     * Returns the value at {@code index} if it exists and is a {@code
+     * JSONObject}. Returns null otherwise.
+     *
+     * @param index Which value to get.
+     * @return the value at the specified location.
+     */
+    public JSONObject optJSONObject(int index) {
+        Object object = opt(index);
+        return object instanceof JSONObject ? (JSONObject) object : null;
+    }
+
+    /**
+     * Returns a new object whose values are the values in this array, and whose
+     * names are the values in {@code names}. Names and values are paired up by
+     * index from 0 through to the shorter array's length. Names that are not
+     * strings will be coerced to strings. This method returns null if either
+     * array is empty.
+     *
+     * @param names The names to apply to the returned values.
+     * @return the newly constructed object.
+     * @throws JSONException Should not be possible.
+     */
+    public JSONObject toJSONObject(JSONArray names) throws JSONException {
+        JSONObject result = new JSONObject();
+        int length = Math.min(names.length(), values.size());
+        if (length == 0) {
+            return null;
+        }
+        for (int i = 0; i < length; i++) {
+            String name = JSON.toString(names.opt(i));
+            result.put(name, opt(i));
+        }
+        return result;
+    }
+
+    /**
+     * Returns a new string by alternating this array's values with {@code
+     * separator}. This array's string values are quoted and have their special
+     * characters escaped. For example, the array containing the strings '12"
+     * pizza', 'taco' and 'soda' joined on '+' returns this:
+     * <pre>"12\" pizza"+"taco"+"soda"</pre>
+     *
+     * @param separator The string used to separate the returned values.
+     * @return the conjoined values.
+     * @throws JSONException Only if there is a coding error.
+     */
+    public String join(String separator) throws JSONException {
+        JSONStringer stringer = new JSONStringer();
+        stringer.open(JSONStringer.Scope.NULL, "");
+        for (int i = 0, size = values.size(); i < size; i++) {
+            if (i > 0) {
+                stringer.out.append(separator);
+            }
+            stringer.value(values.get(i));
+        }
+        stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, "");
+        return stringer.out.toString();
+    }
+
+    /**
+     * Encodes this array as a compact JSON string, such as:
+     * <pre>[94043,90210]</pre>
+     *
+     * @return The string form of this array.
+     */
+    @Override
+    public String toString() {
+        try {
+            JSONStringer stringer = new JSONStringer();
+            writeTo(stringer);
+            return stringer.toString();
+        } catch (JSONException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Encodes this array as a human readable JSON string for debugging, such
+     * as:
+     * <pre>
+     * [
+     *     94043,
+     *     90210
+     * ]</pre>
+     *
+     * @param indentSpaces the number of spaces to indent for each level of
+     *                     nesting.
+     * @return The string form of this array.
+     * @throws JSONException Only if there is a coding error.
+     */
+    public String toString(int indentSpaces) throws JSONException {
+        JSONStringer stringer = new JSONStringer(indentSpaces);
+        writeTo(stringer);
+        return stringer.toString();
+    }
+
+    void writeTo(JSONStringer stringer) throws JSONException {
+        stringer.array();
+        for (Object value : values) {
+            stringer.value(value);
+        }
+        stringer.endArray();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        return o instanceof JSONArray && ((JSONArray) o).values.equals(values);
+    }
+
+    @Override
+    public int hashCode() {
+        // diverge from the original, which doesn't implement hashCode
+        return values.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/main/java/org/json/JSONException.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONException.java b/geode-json/src/main/java/org/json/JSONException.java
new file mode 100755
index 0000000..1292e86
--- /dev/null
+++ b/geode-json/src/main/java/org/json/JSONException.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+// Note: this class was written without inspecting the non-free org.json sourcecode.
+
+/**
+ * Thrown to indicate a problem with the JSON API. Such problems include:
+ * <ul>
+ *   <li>Attempts to parse or construct malformed documents
+ *   <li>Use of null as a name
+ *   <li>Use of numeric types not available to JSON, such as {@link
+ *       Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}.
+ *   <li>Lookups using an out of range index or nonexistent name
+ *   <li>Type mismatches on lookups
+ * </ul>
+ *
+ * <p>Although this is a checked exception, it is rarely recoverable. Most
+ * callers should simply wrap this exception in an unchecked exception and
+ * rethrow:
+ * <pre>  public JSONArray toJSONObject() {
+ *     try {
+ *         JSONObject result = new JSONObject();
+ *         ...
+ *     } catch (JSONException e) {
+ *         throw new RuntimeException(e);
+ *     }
+ * }</pre>
+ */
+public class JSONException extends RuntimeException {
+
+    public JSONException(String s) {
+        super(s);
+    }
+
+    public JSONException(Throwable cause) {
+        super(cause);
+    }
+
+    public JSONException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/main/java/org/json/JSONObject.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONObject.java b/geode-json/src/main/java/org/json/JSONObject.java
new file mode 100755
index 0000000..d2bc126
--- /dev/null
+++ b/geode-json/src/main/java/org/json/JSONObject.java
@@ -0,0 +1,993 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed 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 org.json;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+// Note: this class was written without inspecting the non-free org.json sourcecode.
+
+/**
+ * A modifiable set of name/value mappings. Names are unique, non-null strings.
+ * Values may be any mix of {@link JSONObject JSONObjects}, {@link JSONArray
+ * JSONArrays}, Strings, Booleans, Integers, Longs, Doubles or {@link #NULL}.
+ * Values may not be {@code null}, {@link Double#isNaN() NaNs}, {@link
+ * Double#isInfinite() infinities}, or of any type not listed here.
+ *
+ * <p>This class can coerce values to another type when requested.
+ * <ul>
+ * <li>When the requested type is a boolean, strings will be coerced using a
+ * case-insensitive comparison to "true" and "false".
+ * <li>When the requested type is a double, other {@link Number} types will
+ * be coerced using {@link Number#doubleValue() doubleValue}. Strings
+ * that can be coerced using {@link Double#valueOf(String)} will be.
+ * <li>When the requested type is an int, other {@link Number} types will
+ * be coerced using {@link Number#intValue() intValue}. Strings
+ * that can be coerced using {@link Double#valueOf(String)} will be,
+ * and then cast to int.
+ * <li><a name="lossy">When the requested type is a long, other {@link Number} types will
+ * be coerced using {@link Number#longValue() longValue}. Strings
+ * that can be coerced using {@link Double#valueOf(String)} will be,
+ * and then cast to long. This two-step conversion is lossy for very
+ * large values. For example, the string "9223372036854775806" yields the
+ * long 9223372036854775807.</a>
+ * <li>When the requested type is a String, other non-null values will be
+ * coerced using {@link String#valueOf(Object)}. Although null cannot be
+ * coerced, the sentinel value {@link JSONObject#NULL} is coerced to the
+ * string "null".
+ * </ul>
+ *
+ * <p>This class can look up both mandatory and optional values:
+ * <ul>
+ * <li>Use <code>get<i>Type</i>()</code> to retrieve a mandatory value. This
+ * fails with a {@code JSONException} if the requested name has no value
+ * or if the value cannot be coerced to the requested type.
+ * <li>Use <code>opt<i>Type</i>()</code> to retrieve an optional value. This
+ * returns a system- or user-supplied default if the requested name has no
+ * value or if the value cannot be coerced to the requested type.
+ * </ul>
+ *
+ * <p><strong>Warning:</strong> this class represents null in two incompatible
+ * ways: the standard Java {@code null} reference, and the sentinel value {@link
+ * JSONObject#NULL}. In particular, calling {@code put(name, null)} removes the
+ * named entry from the object but {@code put(name, JSONObject.NULL)} stores an
+ * entry whose value is {@code JSONObject.NULL}.
+ *
+ * <p>Instances of this class are not thread safe. Although this class is
+ * nonfinal, it was not designed for inheritance and should not be subclassed.
+ * In particular, self-use by overrideable methods is not specified. See
+ * <i>Effective Java</i> Item 17, "Design and Document or inheritance or else
+ * prohibit it" for further information.
+ */
+public class JSONObject {
+
+    private static final Double NEGATIVE_ZERO = -0d;
+
+    /**
+     * A sentinel value used to explicitly define a name with no value. Unlike
+     * {@code null}, names with this value:
+     * <ul>
+     * <li>show up in the {@link #names} array
+     * <li>show up in the {@link #keys} iterator
+     * <li>return {@code true} for {@link #has(String)}
+     * <li>do not throw on {@link #get(String)}
+     * <li>are included in the encoded JSON string.
+     * </ul>
+     *
+     * <p>This value violates the general contract of {@link Object#equals} by
+     * returning true when compared to {@code null}. Its {@link #toString}
+     * method returns "null".
+     */
+    public static final Object NULL = new Object() {
+        @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
+        @Override
+        public boolean equals(Object o) {
+            return o == this || o == null; // API specifies this broken equals implementation
+        }
+
+        // at least make the broken equals(null) consistent with Objects.hashCode(null).
+        @Override
+        public int hashCode() {
+            return 0;
+        }
+
+        @Override
+        public String toString() {
+            return "null";
+        }
+    };
+
+    private final LinkedHashMap<String, Object> nameValuePairs;
+
+    /**
+     * Creates a {@code JSONObject} with no name/value mappings.
+     */
+    public JSONObject() {
+        nameValuePairs = new LinkedHashMap<String, Object>();
+    }
+
+    /**
+     * Creates a new {@code JSONObject} by copying all name/value mappings from
+     * the given map.
+     *
+     * @param copyFrom a map whose keys are of type {@link String} and whose
+     *                 values are of supported types.
+     * @throws NullPointerException if any of the map's keys are null.
+     */
+    /* (accept a raw type for API compatibility) */
+    public JSONObject(Map copyFrom) {
+        this();
+        Map<?, ?> contentsTyped = (Map<?, ?>) copyFrom;
+        for (Map.Entry<?, ?> entry : contentsTyped.entrySet()) {
+            /*
+             * Deviate from the original by checking that keys are non-null and
+             * of the proper type. (We still defer validating the values).
+             */
+            String key = (String) entry.getKey();
+            if (key == null) {
+                throw new NullPointerException("key == null");
+            }
+            nameValuePairs.put(key, wrap(entry.getValue()));
+        }
+    }
+
+    /**
+     * Creates a new {@code JSONObject} with name/value mappings from the next
+     * object in the tokener.
+     *
+     * @param readFrom a tokener whose nextValue() method will yield a
+     *                 {@code JSONObject}.
+     * @throws JSONException if the parse fails or doesn't yield a
+     *                       {@code JSONObject}.
+     */
+    public JSONObject(JSONTokener readFrom) throws JSONException {
+        /*
+         * Getting the parser to populate this could get tricky. Instead, just
+         * parse to temporary JSONObject and then steal the data from that.
+         */
+        Object object = readFrom.nextValue();
+        if (object instanceof JSONObject) {
+            this.nameValuePairs = ((JSONObject) object).nameValuePairs;
+        } else {
+            throw JSON.typeMismatch(object, "JSONObject");
+        }
+    }
+
+    /**
+     * Creates a new {@code JSONObject} with name/value mappings from the JSON
+     * string.
+     *
+     * @param json a JSON-encoded string containing an object.
+     * @throws JSONException if the parse fails or doesn't yield a {@code
+     *                       JSONObject}.
+     */
+    public JSONObject(String json) throws JSONException {
+        this(new JSONTokener(json));
+    }
+
+    /**
+     * Creates a new {@code JSONObject} by copying mappings for the listed names
+     * from the given object. Names that aren't present in {@code copyFrom} will
+     * be skipped.
+     *
+     * @param copyFrom The source object.
+     * @param names    The names of the fields to copy.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONObject(JSONObject copyFrom, String[] names) throws JSONException {
+        this();
+        for (String name : names) {
+            Object value = copyFrom.opt(name);
+            if (value != null) {
+                nameValuePairs.put(name, value);
+            }
+        }
+    }
+
+    /**
+     * Creates a json object from a bean
+     * @param bean the bean to create the json object from
+     * @throws JSONException If there is an exception while reading the bean
+     */
+    public JSONObject(Object bean) throws JSONException {
+        this(propertiesAsMap(bean));
+    }
+
+    private static Map<String, Object> propertiesAsMap(Object bean) throws JSONException {
+        Map<String, Object> props = new TreeMap<String, Object>();
+        try {
+            PropertyDescriptor[] properties = Introspector.getBeanInfo(bean.getClass(), Object.class)
+                    .getPropertyDescriptors();
+            for (PropertyDescriptor prop : properties) {
+                Object v = prop.getReadMethod().invoke(bean);
+                props.put(prop.getDisplayName(), wrap(v));
+            }
+        } catch (IllegalAccessException e) {
+            throw new JSONException(e);
+        } catch (IntrospectionException e) {
+            throw new JSONException(e);
+        } catch (InvocationTargetException e) {
+            throw new JSONException(e);
+        }
+        return props;
+    }
+
+    public static String[] getNames(JSONObject x) {
+        Set<String> names = x.keySet();
+        String[] r = new String[names.size()];
+        int i = 0;
+        for (String name : names) {
+            r[i++] = name;
+        }
+        return r;
+    }
+
+    /**
+     * Returns the number of name/value mappings in this object.
+     *
+     * @return the length of this.
+     */
+    public int length() {
+        return nameValuePairs.size();
+    }
+
+    /**
+     * Maps {@code name} to {@code value}, clobbering any existing name/value
+     * mapping with the same name.
+     *
+     * @param name  The name of the value to insert.
+     * @param value The value to insert.
+     * @return this object.
+     * @throws JSONException Should not be possible.
+     */
+    public JSONObject put(String name, boolean value) throws JSONException {
+        nameValuePairs.put(checkName(name), value);
+        return this;
+    }
+
+    /**
+     * Maps {@code name} to {@code value}, clobbering any existing name/value
+     * mapping with the same name.
+     *
+     * @param name  The name for the new value.
+     * @param value a finite value. May not be {@link Double#isNaN() NaNs} or
+     *              {@link Double#isInfinite() infinities}.
+     * @return this object.
+     * @throws JSONException if value is NaN or infinite.
+     */
+    public JSONObject put(String name, double value) throws JSONException {
+        nameValuePairs.put(checkName(name), JSON.checkDouble(value));
+        return this;
+    }
+
+    /**
+     * Maps {@code name} to {@code value}, clobbering any existing name/value
+     * mapping with the same name.
+     *
+     * @param name  The name for the new value.
+     * @param value The new value.
+     * @return this object.
+     * @throws JSONException Should not be possible.
+     */
+    public JSONObject put(String name, int value) throws JSONException {
+        nameValuePairs.put(checkName(name), value);
+        return this;
+    }
+
+    /**
+     * Maps {@code name} to {@code value}, clobbering any existing name/value
+     * mapping with the same name.
+     *
+     * @param name  The name of the new value.
+     * @param value The new value to insert.
+     * @return this object.
+     * @throws JSONException Should not be possible.
+     */
+    public JSONObject put(String name, long value) throws JSONException {
+        nameValuePairs.put(checkName(name), value);
+        return this;
+    }
+
+    /**
+     * Maps {@code name} to {@code value}, clobbering any existing name/value
+     * mapping with the same name. If the value is {@code null}, any existing
+     * mapping for {@code name} is removed.
+     *
+     * @param name  The name of the new value.
+     * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
+     *              Integer, Long, Double, {@link #NULL}, or {@code null}. May not be
+     *              {@link Double#isNaN() NaNs} or {@link Double#isInfinite()
+     *              infinities}.
+     * @return this object.
+     * @throws JSONException if the value is an invalid double (infinite or NaN).
+     */
+    public JSONObject put(String name, Object value) throws JSONException {
+        if (value == null) {
+            nameValuePairs.remove(name);
+            return this;
+        }
+        if (value instanceof Number) {
+            // deviate from the original by checking all Numbers, not just floats & doubles
+            JSON.checkDouble(((Number) value).doubleValue());
+        }
+        nameValuePairs.put(checkName(name), value);
+        return this;
+    }
+
+    /**
+     * Equivalent to {@code put(name, value)} when both parameters are non-null;
+     * does nothing otherwise.
+     *
+     * @param name  The name of the value to insert.
+     * @param value The value to insert.
+     * @return this object.
+     * @throws JSONException if the value is an invalid double (infinite or NaN).
+     */
+    public JSONObject putOpt(String name, Object value) throws JSONException {
+        if (name == null || value == null) {
+            return this;
+        }
+        return put(name, value);
+    }
+
+    /**
+     * Appends {@code value} to the array already mapped to {@code name}. If
+     * this object has no mapping for {@code name}, this inserts a new mapping.
+     * If the mapping exists but its value is not an array, the existing
+     * and new values are inserted in order into a new array which is itself
+     * mapped to {@code name}. In aggregate, this allows values to be added to a
+     * mapping one at a time.
+     *
+     * Note that {@code append(String, Object)} provides better semantics.
+     * In particular, the mapping for {@code name} will <b>always</b> be a
+     * {@link JSONArray}. Using {@code accumulate} will result in either a
+     * {@link JSONArray} or a mapping whose type is the type of {@code value}
+     * depending on the number of calls to it.
+     *
+     * @param name  The name of the field to change.
+     * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean,
+     *              Integer, Long, Double, {@link #NULL} or null. May not be {@link
+     *              Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}.
+     * @return this object after mutation.
+     * @throws JSONException If the object being added is an invalid number.
+     */
+    // TODO: Change {@code append) to {@link #append} when append is
+    // unhidden.
+    public JSONObject accumulate(String name, Object value) throws JSONException {
+        Object current = nameValuePairs.get(checkName(name));
+        if (current == null) {
+            return put(name, value);
+        }
+
+        if (current instanceof JSONArray) {
+            JSONArray array = (JSONArray) current;
+            array.checkedPut(value);
+        } else {
+            JSONArray array = new JSONArray();
+            array.checkedPut(current);
+            array.checkedPut(value);
+            nameValuePairs.put(name, array);
+        }
+        return this;
+    }
+
+    /**
+     * Appends values to the array mapped to {@code name}. A new {@link JSONArray}
+     * mapping for {@code name} will be inserted if no mapping exists. If the existing
+     * mapping for {@code name} is not a {@link JSONArray}, a {@link JSONException}
+     * will be thrown.
+     *
+     * @param name  The name of the array to which the value should be appended.
+     * @param value The value to append.
+     * @return this object.
+     * @throws JSONException if {@code name} is {@code null} or if the mapping for
+     *                       {@code name} is non-null and is not a {@link JSONArray}.
+     */
+    public JSONObject append(String name, Object value) throws JSONException {
+        Object current = nameValuePairs.get(checkName(name));
+
+        final JSONArray array;
+        if (current instanceof JSONArray) {
+            array = (JSONArray) current;
+        } else if (current == null) {
+            JSONArray newArray = new JSONArray();
+            nameValuePairs.put(name, newArray);
+            array = newArray;
+        } else {
+            throw new JSONException("Key " + name + " is not a JSONArray");
+        }
+
+        array.checkedPut(value);
+
+        return this;
+    }
+
+    String checkName(String name) throws JSONException {
+        if (name == null) {
+            throw new JSONException("Names must be non-null");
+        }
+        return name;
+    }
+
+    /**
+     * Removes the named mapping if it exists; does nothing otherwise.
+     *
+     * @param name The name of the mapping to remove.
+     * @return the value previously mapped by {@code name}, or null if there was
+     * no such mapping.
+     */
+    public Object remove(String name) {
+        return nameValuePairs.remove(name);
+    }
+
+    /**
+     * Returns true if this object has no mapping for {@code name} or if it has
+     * a mapping whose value is {@link #NULL}.
+     *
+     * @param name The name of the value to check on.
+     * @return true if the field doesn't exist or is null.
+     */
+    public boolean isNull(String name) {
+        Object value = nameValuePairs.get(name);
+        return value == null || value == NULL;
+    }
+
+    /**
+     * Returns true if this object has a mapping for {@code name}. The mapping
+     * may be {@link #NULL}.
+     *
+     * @param name The name of the value to check on.
+     * @return true if this object has a field named {@code name}
+     */
+    public boolean has(String name) {
+        return nameValuePairs.containsKey(name);
+    }
+
+    /**
+     * Returns the value mapped by {@code name}, or throws if no such mapping exists.
+     *
+     * @param name The name of the value to get.
+     * @return The value.
+     * @throws JSONException if no such mapping exists.
+     */
+    public Object get(String name) throws JSONException {
+        Object result = nameValuePairs.get(name);
+        if (result == null) {
+            throw new JSONException("No value for " + name);
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value mapped by {@code name}, or null if no such mapping
+     * exists.
+     *
+     * @param name The name of the value to get.
+     * @return The value.
+     */
+    public Object opt(String name) {
+        return nameValuePairs.get(name);
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a boolean or
+     * can be coerced to a boolean, or throws otherwise.
+     *
+     * @param name The name of the field we want.
+     * @return The selected value if it exists.
+     * @throws JSONException if the mapping doesn't exist or cannot be coerced
+     *                       to a boolean.
+     */
+    public boolean getBoolean(String name) throws JSONException {
+        Object object = get(name);
+        Boolean result = JSON.toBoolean(object);
+        if (result == null) {
+            throw JSON.typeMismatch(name, object, "boolean");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a boolean or
+     * can be coerced to a boolean, or false otherwise.
+     *
+     * @param name The name of the field we want.
+     * @return The selected value if it exists.
+     */
+    public boolean optBoolean(String name) {
+        return optBoolean(name, false);
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a boolean or
+     * can be coerced to a boolean, or {@code fallback} otherwise.
+     *
+     * @param name     The name of the field we want.
+     * @param fallback The value to return if the field isn't there.
+     * @return The selected value or the fallback.
+     */
+    public boolean optBoolean(String name, boolean fallback) {
+        Object object = opt(name);
+        Boolean result = JSON.toBoolean(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a double or
+     * can be coerced to a double, or throws otherwise.
+     *
+     * @param name The name of the field we want.
+     * @return The selected value if it exists.
+     * @throws JSONException if the mapping doesn't exist or cannot be coerced
+     *                       to a double.
+     */
+    public double getDouble(String name) throws JSONException {
+        Object object = get(name);
+        Double result = JSON.toDouble(object);
+        if (result == null) {
+            throw JSON.typeMismatch(name, object, "double");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a double or
+     * can be coerced to a double, or {@code NaN} otherwise.
+     *
+     * @param name The name of the field we want.
+     * @return The selected value if it exists.
+     */
+    public double optDouble(String name) {
+        return optDouble(name, Double.NaN);
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a double or
+     * can be coerced to a double, or {@code fallback} otherwise.
+     *
+     * @param name     The name of the field we want.
+     * @param fallback The value to return if the field isn't there.
+     * @return The selected value or the fallback.
+     */
+    public double optDouble(String name, double fallback) {
+        Object object = opt(name);
+        Double result = JSON.toDouble(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is an int or
+     * can be coerced to an int, or throws otherwise.
+     *
+     * @param name The name of the field we want.
+     * @return The selected value if it exists.
+     * @throws JSONException if the mapping doesn't exist or cannot be coerced
+     *                       to an int.
+     */
+    public int getInt(String name) throws JSONException {
+        Object object = get(name);
+        Integer result = JSON.toInteger(object);
+        if (result == null) {
+            throw JSON.typeMismatch(name, object, "int");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is an int or
+     * can be coerced to an int, or 0 otherwise.
+     *
+     * @param name The name of the field we want.
+     * @return The selected value if it exists.
+     */
+    public int optInt(String name) {
+        return optInt(name, 0);
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is an int or
+     * can be coerced to an int, or {@code fallback} otherwise.
+     *
+     * @param name     The name of the field we want.
+     * @param fallback The value to return if the field isn't there.
+     * @return The selected value or the fallback.
+     */
+    public int optInt(String name, int fallback) {
+        Object object = opt(name);
+        Integer result = JSON.toInteger(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a long or
+     * can be coerced to a long, or throws otherwise.
+     * Note that JSON represents numbers as doubles,
+     *
+     * so this is <a href="#lossy">lossy</a>; use strings to transfer numbers
+     * via JSON without loss.
+     *
+     * @param name The name of the field that we want.
+     * @return The value of the field.
+     * @throws JSONException if the mapping doesn't exist or cannot be coerced
+     *                       to a long.
+     */
+    public long getLong(String name) throws JSONException {
+        Object object = get(name);
+        Long result = JSON.toLong(object);
+        if (result == null) {
+            throw JSON.typeMismatch(name, object, "long");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a long or
+     * can be coerced to a long, or 0 otherwise. Note that JSON represents numbers as doubles,
+     * so this is <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON.
+     *
+     * @param name The name of the field we want.
+     * @return The selected value.
+     */
+    public long optLong(String name) {
+        return optLong(name, 0L);
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a long or
+     * can be coerced to a long, or {@code fallback} otherwise. Note that JSON represents
+     * numbers as doubles, so this is <a href="#lossy">lossy</a>; use strings to transfer
+     * numbers via JSON.
+     *
+     * @param name     The name of the field we want.
+     * @param fallback The value to return if the field isn't there.
+     * @return The selected value or the fallback.
+     */
+    public long optLong(String name, long fallback) {
+        Object object = opt(name);
+        Long result = JSON.toLong(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists, coercing it if
+     * necessary, or throws if no such mapping exists.
+     *
+     * @param name The name of the field we want.
+     * @return The value of the field.
+     * @throws JSONException if no such mapping exists.
+     */
+    public String getString(String name) throws JSONException {
+        Object object = get(name);
+        String result = JSON.toString(object);
+        if (result == null) {
+            throw JSON.typeMismatch(name, object, "String");
+        }
+        return result;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists, coercing it if
+     * necessary, or the empty string if no such mapping exists.
+     *
+     * @param name The name of the field we want.
+     * @return The value of the field.
+     */
+    public String optString(String name) {
+        return optString(name, "");
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists, coercing it if
+     * necessary, or {@code fallback} if no such mapping exists.
+     *
+     * @param name     The name of the field that we want.
+     * @param fallback The value to return if the field doesn't exist.
+     * @return The value of the field or fallback.
+     */
+    public String optString(String name, String fallback) {
+        Object object = opt(name);
+        String result = JSON.toString(object);
+        return result != null ? result : fallback;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a {@code
+     * JSONArray}, or throws otherwise.
+     *
+     * @param name The field we want to get.
+     * @return The value of the field (if it is a JSONArray.
+     * @throws JSONException if the mapping doesn't exist or is not a {@code
+     *                       JSONArray}.
+     */
+    public JSONArray getJSONArray(String name) throws JSONException {
+        Object object = get(name);
+        if (object instanceof JSONArray) {
+            return (JSONArray) object;
+        } else {
+            throw JSON.typeMismatch(name, object, "JSONArray");
+        }
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a {@code
+     * JSONArray}, or null otherwise.
+     *
+     * @param name The name of the field we want.
+     * @return The value of the specified field (assuming it is a JSNOArray
+     */
+    public JSONArray optJSONArray(String name) {
+        Object object = opt(name);
+        return object instanceof JSONArray ? (JSONArray) object : null;
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a {@code
+     * JSONObject}, or throws otherwise.
+     *
+     * @param name The name of the field that we want.
+     * @return a specified field value (if it is a JSONObject)
+     * @throws JSONException if the mapping doesn't exist or is not a {@code
+     *                       JSONObject}.
+     */
+    public JSONObject getJSONObject(String name) throws JSONException {
+        Object object = get(name);
+        if (object instanceof JSONObject) {
+            return (JSONObject) object;
+        } else {
+            throw JSON.typeMismatch(name, object, "JSONObject");
+        }
+    }
+
+    /**
+     * Returns the value mapped by {@code name} if it exists and is a {@code
+     * JSONObject}, or null otherwise.
+     *
+     * @param name The name of the value we want.
+     * @return The specified value.
+     */
+    public JSONObject optJSONObject(String name) {
+        Object object = opt(name);
+        return object instanceof JSONObject ? (JSONObject) object : null;
+    }
+
+    /**
+     * Returns an array with the values corresponding to {@code names}. The
+     * array contains null for names that aren't mapped. This method returns
+     * null if {@code names} is either null or empty.
+     *
+     * @param names The names of the fields that we want the values for.
+     * @return The selected values.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public JSONArray toJSONArray(JSONArray names) throws JSONException {
+        JSONArray result = new JSONArray();
+        if (names == null) {
+            return null;
+        }
+        int length = names.length();
+        if (length == 0) {
+            return null;
+        }
+        for (int i = 0; i < length; i++) {
+            String name = JSON.toString(names.opt(i));
+            result.put(opt(name));
+        }
+        return result;
+    }
+
+    /**
+     * Returns an iterator of the {@code String} names in this object. The
+     * returned iterator supports {@link Iterator#remove() remove}, which will
+     * remove the corresponding mapping from this object. If this object is
+     * modified after the iterator is returned, the iterator's behavior is
+     * undefined. The order of the keys is undefined.
+     *
+     * @return an iterator over the keys.
+     */
+    public Iterator<String> keys() {
+        return nameValuePairs.keySet().iterator();
+    }
+
+    /**
+     * Returns the set of {@code String} names in this object. The returned set
+     * is a view of the keys in this object. {@link Set#remove(Object)} will remove
+     * the corresponding mapping from this object and set iterator behaviour
+     * is undefined if this object is modified after it is returned.
+     *
+     * See {@link #keys()}.
+     *
+     * @return The names in this object.
+     */
+    public Set<String> keySet() {
+        return nameValuePairs.keySet();
+    }
+
+    /**
+     * Returns an array containing the string names in this object. This method
+     * returns null if this object contains no mappings.
+     *
+     * @return the names.
+     */
+    public JSONArray names() {
+        return nameValuePairs.isEmpty()
+                ? null
+                : new JSONArray(new ArrayList<String>(nameValuePairs.keySet()));
+    }
+
+    /**
+     * Encodes this object as a compact JSON string, such as:
+     * <pre>{"query":"Pizza","locations":[94043,90210]}</pre>
+     */
+    @Override
+    public String toString() {
+        try {
+            JSONStringer stringer = new JSONStringer();
+            writeTo(stringer);
+            return stringer.toString();
+        } catch (JSONException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Encodes this object as a human readable JSON string for debugging, such
+     * as:
+     * <pre>
+     * {
+     *     "query": "Pizza",
+     *     "locations": [
+     *         94043,
+     *         90210
+     *     ]
+     * }</pre>
+     *
+     * @param indentSpaces the number of spaces to indent for each level of
+     *                     nesting.
+     * @return The string containing the pretty form of this.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public String toString(int indentSpaces) throws JSONException {
+        JSONStringer stringer = new JSONStringer(indentSpaces);
+        writeTo(stringer);
+        return stringer.toString();
+    }
+
+    void writeTo(JSONStringer stringer) throws JSONException {
+        stringer.object();
+        for (Map.Entry<String, Object> entry : nameValuePairs.entrySet()) {
+            stringer.key(entry.getKey()).value(entry.getValue());
+        }
+        stringer.endObject();
+    }
+
+    /**
+     * Encodes the number as a JSON string.
+     *
+     * @param number a finite value. May not be {@link Double#isNaN() NaNs} or
+     *               {@link Double#isInfinite() infinities}.
+     * @return The encoded number in string form.
+     * @throws JSONException On internal errors. Shouldn't happen.
+     */
+    public static String numberToString(Number number) throws JSONException {
+        if (number == null) {
+            throw new JSONException("Number must be non-null");
+        }
+
+        double doubleValue = number.doubleValue();
+        JSON.checkDouble(doubleValue);
+
+        // the original returns "-0" instead of "-0.0" for negative zero
+        if (number.equals(NEGATIVE_ZERO)) {
+            return "-0";
+        }
+
+        long longValue = number.longValue();
+        if (doubleValue == (double) longValue) {
+            return Long.toString(longValue);
+        }
+
+        return number.toString();
+    }
+
+    /**
+     * Encodes {@code data} as a JSON string. This applies quotes and any
+     * necessary character escaping.
+     *
+     * @param data the string to encode. Null will be interpreted as an empty
+     *             string.
+     * @return the quoted string.
+     */
+    public static String quote(String data) {
+        if (data == null) {
+            return "\"\"";
+        }
+        try {
+            JSONStringer stringer = new JSONStringer();
+            stringer.open(JSONStringer.Scope.NULL, "");
+            stringer.value(data);
+            stringer.close(JSONStringer.Scope.NULL, JSONStringer.Scope.NULL, "");
+            return stringer.toString();
+        } catch (JSONException e) {
+            throw new AssertionError();
+        }
+    }
+
+    /**
+     * Wraps the given object if necessary.
+     *
+     * <p>If the object is null or , returns {@link #NULL}.
+     * If the object is a {@code JSONArray} or {@code JSONObject}, no wrapping is necessary.
+     * If the object is {@code NULL}, no wrapping is necessary.
+     * If the object is an array or {@code Collection}, returns an equivalent {@code JSONArray}.
+     * If the object is a {@code Map}, returns an equivalent {@code JSONObject}.
+     * If the object is a primitive wrapper type or {@code String}, returns the object.
+     * If the object is from a {@code java} package, returns the result of {@code toString}.
+     * If the object is some other kind of object then it is assumed to be a bean and is converted to a JSONObject.
+     * If wrapping fails, returns null.
+     *
+     * @param o The object to wrap.
+     * @return The wrapped (if necessary) form of the object {$code o}
+     */
+    public static Object wrap(Object o) {
+        if (o == null) {
+            return NULL;
+        }
+        if (o instanceof JSONArray || o instanceof JSONObject) {
+            return o;
+        }
+        if (o.equals(NULL)) {
+            return o;
+        }
+        try {
+            if (o instanceof Collection) {
+                return new JSONArray((Collection) o);
+            } else if (o.getClass().isArray()) {
+                return new JSONArray(o);
+            }
+            if (o instanceof Map) {
+                return new JSONObject((Map) o);
+            }
+            if (o instanceof Boolean ||
+                    o instanceof Byte ||
+                    o instanceof Character ||
+                    o instanceof Double ||
+                    o instanceof Float ||
+                    o instanceof Integer ||
+                    o instanceof Long ||
+                    o instanceof Short ||
+                    o instanceof String) {
+                return o;
+            }
+            if (o.getClass().getPackage().getName().startsWith("java.") || o instanceof Enum<?>) {
+                return o.toString();
+            } else {
+                return new JSONObject(o);
+            }
+        } catch (Exception ignored) {
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b34e47ff/geode-json/src/main/java/org/json/JSONString.java
----------------------------------------------------------------------
diff --git a/geode-json/src/main/java/org/json/JSONString.java b/geode-json/src/main/java/org/json/JSONString.java
new file mode 100755
index 0000000..34815a8
--- /dev/null
+++ b/geode-json/src/main/java/org/json/JSONString.java
@@ -0,0 +1,18 @@
+package org.json;
+/**
+ * The <code>JSONString</code> interface allows a <code>toJSONString()</code> 
+ * method so that a class can change the behavior of 
+ * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
+ * and <code>JSONWriter.value(</code>Object<code>)</code>. The 
+ * <code>toJSONString</code> method will be used instead of the default behavior 
+ * of using the Object's <code>toString()</code> method and quoting the result.
+ */
+public interface JSONString {
+  /**
+   * The <code>toJSONString</code> method allows a class to produce its own JSON 
+   * serialization. 
+   * 
+   * @return A strictly syntactically correct JSON text.
+   */
+  public String toJSONString();
+}
\ No newline at end of file