atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkan...@apache.org
Subject incubator-atlas git commit: ATLAS-1539 Address coverity scan issues
Date Thu, 16 Feb 2017 18:00:48 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master 20fb5894d -> 90f1566af


ATLAS-1539 Address coverity scan issues


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/90f1566a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/90f1566a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/90f1566a

Branch: refs/heads/master
Commit: 90f1566afabaec8aca5d87050eab43f56f911644
Parents: 20fb589
Author: Dave Kantor <dkantor@us.ibm.com>
Authored: Thu Feb 16 13:00:38 2017 -0500
Committer: Dave Kantor <dkantor@us.ibm.com>
Committed: Thu Feb 16 13:00:38 2017 -0500

----------------------------------------------------------------------
 .../apache/atlas/ApplicationPropertiesTest.java | 62 ++++++++++++++++----
 1 file changed, 52 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/90f1566a/common/src/test/java/org/apache/atlas/ApplicationPropertiesTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/atlas/ApplicationPropertiesTest.java b/common/src/test/java/org/apache/atlas/ApplicationPropertiesTest.java
index cddf974..89e5e9b 100644
--- a/common/src/test/java/org/apache/atlas/ApplicationPropertiesTest.java
+++ b/common/src/test/java/org/apache/atlas/ApplicationPropertiesTest.java
@@ -32,23 +32,52 @@ public class ApplicationPropertiesTest {
     @Test
     public void testGetFileAsInputStream() throws Exception {
         Configuration props = ApplicationProperties.get("test.properties");
+        InputStream inStr = null;
 
         // configured file as class loader resource
-        InputStream inStr = ApplicationProperties.getFileAsInputStream(props, "jaas.properties.file",
null);
-        assertNotNull(inStr);
+        try {
+            inStr = ApplicationProperties.getFileAsInputStream(props, "jaas.properties.file",
null);
+            assertNotNull(inStr);
+        }
+        finally {
+            if (inStr != null) {
+                inStr.close();
+            }
+        }
 
         // configured file from file system path
         props.setProperty("jaas.properties.file", "src/test/resources/atlas-jaas.properties");
-        inStr = ApplicationProperties.getFileAsInputStream(props, "jaas.properties.file",
null);
-        assertNotNull(inStr);
+        try {
+            inStr = ApplicationProperties.getFileAsInputStream(props, "jaas.properties.file",
null);
+            assertNotNull(inStr);
+        }
+        finally {
+            if (inStr != null) {
+                inStr.close();
+            }
+        }
 
         // default file as class loader resource
-        inStr = ApplicationProperties.getFileAsInputStream(props, "property.not.specified.in.config",
"atlas-jaas.properties");
-        assertNotNull(inStr);
+        try {
+            inStr = ApplicationProperties.getFileAsInputStream(props, "property.not.specified.in.config",
"atlas-jaas.properties");
+            assertNotNull(inStr);
+        }
+        finally {
+            if (inStr != null) {
+                inStr.close();
+            }
+        }
 
         // default file relative to working directory
-        inStr = ApplicationProperties.getFileAsInputStream(props, "property.not.specified.in.config",
"src/test/resources/atlas-jaas.properties");
-        assertNotNull(inStr);
+        try {
+            inStr = ApplicationProperties.getFileAsInputStream(props, "property.not.specified.in.config",
"src/test/resources/atlas-jaas.properties");
+            assertNotNull(inStr);
+        }
+        finally {
+            if (inStr != null) {
+                inStr.close();
+            }
+        }
 
         // default file relative to atlas configuration directory
         String originalConfDirSetting = System.setProperty(ApplicationProperties.ATLAS_CONFIGURATION_DIRECTORY_PROPERTY,
"src/test/resources");
@@ -57,6 +86,9 @@ public class ApplicationPropertiesTest {
             assertNotNull(inStr);
         }
         finally {
+            if (inStr != null) {
+                inStr.close();
+            }
             if (originalConfDirSetting != null) {
                 System.setProperty(ApplicationProperties.ATLAS_CONFIGURATION_DIRECTORY_PROPERTY,
originalConfDirSetting);
             }
@@ -67,21 +99,31 @@ public class ApplicationPropertiesTest {
 
         // non-existent property and no default file
         try {
-            ApplicationProperties.getFileAsInputStream(props, "property.not.specified.in.config",
null);
+            inStr = ApplicationProperties.getFileAsInputStream(props, "property.not.specified.in.config",
null);
             fail("Expected " + AtlasException.class.getSimpleName() + " but none thrown");
         }
         catch (AtlasException e) {
             // good
         }
+        finally {
+            if (inStr != null) {
+                inStr.close();
+            }
+        }
 
         // configured file not found in file system or classpath
         props.setProperty("jaas.properties.file", "does_not_exist.txt");
         try {
-            ApplicationProperties.getFileAsInputStream(props, "jaas.properties.file", null);
+            inStr = ApplicationProperties.getFileAsInputStream(props, "jaas.properties.file",
null);
             fail("Expected " + AtlasException.class.getSimpleName() + " but none thrown");
         }
         catch (AtlasException e) {
             // good
         }
+        finally {
+            if (inStr != null) {
+                inStr.close();
+            }
+        }
     }
 }


Mime
View raw message