You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2025/05/15 13:39:00 UTC
[jira] [Resolved] (CAMEL-21973) Add try with resources to reported errors in coverity
[ https://issues.apache.org/jira/browse/CAMEL-21973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-21973.
---------------------------------
Resolution: Fixed
> Add try with resources to reported errors in coverity
> -----------------------------------------------------
>
> Key: CAMEL-21973
> URL: https://issues.apache.org/jira/browse/CAMEL-21973
> Project: Camel
> Issue Type: Task
> Components: camel-spring-boot
> Reporter: Thomas Cunningham
> Assignee: Thomas Cunningham
> Priority: Minor
> Fix For: 4.12.0
>
>
>
> *Error: RESOURCE_LEAK ([CWE-404|https://cwe.mitre.org/data/definitions/404.html]):*
> [[#def2]|https://cov01.lab.eng.brq2.redhat.com/covscanhub/task/869615/log/camel-spring-boot-4.10.3.redhat-00003/scan-results-imp.html#def2]
> [important] tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java:1930:17: {*}alloc_fn{*}: A new resource is returned from allocation method "getResourceAsStream". tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java:1930:17: {*}var_assign{*}: Assigning: "is" = resource returned from "(java.lang.Class)getClass().getClassLoader().getResourceAsStream("license-header.txt")". tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java:1939:17:
> *leaked_resource*
> : Variable "is" going out of scope leaks the resource it refers to. # 1937| } # 1938| # 1939|-> FileUtils.write(target, code, StandardCharsets.UTF_8); # 1940| getLog().info("Created file: " + target); # 1941| is.close();
>
> *Error: RESOURCE_LEAK ([CWE-404|https://cwe.mitre.org/data/definitions/404.html]):*
> [[#def3]|https://cov01.lab.eng.brq2.redhat.com/covscanhub/task/869615/log/camel-spring-boot-4.10.3.redhat-00003/scan-results-imp.html#def3]
> [important] tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java:120:9: {*}alloc_fn{*}: A new resource is returned from allocation method "getResourceAsStream". tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java:120:9: {*}var_assign{*}: Assigning: "is" = resource returned from "(java.lang.Class)getClass().getResourceAsStream("/spring-boot-fix-dependencies.properties")". tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java:121:9: {*}noescape{*}: Resource "is" is not closed or saved in "load". tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java:121:9:
> *leaked_resource*
> : Variable "is" going out of scope leaks the resource it refers to. # 119| Properties properties = new Properties(); # 120| InputStream is = getClass().getResourceAsStream("/spring-boot-fix-dependencies.properties"); # 121|-> properties.load(is); # 122| is.close(); # 123|
>
> *Error: RESOURCE_LEAK ([CWE-404|https://cwe.mitre.org/data/definitions/404.html]):*
> [[#def4]|https://cov01.lab.eng.brq2.redhat.com/covscanhub/task/869615/log/camel-spring-boot-4.10.3.redhat-00003/scan-results-imp.html#def4]
> [important] tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java:238:9: {*}alloc_fn{*}: A new resource is returned from allocation method "getResourceAsStream". tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java:238:9: {*}var_assign{*}: Assigning: "is" = resource returned from "(java.lang.Class)getClass().getResourceAsStream("/spring-boot-fix-dependencies.properties")". tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java:239:9: {*}noescape{*}: Resource "is" is not closed or saved in "load". tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootStarterMojo.java:239:9:
> *leaked_resource*
> : Variable "is" going out of scope leaks the resource it refers to. # 237| Properties properties = new Properties(); # 238| InputStream is = getClass().getResourceAsStream("/spring-boot-fix-dependencies.properties"); # 239|-> properties.load(is); # 240| is.close(); # 241|
--
This message was sent by Atlassian Jira
(v8.20.10#820010)