Skip to content

Commit

Permalink
Merge pull request #85 from avaje/feature/load-file
Browse files Browse the repository at this point in the history
Fix where load by props or command line args or indirection does not load FILE if RESOURCE found
  • Loading branch information
rbygrave authored Jul 11, 2023
2 parents 9c1c6d2 + 64e2190 commit a24dd98
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions avaje-config/src/main/java/io/avaje/config/InitialLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ private void loadViaSystemProperty() {

boolean loadWithExtensionCheck(String fileName) {
if (fileName.endsWith("yaml") || fileName.endsWith("yml")) {
return loadYamlPath(fileName, RESOURCE) || loadYamlPath(fileName, FILE);
return loadYamlPath(fileName, RESOURCE) | loadYamlPath(fileName, FILE);
} else if (fileName.endsWith("properties")) {
return loadProperties(fileName, RESOURCE) || loadProperties(fileName, FILE);
return loadProperties(fileName, RESOURCE) | loadProperties(fileName, FILE);
} else {
throw new IllegalArgumentException("Expecting only yaml or properties file but got [" + fileName + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void loadWithExtensionCheck() {
assertThat(properties.get("dummy.yaml.bar").value()).isEqualTo("baz");
assertThat(properties.get("dummy.yml.foo").value()).isEqualTo("bar");
assertThat(properties.get("dummy.properties.foo").value()).isEqualTo("bar");
assertThat(properties.get("dummy.properties.a").value()).isEqualTo("fromResource");
}

@Test
Expand Down
2 changes: 2 additions & 0 deletions avaje-config/src/test/resources/test-dummy.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dummy.properties.a=fromResource
dummy.properties.foo=bazz

0 comments on commit a24dd98

Please sign in to comment.