Make sure resources get closed

This commit is contained in:
Matthias Kurz 2018-07-05 16:16:20 +02:00
parent 15345fc0e4
commit 11962f83d7
No known key found for this signature in database
GPG Key ID: 0B4AAA92F1117EF5
1 changed files with 4 additions and 1 deletions

View File

@ -45,12 +45,14 @@ public class SitemapValidator {
if (stream == null) throw new RuntimeException("BUG Couldn't load sitemap.xsd");
StreamSource source = new StreamSource(stream);
sitemapSchema = factory.newSchema(source);
stream.close();
stream = SitemapValidator.class.getResourceAsStream("siteindex.xsd");
if (stream == null) throw new RuntimeException("BUG Couldn't load siteindex.xsd");
source = new StreamSource(stream);
sitemapIndexSchema = factory.newSchema(source);
} catch (SAXException e) {
stream.close();
} catch (Exception e) {
throw new RuntimeException("BUG", e);
}
}
@ -73,6 +75,7 @@ public class SitemapValidator {
FileReader reader = new FileReader(sitemap);
SAXSource source = new SAXSource(new InputSource(reader));
validator.validate(source);
reader.close();
} catch (IOException e) {
throw new RuntimeException(e);
}