#vulnerable code 
                                private String readContents(final URI uri, final Charset charset) throws IOException {
        InputStream in = null;
        try {
            in = uri.toURL().openStream();
            final Reader reader = new InputStreamReader(in, charset);
            final StringBuilder result = new StringBuilder(TEXT_BUFFER);
            final char[] buff = new char[PAGE];
            int count = -1;
            while ((count = reader.read(buff)) >= 0) {
                result.append(buff, 0, count);
            }
            return result.toString();
        } finally {
            try {
                in.close();
            } catch (final Exception ignored) {
                // ignored
            }
        }
    } 
                            #location 12 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                private String readContents(final URI uri, final Charset charset) throws IOException {
        if (charset == null) {
            throw new IllegalArgumentException("charset must not be null");
        }
        Reader reader = null;
        try {
            InputStream in = uri.toURL().openStream();
            // The stream is open and charset is not null, we can create the reader safely without a possible NPE.
            reader = new InputStreamReader(in, charset);
            final StringBuilder result = new StringBuilder(TEXT_BUFFER);
            final char[] buff = new char[PAGE];
            int count = -1;
            while ((count = reader.read(buff)) >= 0) {
                result.append(buff, 0, count);
            }
            return result.toString();
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
            } catch (final Exception ignored) {
                // ignored
            }
        }
    }