From c64d9851cabdf3096f4f65e69b46cbe4e64e8744 Mon Sep 17 00:00:00 2001 From: Michael Gibney Date: Thu, 7 Sep 2023 08:59:22 -0400 Subject: [PATCH] Revert "Re-adding 0 indentation of doc colleciton JSON and fixing test (#131)" This reverts commit 3f81865c62f54b1d97c2808b6c0e770ac0981e8a. Fix was not applicable to branch_9_2 --- .../src/java/org/apache/solr/common/util/Utils.java | 9 ++++++++- .../org/apache/solr/common/cloud/DocCollectionTest.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java index 61c9723bb72..8538d0ac5b4 100644 --- a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java +++ b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java @@ -288,7 +288,14 @@ public IteratorWriter.ItemWriter add(Object o) throws IOException { public static byte[] toJSON(Object o) { if (o == null) return new byte[0]; CharArr out = new CharArr(); - new JSONWriter(out, 0).write(o); // indentation by default + // if (!(o instanceof List) && !(o instanceof Map)) { + // if (o instanceof MapWriter) { + // o = ((MapWriter) o).toMap(new LinkedHashMap<>()); + // } else if (o instanceof IteratorWriter) { + // o = ((IteratorWriter) o).toList(new ArrayList<>()); + // } + // } + new MapWriterJSONWriter(out, 0).write(o); // indentation by default return toUTF8(out); } diff --git a/solr/solrj/src/test/org/apache/solr/common/cloud/DocCollectionTest.java b/solr/solrj/src/test/org/apache/solr/common/cloud/DocCollectionTest.java index 7857dbc9bce..8ea519f88f7 100644 --- a/solr/solrj/src/test/org/apache/solr/common/cloud/DocCollectionTest.java +++ b/solr/solrj/src/test/org/apache/solr/common/cloud/DocCollectionTest.java @@ -111,6 +111,6 @@ public void testDocCollectionSeriallizationNoIndent() throws Exception { // sometime it takes url schems http or https - test setup issue assertTrue( - "byte size is wrong at " + ser.length, 540513 == ser.length || 540513 + 2048 == ser.length); + "byte size is wrong at " + ser.length, 540512 == ser.length || 540512 + 2048 == ser.length); } }