Skip to content

Commit b819481

Browse files
wsargentslandelle
authored andcommitted
Use package relative resources (AsyncHttpClient#1538), close AsyncHttpClient#1536
1 parent ed5552b commit b819481

File tree

6 files changed

+3
-27
lines changed

6 files changed

+3
-27
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public final class AsyncHttpClientConfigDefaults {
7373
public static final String AHC_VERSION;
7474

7575
static {
76-
try (InputStream is = AsyncHttpClientConfigDefaults.class.getResourceAsStream("/ahc-version.properties")) {
76+
try (InputStream is = AsyncHttpClientConfigDefaults.class.getResourceAsStream("ahc-version.properties")) {
7777
Properties prop = new Properties();
7878
prop.load(is);
7979
AHC_VERSION = prop.getProperty("ahc.version", "UNKNOWN");

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import java.io.IOException;
44
import java.io.InputStream;
5-
import java.util.ArrayList;
6-
import java.util.List;
75
import java.util.Properties;
86
import java.util.concurrent.ConcurrentHashMap;
97

@@ -45,29 +43,7 @@ public void reload() {
4543
private Properties parsePropertiesFile(String file, boolean required) {
4644
Properties props = new Properties();
4745

48-
List<ClassLoader> cls = new ArrayList<>();
49-
50-
ClassLoader cl = Thread.currentThread().getContextClassLoader();
51-
if (cl != null) {
52-
cls.add(cl);
53-
}
54-
cl = getClass().getClassLoader();
55-
if (cl != null) {
56-
cls.add(cl);
57-
}
58-
cl = ClassLoader.getSystemClassLoader();
59-
if (cl != null) {
60-
cls.add(cl);
61-
}
62-
63-
InputStream is = null;
64-
for (ClassLoader classLoader : cls) {
65-
is = classLoader.getResourceAsStream(file);
66-
if (is != null) {
67-
break;
68-
}
69-
}
70-
46+
InputStream is = getClass().getResourceAsStream(file);
7147
if (is != null) {
7248
try {
7349
props.load(is);

client/src/main/java/org/asynchttpclient/request/body/multipart/FileLikePart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public abstract class FileLikePart extends PartBase {
2727
private static final MimetypesFileTypeMap MIME_TYPES_FILE_TYPE_MAP;
2828

2929
static {
30-
try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("ahc-mime.types")) {
30+
try (InputStream is = FileLikePart.class.getResourceAsStream("ahc-mime.types")) {
3131
MIME_TYPES_FILE_TYPE_MAP = new MimetypesFileTypeMap(is);
3232
} catch (IOException e) {
3333
throw new ExceptionInInitializerError(e);

0 commit comments

Comments
 (0)