Skip to content

Commit

Permalink
Use try-with-resources
Browse files Browse the repository at this point in the history
Stop Coverity Scan complaining
  • Loading branch information
markt-asf committed Jul 5, 2023
1 parent 171cfff commit 2d932ec
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions java/org/apache/tomcat/buildutil/MimeTypeMappings.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,19 @@ public static void main(String... args) throws Exception {
SortedMap<String, String> sortedWebXmlMimeMappings = new TreeMap<>(webXmlMimeMappings);

File f = new File("java/org/apache/catalina/startup/MimeTypeMappings.properties");
FileOutputStream fos = new FileOutputStream(f);
Writer w = new OutputStreamWriter(fos, StandardCharsets.US_ASCII);
try (FileOutputStream fos = new FileOutputStream(f);
Writer w = new OutputStreamWriter(fos, StandardCharsets.US_ASCII)) {

Utils.insertLicense(w);
Utils.insertLicense(w);

w.write(System.lineSeparator());

for (Map.Entry<String, String> mapping : sortedWebXmlMimeMappings.entrySet()) {
w.write(mapping.getKey());
w.write("=");
w.write(mapping.getValue());
w.write(System.lineSeparator());
}

w.close();
fos.close();
for (Map.Entry<String, String> mapping : sortedWebXmlMimeMappings.entrySet()) {
w.write(mapping.getKey());
w.write("=");
w.write(mapping.getValue());
w.write(System.lineSeparator());
}
}
}
}

0 comments on commit 2d932ec

Please sign in to comment.