Test case:
import org.apache.jena.atlas.json.JSON;
import org.junit.Test;
public class JSONTest {
@Test
public void testRepeat() {
try {
JSON.parse("");
}
catch(Exception ex) {
// Ignore
System.out.println("Expected error " + ex);
}
JSON.parse("{}");
}
}
works fine if the first JSON.parse gets commented out, but reports
org.apache.jena.atlas.json.JsonParseException: Not a JSON object START:
[null]
at
org.apache.jena.atlas.json.io.parser.ParserBase.exception(ParserBase.java:130)
at org.apache.jena.atlas.json.io.parser.JSONP.parse(JSONP.java:49)
at
org.apache.jena.atlas.json.io.parser.JSONParser.parse(JSONParser.java:58)
at
org.apache.jena.atlas.json.io.parser.JSONParser.parse(JSONParser.java:52)
at org.apache.jena.atlas.json.JSON._parse(JSON.java:125)
at org.apache.jena.atlas.json.JSON._parse(JSON.java:105)
at org.apache.jena.atlas.json.JSON.parse(JSON.java:44)
at org.topbraid.jenax.test.JSONTest.testRepeat(JSONTest.java:17)
otherwise. The first parsing should not have an effect on subsequent
calls. Our work-around is not to ever call JSON.parse with an empty
string, so it's not high priority but I thought I'd report it anyway in
case there is a deeper problem (e.g. with concurrency of this class).
Thanks
Holger