You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/03/22 11:42:05 UTC

[camel] 06/08: (chores) camel-report-maven-plugin: use try-with-resources where possible

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

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit aabab430e490be7dd8758f78853400eb62847aff
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Tue Mar 22 11:04:39 2022 +0100

    (chores) camel-report-maven-plugin: use try-with-resources where possible
    
    Co-authored-by: Nicolas Filotto <es...@users.noreply.github.com>
---
 .../main/java/org/apache/camel/maven/ValidateMojo.java | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
index 963d40b..457ab41 100644
--- a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
+++ b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/ValidateMojo.java
@@ -558,19 +558,19 @@ public class ValidateMojo extends AbstractExecMojo {
             String fqn = file.getPath();
             String baseDir = ".";
 
-            InputStream is = new FileInputStream(file);
-            XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, fileEndpoints);
-            is.close();
+            try (InputStream is = new FileInputStream(file)) {
+                XmlRouteParser.parseXmlRouteEndpoints(is, baseDir, fqn, fileEndpoints);
+            }
             // need a new stream
-            is = new FileInputStream(file);
-            XmlRouteParser.parseXmlRouteSimpleExpressions(is, baseDir, fqn, fileSimpleExpressions);
-            is.close();
+            try (InputStream is = new FileInputStream(file)) {
+                XmlRouteParser.parseXmlRouteSimpleExpressions(is, baseDir, fqn, fileSimpleExpressions);
+            }
 
             if (duplicateRouteId) {
                 // need a new stream
-                is = new FileInputStream(file);
-                XmlRouteParser.parseXmlRouteRouteIds(is, baseDir, fqn, fileRouteIds);
-                is.close();
+                try (InputStream is = new FileInputStream(file)) {
+                    XmlRouteParser.parseXmlRouteRouteIds(is, baseDir, fqn, fileRouteIds);
+                }
             }
 
             // add what we found in this file to the total list