Skip to content

ArrayIndexOutOfBoundsException when parsing large Map #49

@mjavault

Description

@mjavault

Howdy,
I'm getting the following error when parsing a Map that contains a large number of items (2387 in this case) using Jackson Jr version 2.8.3:

java.lang.ArrayIndexOutOfBoundsException: 3645

The source JSON was generated using the JSON.std.asString() function with no problem, but the result can't be parse back by the JSON.std.anyFrom() function.
Attached a file that reproduces the problem.
large_map.txt

File does not contain duplicate keys, and the parsing works when I reduce the number of items in the Map down to 1822. You can also use the following code to reproduce:

    public static void main(String[] args) {
        int i = 0;
        try {
            for (i = 1; i < 3000; i++) {
                testLargeJson(i);
            }
        } catch (Exception ex) {
            System.out.println(i);
            ex.printStackTrace();
        }
    }

    private static void testLargeJson(int size) throws Exception {
        Map<String, Object> map = new HashMap<>();
        for (int i = 0; i < size; i++) {
            map.put("" + i, new HashMap<String, Object>());
        }
        String output = JSON.std.asString(map);
        Map json = (Map) JSON.std.anyFrom(output);
    }

This crashes for i = 1823 but not before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions