diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java b/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java index cac77732ba28..cdf01eac4b4d 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/PropertyUserStore.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -218,7 +219,10 @@ protected void loadUsers() throws IOException throw new IllegalStateException("Config does not exist: " + config); Properties properties = new Properties(); - properties.load(config.getInputStream()); + try (InputStream inputStream = config.getInputStream()) + { + properties.load(inputStream); + } Set known = new HashSet<>(); diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java index 65007cc2c00b..a6e269109d30 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java @@ -70,7 +70,10 @@ public Modules(BaseHome basehome, StartArgs args) Path deprecatedPath = _baseHome.getPath("modules/deprecated.properties"); if (deprecatedPath != null && FS.exists(deprecatedPath)) { - _deprecated.load(new FileInputStream(deprecatedPath.toFile())); + try (FileInputStream inputStream = new FileInputStream(deprecatedPath.toFile())) + { + _deprecated.load(inputStream); + } } } catch (IOException e) diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index 4cd59c3a8795..a102b27df175 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -1823,7 +1823,12 @@ public static void main(final String... args) throws Exception properties.put(arg.substring(0, i), arg.substring(i + 1)); } else if (arg.toLowerCase(Locale.ENGLISH).endsWith(".properties")) - properties.load(Resource.newResource(arg).getInputStream()); + { + try (InputStream inputStream = Resource.newResource(arg).getInputStream()) + { + properties.load(inputStream); + } + } } // For all arguments, parse XMLs