#fixed code
                                @Override
    public String getResponseBodyExcerpt(int maxLength) throws IOException {
        String contentType = getContentType();
        String charset = "UTF-8";
        if (contentType != null) {
            for (String part : contentType.split(";")) {
                if (part.startsWith("charset=")) {
                    charset = part.substring("charset=".length());
                }
            }
        }
        String response = contentToString(charset);    
        return response.length() <= maxLength ? response : response.substring(0,maxLength);
    }
#vulnerable code 
                                @Override
    public String getResponseBodyExcerpt(int maxLength) throws IOException {
        String contentType = getContentType();
        String charset = "UTF-8";
        if (contentType != null) {
            for (String part : contentType.split(";")) {
                if (part.startsWith("charset=")) {
                    charset = part.substring("charset=".length());
                }
            }
        }
        InputStream responseInput = getResponseBodyAsStream();
        String response = contentToString(charset);
    
        return response.length() <= maxLength ? response : response.substring(0,maxLength);
    } 
                            #location 12 
                            #vulnerability type RESOURCE_LEAK