Skip to content

Commit

Permalink
Use ConfigFactory.parseURL for reading jar located config.
Browse files Browse the repository at this point in the history
Use ConfigFactory.parseURL for reading jar located config.

Change-Id: I1a6603bc2973d71d07993ec352119639b11d5169
  • Loading branch information
mletenay committed Nov 30, 2023
1 parent 2f9b683 commit 248f480
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
import static java.util.concurrent.TimeUnit.NANOSECONDS;

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.Collections;
import java.util.Objects;
Expand Down Expand Up @@ -171,11 +169,11 @@ private static Config resolveConfig(URI uri, ClassLoader classloader) {
.withFallback(ConfigFactory.parseFile(new File(uri), options))
.withFallback(ConfigFactory.defaultReferenceUnresolved(classloader));
} else if ((uri.getScheme() != null) && uri.getScheme().equalsIgnoreCase("jar")) {
try (Reader reader = new InputStreamReader(uri.toURL().openStream())) {
try {
return ConfigFactory.defaultOverrides(classloader)
.withFallback(ConfigFactory.parseReader(reader, options))
.withFallback(ConfigFactory.parseURL(uri.toURL(), options))
.withFallback(ConfigFactory.defaultReferenceUnresolved(classloader));
} catch (IOException e) {
} catch (MalformedURLException e) {
throw new ConfigException.BadPath(uri.toString(), e.getMessage());
}
} else if (isResource(uri)) {
Expand Down

0 comments on commit 248f480

Please sign in to comment.