Repository: calcite
Updated Branches:
  refs/heads/master 188c8020d -> 534b09ffd


[CALCITE-2014] Look for saffron.properties file in classpath rather than in 
working directory (Arina Ielchiieva)

Close apache/calcite#550


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/534b09ff
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/534b09ff
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/534b09ff

Branch: refs/heads/master
Commit: 534b09ffdf4972cb9efb978ef7fae46b9deb8e32
Parents: 188c802
Author: Arina Ielchiieva <[email protected]>
Authored: Tue Oct 17 14:58:28 2017 +0300
Committer: Julian Hyde <[email protected]>
Committed: Tue Oct 17 13:37:22 2017 -0700

----------------------------------------------------------------------
 .../apache/calcite/util/SaffronProperties.java   | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/534b09ff/core/src/main/java/org/apache/calcite/util/SaffronProperties.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/SaffronProperties.java 
b/core/src/main/java/org/apache/calcite/util/SaffronProperties.java
index 8f45d68..1397871 100644
--- a/core/src/main/java/org/apache/calcite/util/SaffronProperties.java
+++ b/core/src/main/java/org/apache/calcite/util/SaffronProperties.java
@@ -22,9 +22,8 @@ import org.apache.calcite.runtime.Resources.Default;
 import org.apache.calcite.runtime.Resources.Resource;
 import org.apache.calcite.runtime.Resources.StringProp;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.security.AccessControlException;
 import java.util.Enumeration;
 import java.util.Properties;
@@ -109,16 +108,14 @@ public interface SaffronProperties {
     static SaffronProperties instance() {
       Properties properties = new Properties();
 
-      // read properties from the file "saffron.properties", if it exists
-      File file = new File("saffron.properties");
-      try {
-        if (file.exists()) {
-          try {
-            properties.load(new FileInputStream(file));
-          } catch (IOException e) {
-            throw new RuntimeException("while reading from " + file, e);
-          }
+      // read properties from the file "saffron.properties", if it exists in 
classpath
+      try (InputStream stream = Helper.class.getClassLoader()
+          .getResourceAsStream("saffron.properties")) {
+        if (stream != null) {
+          properties.load(stream);
         }
+      } catch (IOException e) {
+        throw new RuntimeException("while reading from saffron.properties 
file", e);
       } catch (AccessControlException e) {
         // we're in a sandbox
       }

Reply via email to