From 453433303d7024ea4b14bd5e99899db0af1b7ab6 Mon Sep 17 00:00:00 2001 From: XSoussou <43005332+XSoussou@users.noreply.github.com> Date: Thu, 3 Dec 2020 00:29:39 +0100 Subject: [PATCH] Fixed use of InputStream InputStream now closes after being used --- src/main/java/me/soussou/chopchop/Updater.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/soussou/chopchop/Updater.java b/src/main/java/me/soussou/chopchop/Updater.java index d7c7e89..3164fdd 100644 --- a/src/main/java/me/soussou/chopchop/Updater.java +++ b/src/main/java/me/soussou/chopchop/Updater.java @@ -21,6 +21,7 @@ package me.soussou.chopchop; import java.io.IOException; +import java.io.InputStream; import java.net.URL; import javax.xml.parsers.DocumentBuilderFactory; @@ -87,7 +88,9 @@ private void checkUpdates() throws IOException, SAXException, ParserConfiguratio private String getXmlVersion(URL url) throws IOException, SAXException, ParserConfigurationException { String version = ""; - Document pom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(url.openStream()); + + InputStream in = url.openStream(); + Document pom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in); NodeList elements = pom.getFirstChild().getChildNodes(); // Every element of the main node for(int i = 0; i < elements.getLength(); i++) { @@ -99,6 +102,8 @@ private String getXmlVersion(URL url) throws IOException, SAXException, ParserCo } } + in.close(); + return version; }