mirror of https://github.com/apache/lucene.git
SOLR-898: Fix null pointer exception for the JSON response writer based formats when nl.json=arrarr with null keys.
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@723804 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5db15f719a
commit
78bc41b54e
|
@ -149,6 +149,9 @@ Bug Fixes
|
|||
14. SOLR-892: Fix serialization of booleans for PHPSerializedResponseWriter
|
||||
(yonik)
|
||||
|
||||
15. SOLR-898: Fix null pointer exception for the JSON response writer
|
||||
based formats when nl.json=arrarr with null keys. (yonik)
|
||||
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
|
|
@ -245,13 +245,15 @@ class JSONWriter extends TextResponseWriter {
|
|||
|
||||
writeArrayOpener(1);
|
||||
incLevel();
|
||||
writeStr(null,key,true);
|
||||
if (key==null) {
|
||||
writeNull(null);
|
||||
} else {
|
||||
writeStr(null, key, true);
|
||||
}
|
||||
writeArraySeparator();
|
||||
writeVal(key,val.getVal(i));
|
||||
decLevel();
|
||||
writeArrayCloser();
|
||||
|
||||
|
||||
}
|
||||
|
||||
decLevel();
|
||||
|
|
|
@ -64,4 +64,20 @@ public class JSONWriterTest extends AbstractSolrTestCase {
|
|||
assertEquals(buf.toString(), "a:3:{s:5:\"data1\";s:5:\"hello\";s:5:\"data2\";i:42;s:5:\"data3\";b:1;}");
|
||||
}
|
||||
|
||||
public void testJSON() throws IOException {
|
||||
SolrQueryRequest req = req("wt","json","json.nl","arrarr");
|
||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||
JSONResponseWriter w = new JSONResponseWriter();
|
||||
|
||||
StringWriter buf = new StringWriter();
|
||||
NamedList nl = new NamedList();
|
||||
nl.add("data1", "hello");
|
||||
nl.add(null, 42);
|
||||
rsp.add("nl", nl);
|
||||
|
||||
w.write(buf, req, rsp);
|
||||
assertEquals(buf.toString(), "{\"nl\":[[\"data1\",\"hello\"],[null,42]]}");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue