#vulnerable code 
                                @SuppressWarnings("resource")
    private void _testEscapeAboveAscii(boolean useStream) throws Exception
    {
        JsonFactory f = new JsonFactory();
        final String VALUE = "chars: [\u00A0]/[\u1234]";
        final String KEY = "fun:\u0088:\u3456";
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        JsonGenerator jgen;

        // First: output normally; should not add escaping
        if (useStream) {
            jgen = f.createJsonGenerator(bytes, JsonEncoding.UTF8);
        } else {
            jgen = f.createJsonGenerator(new OutputStreamWriter(bytes, "UTF-8"));
        }
        jgen.writeStartArray();
        jgen.writeString(VALUE);
        jgen.writeEndArray();
        jgen.close();
        String json = bytes.toString("UTF-8");
        
        assertEquals("["+quote(VALUE)+"]", json);

        // And then with forced ASCII; first, values

        bytes = new ByteArrayOutputStream();
        if (useStream) {
            jgen = f.createJsonGenerator(bytes, JsonEncoding.UTF8);
        } else {
            jgen = f.createJsonGenerator(new OutputStreamWriter(bytes, "UTF-8"));
        }
        jgen.enable(JsonGenerator.Feature.ESCAPE_NON_ASCII);
        jgen.writeStartArray();
        jgen.writeString(VALUE);
        jgen.writeEndArray();
        jgen.close();
        json = bytes.toString("UTF-8");
        assertEquals("["+quote("chars: [\\u00A0]/[\\u1234]")+"]", json);

        // and then keys
        bytes = new ByteArrayOutputStream();
        if (useStream) {
            jgen = f.createJsonGenerator(bytes, JsonEncoding.UTF8);
        } else {
            jgen = f.createJsonGenerator(new OutputStreamWriter(bytes, "UTF-8"));
        }
        jgen.enable(JsonGenerator.Feature.ESCAPE_NON_ASCII);
        jgen.writeStartObject();
        jgen.writeFieldName(KEY);
        jgen.writeBoolean(true);
        jgen.writeEndObject();
        jgen.close();
        json = bytes.toString("UTF-8");
        assertEquals("{"+quote("fun:\\u0088:\\u3456")+":true}", json);
    } 
                            #location 15 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @SuppressWarnings("resource")
    private void _testEscapeAboveAscii(boolean useStream) throws Exception
    {
        JsonFactory f = new JsonFactory();
        final String VALUE = "chars: [\u00A0]/[\u1234]";
        final String KEY = "fun:\u0088:\u3456";
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        JsonGenerator jgen;

        // First: output normally; should not add escaping
        if (useStream) {
            jgen = f.createGenerator(bytes, JsonEncoding.UTF8);
        } else {
            jgen = f.createGenerator(new OutputStreamWriter(bytes, "UTF-8"));
        }
        jgen.writeStartArray();
        jgen.writeString(VALUE);
        jgen.writeEndArray();
        jgen.close();
        String json = bytes.toString("UTF-8");
        
        assertEquals("["+quote(VALUE)+"]", json);

        // And then with forced ASCII; first, values

        bytes = new ByteArrayOutputStream();
        if (useStream) {
            jgen = f.createGenerator(bytes, JsonEncoding.UTF8);
        } else {
            jgen = f.createGenerator(new OutputStreamWriter(bytes, "UTF-8"));
        }
        jgen.enable(JsonGenerator.Feature.ESCAPE_NON_ASCII);
        jgen.writeStartArray();
        jgen.writeString(VALUE);
        jgen.writeEndArray();
        jgen.close();
        json = bytes.toString("UTF-8");
        assertEquals("["+quote("chars: [\\u00A0]/[\\u1234]")+"]", json);

        // and then keys
        bytes = new ByteArrayOutputStream();
        if (useStream) {
            jgen = f.createGenerator(bytes, JsonEncoding.UTF8);
        } else {
            jgen = f.createGenerator(new OutputStreamWriter(bytes, "UTF-8"));
        }
        jgen.enable(JsonGenerator.Feature.ESCAPE_NON_ASCII);
        jgen.writeStartObject();
        jgen.writeFieldName(KEY);
        jgen.writeBoolean(true);
        jgen.writeEndObject();
        jgen.close();
        json = bytes.toString("UTF-8");
        assertEquals("{"+quote("fun:\\u0088:\\u3456")+":true}", json);
    }