You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/03/16 14:52:26 UTC

[camel] 01/04: Try-with-resources: Lets use in the catalog

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

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

commit f1806d9ef9ceb7b9371a9814a7e535a87a9daf8b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Mar 16 15:29:17 2020 +0100

    Try-with-resources: Lets use in the catalog
---
 .../apache/camel/catalog/DefaultRuntimeProvider.java | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java b/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
index b943647..9efe85d 100644
--- a/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
+++ b/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
@@ -107,7 +107,7 @@ public class DefaultRuntimeProvider implements RuntimeProvider {
     @Override
     public List<String> findComponentNames() {
         List<String> names = new ArrayList<>();
-        InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getComponentsCatalog());
+        try (InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getComponentsCatalog())) {
         if (is != null) {
             try {
                 CatalogHelper.loadLines(is, names);
@@ -115,13 +115,16 @@ public class DefaultRuntimeProvider implements RuntimeProvider {
                 // ignore
             }
         }
+        } catch (IOException e1) {
+			// ignore 
+		}
         return names;
     }
 
     @Override
     public List<String> findDataFormatNames() {
         List<String> names = new ArrayList<>();
-        InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getDataFormatsCatalog());
+        try (InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getDataFormatsCatalog())) {
         if (is != null) {
             try {
                 CatalogHelper.loadLines(is, names);
@@ -129,13 +132,16 @@ public class DefaultRuntimeProvider implements RuntimeProvider {
                 // ignore
             }
         }
+        } catch (IOException e1) {
+			// ignore
+		}
         return names;
     }
 
     @Override
     public List<String> findLanguageNames() {
         List<String> names = new ArrayList<>();
-        InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getLanguageCatalog());
+        try (InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getLanguageCatalog())) {
         if (is != null) {
             try {
                 CatalogHelper.loadLines(is, names);
@@ -143,13 +149,16 @@ public class DefaultRuntimeProvider implements RuntimeProvider {
                 // ignore
             }
         }
+        } catch (IOException e1) {
+			// ignore
+		}
         return names;
     }
 
     @Override
     public List<String> findOtherNames() {
         List<String> names = new ArrayList<>();
-        InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getOtherCatalog());
+        try (InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getOtherCatalog())) {
         if (is != null) {
             try {
                 CatalogHelper.loadLines(is, names);
@@ -157,6 +166,9 @@ public class DefaultRuntimeProvider implements RuntimeProvider {
                 // ignore
             }
         }
+        } catch (IOException e1) {
+			// ignore
+		}
         return names;
     }
 }