Skip to content

Commit ad3cdbf

Browse files
author
Paul Bakker
committed
Property loading falls back to default classloader when context classloader is not set correctly, e.g. in OSGi environments
1 parent 23a4967 commit ad3cdbf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigHelper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ private Properties parsePropertiesFile(String file) {
4747
try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(file)) {
4848
if (is != null) {
4949
props.load(is);
50+
} else {
51+
//Try loading from this class classloader instead, e.g. for OSGi environments.
52+
try(InputStream is2 = this.getClass().getClassLoader().getResourceAsStream(file)) {
53+
if (is2 != null) {
54+
props.load(is2);
55+
}
56+
}
5057
}
5158
} catch (IOException e) {
5259
throw new IllegalArgumentException("Can't parse file", e);

0 commit comments

Comments
 (0)