Skip to content

Commit

Permalink
Merge pull request #1969 from mimkorn/1968
Browse files Browse the repository at this point in the history
Add fallback to Thread Context Class Loader for resource loading
  • Loading branch information
gracekarina authored Sep 20, 2023
2 parents 08a7630 + 77d1241 commit 03238c7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static String loadFileFromClasspath(String location) {
String file = FilenameUtils.separatorsToUnix(location);

InputStream inputStream = ClasspathHelper.class.getResourceAsStream(file);

if(inputStream == null) {
inputStream = ClasspathHelper.class.getClassLoader().getResourceAsStream(file);
}
Expand All @@ -22,6 +22,10 @@ public static String loadFileFromClasspath(String location) {
inputStream = ClassLoader.getSystemResourceAsStream(file);
}

if(inputStream == null) {
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
}

if(inputStream != null) {
try {
return IOUtils.toString(inputStream);
Expand Down

0 comments on commit 03238c7

Please sign in to comment.