#fixed code
                             @Override
	protected void doRequest(ServletTransaction transaction)
			throws ServletException {
		try {
			HttpServletRequest request = transaction.getServletRequest();
			Client client = ClientCatalog
					.getClient(request.getParameter("use"));
			String report = request.getParameter("report");
			String emails = request.getParameter("emails");
			if (emails == null)
				return;
			HtmlEmail htmlEmail = client.getMailer().getHtmlEmail(emails, null);
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			if ("statistics".equals(report)) {
				htmlEmail.setSubject("OpenSearchServer statistics report");
				doStatistics(client, request.getParameter("stat"), request
						.getParameter("period"), pw);
			}
			pw.close();
			sw.close();
			String html = sw.toString();
			if (html == null || html.length() == 0) {
				transaction.addXmlResponse("Result", "Nothing to send");
			} else {
				htmlEmail.setHtmlMsg(sw.toString());
				htmlEmail
						.setTextMsg("Your email client does not support HTML messages");
				htmlEmail.send();
			}
			transaction.addXmlResponse("MailSent", emails);
		} catch (Exception e) {
			throw new ServletException(e);
		}
	}
#vulnerable code 
                             @Override
	protected void doRequest(ServletTransaction transaction)
			throws ServletException {
		try {
			HttpServletRequest request = transaction.getServletRequest();
			Client client = ClientCatalog
					.getClient(request.getParameter("use"));
			String report = request.getParameter("report");
			String emails = request.getParameter("emails");
			if (emails == null)
				return;
			HtmlEmail htmlEmail = client.getMailer().getHtmlEmail(emails, null);
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			if ("statistics".equals(report)) {
				htmlEmail.setSubject("OpenSearchServer statistics report");
				doStatistics(client, request.getParameter("stat"), request
						.getParameter("period"), pw);
			}
			htmlEmail.setHtmlMsg(sw.toString());
			htmlEmail.send();
			transaction.addXmlResponse("MailSent", emails);
		} catch (Exception e) {
			throw new ServletException(e);
		}
	} 
                            #location 15 
                            #vulnerability type RESOURCE_LEAK