Skip to content

Commit

Permalink
Improve resource loading error handling and update Membrane configura…
Browse files Browse the repository at this point in the history
…tion (#1303)
  • Loading branch information
christiangoerdes authored Oct 9, 2024
1 parent f555bbb commit 1c32a0c
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,13 @@ public static String normalizeForId(String s) {
*/
public static InputStream getResourceAsStream(Object obj, String location) throws FileNotFoundException {
try {
URL url = obj.getClass().getResource(location);
if (url == null) {
LOG.warn("Resource {} not found", location);
throw new FileNotFoundException(location);
InputStream inputStream = obj.getClass().getResourceAsStream(new URI(location).getPath());

if (inputStream == null) {
throw new FileNotFoundException("Resource " + location + " not found");
}

// Uses wrapping in URI and FileInputStream because of:
// https://stackoverflow.com/questions/3263560/sysloader-getresource-problem-in-java
return new FileInputStream(new URI(url.toString()).getPath());
return inputStream;
} catch (URISyntaxException e) {
LOG.error(e.getMessage());
throw new RuntimeException(e);
Expand Down

0 comments on commit 1c32a0c

Please sign in to comment.