#vulnerable code 
                                protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        LOGGER.info("CSP-Reporting-Servlet");

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
            StringBuilder responseBuilder = new StringBuilder();

            String inputStr;
            while ((inputStr = reader.readLine()) != null) {
                responseBuilder.append(inputStr);
            }

            LOGGER.info("REPORT " + responseBuilder.toString());

            JSONObject json = new JSONObject(responseBuilder.toString());
            JSONObject cspReport = json.getJSONObject("csp-report");
            LOGGER.info("document-uri: " + cspReport.getString("document-uri"));
            LOGGER.info("referrer: " + cspReport.getString("referrer"));
            LOGGER.info("blocked-uri: " + cspReport.getString("blocked-uri"));
            LOGGER.info("violated-directive: " + cspReport.getString("violated-directive"));
            LOGGER.info("source-file: " + cspReport.getString("source-file"));
            LOGGER.info("script-sample: " + cspReport.getString("script-sample"));
            LOGGER.info("line-number: " + cspReport.getString("line-number"));
        } catch (IOException | JSONException ex) {
            LOGGER.error(ex.getMessage(), ex);
        }
    } 
                            #location 24 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        LOGGER.info("CSP-Reporting-Servlet");

        try (BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()))) {
            StringBuilder responseBuilder = new StringBuilder();

            String inputStr;
            while ((inputStr = reader.readLine()) != null) {
                responseBuilder.append(inputStr);
            }

            LOGGER.info("REPORT " + responseBuilder.toString());

            JSONObject json = new JSONObject(responseBuilder.toString());
            JSONObject cspReport = json.getJSONObject("csp-report");
            LOGGER.info("document-uri: " + cspReport.getString("document-uri"));
            LOGGER.info("referrer: " + cspReport.getString("referrer"));
            LOGGER.info("blocked-uri: " + cspReport.getString("blocked-uri"));
            LOGGER.info("violated-directive: " + cspReport.getString("violated-directive"));
            LOGGER.info("source-file: " + cspReport.getString("source-file"));
            LOGGER.info("script-sample: " + cspReport.getString("script-sample"));
            LOGGER.info("line-number: " + cspReport.getString("line-number"));
        } catch (IOException | JSONException ex) {
            LOGGER.error(ex.getMessage(), ex);
        }
    }