#fixed code
                              private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
    LOG.info("Sending Monitor email to " + emailTargets.size() + " targets: " + emailTargets + " Email body: " + body);
    for (String emailTarget : emailTargets) {
      String[] command = {"/bin/mail", "-s", "Hank-Notification", emailTarget};
      Process process = Runtime.getRuntime().exec(command);
      OutputStreamWriter writer = new OutputStreamWriter(process.getOutputStream());
      writer.write(body);
      writer.close();
      process.getOutputStream().close();
      process.waitFor();
    }
  }
#vulnerable code 
                              private void sendEmails(Set<String> emailTargets, String body) throws IOException {
    File temporaryEmailBody = File.createTempFile("_tmp_" + getClass().getSimpleName(), null);
    BufferedWriter writer = new BufferedWriter(new FileWriter(temporaryEmailBody, false));
    writer.write(body);

    LOG.info("Sending Monitor email to " + emailTargets.size() + " targets: " + emailTargets + " Email body: " + body);

    for (String emailTarget : emailTargets) {
      Runtime.getRuntime().exec("cat " + temporaryEmailBody.getAbsolutePath()
          + " | mail -s 'Hank Notification' " + emailTarget);
    }

    if (!temporaryEmailBody.delete()) {
      throw new IOException("Could not delete " + temporaryEmailBody.getAbsolutePath());
    }
  } 
                            #location 9 
                            #vulnerability type RESOURCE_LEAK