Skip to content

Commit

Permalink
Adding a few try-with-ressources in Tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacchella committed Dec 14, 2018
1 parent 4d4cb4a commit 5883615
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions jrds-core/src/test/java/jrds/Tools.java
Expand Up @@ -91,18 +91,20 @@ public void warning(SAXParseException exception) throws SAXException {
}

static public JrdsDocument parseRessource(String name) throws Exception {
InputStream is = Tools.class.getClassLoader().getResourceAsStream(name);
try (InputStream is = Tools.class.getClassLoader().getResourceAsStream(name)) {
return parseRessource(is);
}
}

static public JrdsDocument parseRessource(InputStream is) throws Exception {
return new JrdsDocument(Tools.dbuilder.parse(is));
}

static public JrdsDocument parseString(String s) throws Exception {
InputStream is = new ByteArrayInputStream(s.getBytes());
try (InputStream is = new ByteArrayInputStream(s.getBytes())) {
return Tools.parseRessource(is);
}
}

static public void setLevel(Logger logger, Level level, String... allLoggers) {
Appender app = Logger.getLogger("jrds").getAppender(JrdsLoggerConfiguration.APPENDERNAME);
Expand Down

0 comments on commit 5883615

Please sign in to comment.