Skip to content

Commit

Permalink
Merge pull request #40 from githuib/fix/resource-loading
Browse files Browse the repository at this point in the history
Fix/resource loading
  • Loading branch information
Huib Piguillet authored Dec 7, 2020
2 parents ec22712 + 2f50f65 commit 2ccb806
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,25 @@ Observable<Response<Void>> shareCollection(CollectionShareQuery collectionShareQ

### Using latest release

The most recent release is Bynder Java SDK 2.2.5.
The most recent release is Bynder Java SDK 2.2.6.

- API Docs: http://www.javadoc.io/doc/com.bynder/bynder-java-sdk/2.2.5
- API Docs: http://www.javadoc.io/doc/com.bynder/bynder-java-sdk/2.2.6

To add a dependency on the SDK using Maven, use the following:

```xml
<dependency>
<groupId>com.bynder</groupId>
<artifactId>bynder-java-sdk</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
</dependency>
```

To add a dependency using Gradle:

```
dependencies {
implementation 'com.bynder:bynder-java-sdk:2.2.5'
implementation 'com.bynder:bynder-java-sdk:2.2.6'
}
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>com.bynder</groupId>
<artifactId>bynder-java-sdk</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<packaging>jar</packaging>

<name>Bynder Java SDK</name>
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/bynder/sdk/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ public static Properties loadConfig(final String file)
throws IOException {
String filename = file + ".properties";
Properties config = new Properties();
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);

// Try to load the resource, using some fallbacks if it fails.
InputStream is = ClassLoader.getSystemResourceAsStream(filename);
if (is == null) {
is = Utils.class.getResourceAsStream(filename);
}
if (is == null) {
throw new IOException(filename + " could not be loaded.");
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
}

if (is == null) {
throw new IOException("Resource could not be loaded: " + filename);
}

config.load(is);
return config;
}
Expand Down

0 comments on commit 2ccb806

Please sign in to comment.