Browse Source

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

pull/67/head
catbref 5 years ago
parent
commit
cd5f9a1e6c
  1. 2
      src/main/java/org/qora/controller/Controller.java
  2. 4
      src/main/java/org/qora/gui/Gui.java

2
src/main/java/org/qora/controller/Controller.java

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

4
src/main/java/org/qora/gui/Gui.java

@ -42,9 +42,9 @@ public class Gui {
} }
protected static BufferedImage loadImage(String resourceName) { 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); return ImageIO.read(in);
} catch (IOException e) { } catch (IllegalArgumentException | IOException e) {
LOGGER.warn(String.format("Couldn't locate image resource \"images/%s\"", resourceName)); LOGGER.warn(String.format("Couldn't locate image resource \"images/%s\"", resourceName));
return null; return null;
} }

Loading…
Cancel
Save