Convert ClassLoader.getSystemResource* calls to class.getResource* variant for OSGi, etc. safety

This commit is contained in:
catbref 2019-05-30 11:23:53 +01:00
parent 94fceeb34a
commit cd5f9a1e6c
2 changed files with 3 additions and 3 deletions

View File

@ -80,7 +80,7 @@ public class Controller extends Thread {
private Controller() {
Properties properties = new Properties();
try (InputStream in = ClassLoader.getSystemResourceAsStream("build.properties")) {
try (InputStream in = this.getClass().getResourceAsStream("/build.properties")) {
properties.load(in);
} catch (IOException e) {
throw new RuntimeException("Can't read build.properties resource", e);

View File

@ -42,9 +42,9 @@ public class Gui {
}
protected static BufferedImage loadImage(String resourceName) {
try (InputStream in = ClassLoader.getSystemResourceAsStream("images/" + resourceName)) {
try (InputStream in = Gui.class.getResourceAsStream("/images/" + resourceName)) {
return ImageIO.read(in);
} catch (IOException e) {
} catch (IllegalArgumentException | IOException e) {
LOGGER.warn(String.format("Couldn't locate image resource \"images/%s\"", resourceName));
return null;
}