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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 816ff406fca CAMEL-21973 Add try with resource to reported resource 
leaks (#1423)
816ff406fca is described below

commit 816ff406fca3d7a8e4063d7b6bf431353ff6de9b
Author: Tom Cunningham <[email protected]>
AuthorDate: Fri Apr 18 02:03:42 2025 -0400

    CAMEL-21973 Add try with resource to reported resource leaks (#1423)
    
    * CAMEL-21973 Add try with resource to reported resource leaks
    
    * Remove closes that are not needed because they are enclosed in 
try-with-resources
    
    * Remove extraneous semi-colon; regenerate
---
 .../springboot/maven/SpringBootAutoConfigurationMojo.java    |  3 +--
 .../apache/camel/springboot/maven/SpringBootStarterMojo.java | 12 ++++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git 
a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
 
b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
index da2b5947e3f..399e21d391c 100644
--- 
a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
+++ 
b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java
@@ -1926,8 +1926,7 @@ public class SpringBootAutoConfigurationMojo extends 
AbstractSpringBootGenerator
             }
         } else {
             // create new file
-            try {
-                InputStream is = 
getClass().getClassLoader().getResourceAsStream("license-header.txt");
+            try (InputStream is = 
getClass().getClassLoader().getResourceAsStream("license-header.txt")) {
                 String header = PackageHelper.loadText(is);
                 String code = lineToAdd;
                 // add empty new line after header
diff --git 
a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java
 
b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java
index dd08ed15e72..85f27ce6620 100644
--- 
a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java
+++ 
b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java
@@ -117,9 +117,9 @@ public class SpringBootStarterMojo extends 
AbstractSpringBootGenerator {
 
     private void fixAdditionalDependencies(Document pom) throws Exception {
         Properties properties = new Properties();
-        InputStream is = 
getClass().getResourceAsStream("/spring-boot-fix-dependencies.properties");
-        properties.load(is);
-        is.close();
+        try (InputStream is = 
getClass().getResourceAsStream("/spring-boot-fix-dependencies.properties")) {
+            properties.load(is);
+        }
 
         Set<String> deps = new 
TreeSet<>(csvToSet(properties.getProperty(getMainDepArtifactId())));
 
@@ -236,9 +236,9 @@ public class SpringBootStarterMojo extends 
AbstractSpringBootGenerator {
         // excluded dependencies
         Set<String> configExclusions = new HashSet<>();
         Properties properties = new Properties();
-        InputStream is = 
getClass().getResourceAsStream("/spring-boot-fix-dependencies.properties");
-        properties.load(is);
-        is.close();
+        try (InputStream is = 
getClass().getResourceAsStream("/spring-boot-fix-dependencies.properties")) {
+            properties.load(is);
+        }
 
         String artExcl = properties.getProperty("exclude_" + 
getMainDepArtifactId());
         getLog().debug("Configured exclusions: " + artExcl);

Reply via email to