#vulnerable code 
                                private void handleRequest(SlingHttpServletRequest request, SlingHttpServletResponse response)
            throws IOException,
        RepositoryException, ServletException {

        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");

        // Generate current date and time for filename
        DateFormat df = new SimpleDateFormat("yyyyddMM_HHmmss");
        Date today = Calendar.getInstance().getTime();
        String filename = df.format(today);

        response.setHeader("Content-Disposition", "filename=jcr-checksum-"
            + filename + ".json");

        String optionsName = request.getParameter(ServletConstants.OPTIONS_NAME);
        ChecksumGeneratorOptions options =
            ChecksumGeneratorOptionsFactory.getOptions(request, optionsName);

        if (log.isDebugEnabled()) {
            log.debug(options.toString());
        }

        Set<String> paths = RequestChecksumGeneratorOptions.getPaths(request);

        if (CollectionUtils.isEmpty(paths)) {
            try {
                response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                response.getWriter().print(
                    "ERROR: At least one path must be specified");
            } catch (IOException ioe) {
                throw ioe;
            }
        }

        Session session = request.getResourceResolver().adaptTo(Session.class);

        JsonWriter jsonWriter = new JsonWriter(response.getWriter());

        try {
            JSONGenerator.generateJSON(session, paths, options, jsonWriter);
        } catch (RepositoryException e) {
            throw new ServletException("Error accessing repository", e);
        } catch (IOException e) {
            throw new ServletException("Unable to generate json", e);
        }
    } 
                            #location 41 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             private void handleRequest(SlingHttpServletRequest request, SlingHttpServletResponse response)
			throws IOException,
			RepositoryException, ServletException {

		response.setContentType("application/json");
		response.setCharacterEncoding("UTF-8");

		// Generate current date and time for filename
		DateFormat df = new SimpleDateFormat("yyyyddMM_HHmmss");
		Date today = Calendar.getInstance().getTime();
		String filename = df.format(today);

		response.setHeader("Content-Disposition", "filename=jcr-checksum-"
				+ filename + ".json");

		String optionsName = request.getParameter(ServletConstants.OPTIONS_NAME);
		ChecksumGeneratorOptions options =
				ChecksumGeneratorOptionsFactory.getOptions(request, optionsName);

		if (log.isDebugEnabled()) {
			log.debug(options.toString());
		}

		Set<String> paths = RequestChecksumGeneratorOptions.getPaths(request);

		if (CollectionUtils.isEmpty(paths)) {
			try {
				response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
				response.getWriter().print(
						"ERROR: At least one path must be specified");
			} catch (IOException ioe) {
				throw ioe;
			}
		} else {
			Session session = request.getResourceResolver().adaptTo(Session.class);

			JsonWriter jsonWriter = new JsonWriter(response.getWriter());

			try {
				JSONGenerator.generateJSON(session, paths, options, jsonWriter);
				jsonWriter.close();
			} catch (RepositoryException e) {
				throw new ServletException("Error accessing repository", e);
			} catch (IOException e) {
				throw new ServletException("Unable to generate json", e);
			}
		}
	}