@Test(expected = IllegalArgumentException.class) public void avoidInfiniteLoop_TOMEE1970() throws IOException { assertNotNull(SimpleJSonParser.read(new ByteArrayInputStream(("{\n" + " \"resources\":{\n" + " \"jdbc/test\":{\n" + " \"type\":\"DataSource\",\n" + " \"classpath\":\"whatever\",\n" + " \"properties\":{\n" + " \"a\":\"b\n" + " }\n" + " }\n" + " }\n" + "}\n").getBytes(StandardCharsets.UTF_8)))); }
public static Object read(final InputStream is) throws IOException { Map<String, Object> json = null; Collection<Object> array = null; int read; char current; while ((read = is.read()) != -1) { current = (char) read; if (current == '{') { json = new HashMap<>(); } else if (current == '}') { return json; } else if (current == '[') { array = new ArrayList<>(); } else if (current == ']') { return array; } else if (current == '"') { final StringBuilder b = new StringBuilder(); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && current != '\"'); if (read == -1) { throw new IllegalArgumentException("String should be between \""); } final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } else if (current != ':' && current != '=' && current != ',' && !isWhiteSpace(current)) { final StringBuilder b = new StringBuilder().append(current); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && !isWhiteSpace(current) && current != ','); final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } } throw new IllegalArgumentException("Please check input, a } is probably missing"); }
SimpleJSonParser { public static Object read(final InputStream is) throws IOException { Map<String, Object> json = null; Collection<Object> array = null; int read; char current; while ((read = is.read()) != -1) { current = (char) read; if (current == '{') { json = new HashMap<>(); } else if (current == '}') { return json; } else if (current == '[') { array = new ArrayList<>(); } else if (current == ']') { return array; } else if (current == '"') { final StringBuilder b = new StringBuilder(); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && current != '\"'); if (read == -1) { throw new IllegalArgumentException("String should be between \""); } final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } else if (current != ':' && current != '=' && current != ',' && !isWhiteSpace(current)) { final StringBuilder b = new StringBuilder().append(current); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && !isWhiteSpace(current) && current != ','); final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } } throw new IllegalArgumentException("Please check input, a } is probably missing"); } }
SimpleJSonParser { public static Object read(final InputStream is) throws IOException { Map<String, Object> json = null; Collection<Object> array = null; int read; char current; while ((read = is.read()) != -1) { current = (char) read; if (current == '{') { json = new HashMap<>(); } else if (current == '}') { return json; } else if (current == '[') { array = new ArrayList<>(); } else if (current == ']') { return array; } else if (current == '"') { final StringBuilder b = new StringBuilder(); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && current != '\"'); if (read == -1) { throw new IllegalArgumentException("String should be between \""); } final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } else if (current != ':' && current != '=' && current != ',' && !isWhiteSpace(current)) { final StringBuilder b = new StringBuilder().append(current); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && !isWhiteSpace(current) && current != ','); final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } } throw new IllegalArgumentException("Please check input, a } is probably missing"); } private  SimpleJSonParser(); }
SimpleJSonParser { public static Object read(final InputStream is) throws IOException { Map<String, Object> json = null; Collection<Object> array = null; int read; char current; while ((read = is.read()) != -1) { current = (char) read; if (current == '{') { json = new HashMap<>(); } else if (current == '}') { return json; } else if (current == '[') { array = new ArrayList<>(); } else if (current == ']') { return array; } else if (current == '"') { final StringBuilder b = new StringBuilder(); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && current != '\"'); if (read == -1) { throw new IllegalArgumentException("String should be between \""); } final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } else if (current != ':' && current != '=' && current != ',' && !isWhiteSpace(current)) { final StringBuilder b = new StringBuilder().append(current); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && !isWhiteSpace(current) && current != ','); final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } } throw new IllegalArgumentException("Please check input, a } is probably missing"); } private  SimpleJSonParser(); static Object read(final InputStream is); }
SimpleJSonParser { public static Object read(final InputStream is) throws IOException { Map<String, Object> json = null; Collection<Object> array = null; int read; char current; while ((read = is.read()) != -1) { current = (char) read; if (current == '{') { json = new HashMap<>(); } else if (current == '}') { return json; } else if (current == '[') { array = new ArrayList<>(); } else if (current == ']') { return array; } else if (current == '"') { final StringBuilder b = new StringBuilder(); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && current != '\"'); if (read == -1) { throw new IllegalArgumentException("String should be between \""); } final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } else if (current != ':' && current != '=' && current != ',' && !isWhiteSpace(current)) { final StringBuilder b = new StringBuilder().append(current); do { read = is.read(); current = (char) read; b.append(current); } while (read != -1 && !isWhiteSpace(current) && current != ','); final String value = PropertyPlaceHolderHelper.simpleValue(b.substring(0, b.length() - 1)); if (valueRead(is, json, array, value)) { return value; } } } throw new IllegalArgumentException("Please check input, a } is probably missing"); } private  SimpleJSonParser(); static Object read(final InputStream is);  }