This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new bd1393b71f Use try-with-resources
bd1393b71f is described below

commit bd1393b71ff5d24ab3bea233095506b295fbafce
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jul 5 14:08:47 2023 +0100

    Use try-with-resources
    
    Stop Coverity Scan complaining
---
 .../apache/tomcat/buildutil/MimeTypeMappings.java  | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/tomcat/buildutil/MimeTypeMappings.java 
b/java/org/apache/tomcat/buildutil/MimeTypeMappings.java
index 1190a628f6..3f467ad7d5 100644
--- a/java/org/apache/tomcat/buildutil/MimeTypeMappings.java
+++ b/java/org/apache/tomcat/buildutil/MimeTypeMappings.java
@@ -52,21 +52,19 @@ public class MimeTypeMappings {
         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());
+            }
+        }
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to