Skip to content

Commit

Permalink
[CALCITE-2014] Look for saffron.properties file in classpath rather t…
Browse files Browse the repository at this point in the history
…han in working directory (Arina Ielchiieva)

Close #550
  • Loading branch information
arina-ielchiieva authored and julianhyde committed Oct 17, 2017
1 parent 188c802 commit 534b09f
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions core/src/main/java/org/apache/calcite/util/SaffronProperties.java
Expand Up @@ -22,9 +22,8 @@
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;
Expand Down Expand Up @@ -109,16 +108,14 @@ private Helper() {}
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
}
Expand Down

0 comments on commit 534b09f

Please sign in to comment.