Skip to content

Commit

Permalink
Fixed the properties issue: matteobaccan#226
Browse files Browse the repository at this point in the history
  • Loading branch information
jonn-smith committed Apr 9, 2018
1 parent 4d73daa commit 20f085a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions owner/src/main/java/org/aeonbits/owner/ConfigURIFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,15 @@ URI newURI(String spec) throws URISyntaxException {
return null;
return url.toURI();
} else if (fixed.startsWith(FILE_PROTOCOL)) {
String path = fixSpacesToPercentTwenty(fixed);
return new URI(path);
// This check fixes the case where an environment variable has been
// specified for the path to the config file, but that environment
// variable is blank / undefined.
if ( fixed.equals(FILE_PROTOCOL) ) {
return new URI("");
} else {
String path = fixSpacesToPercentTwenty(fixed);
return new URI(path);
}
} else {
return new URI(fixed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ public void shouldReturnAnURI() throws URISyntaxException {
URI uri = h.newURI("classpath:test.properties");
assertNotNull(uri);
}

@Test
public void shouldReturnAUriWithEmptyFilePath() throws URISyntaxException {
ConfigURIFactory h = new ConfigURIFactory(this.getClass().getClassLoader(), new VariablesExpander(new Properties()));
URI uri = h.newURI("file:");
assertNotNull(uri);
}
}

0 comments on commit 20f085a

Please sign in to comment.