fix resource leak (#7361)

Fix resource leaks
This commit is contained in:
lujiefsi 2022-01-10 03:56:22 -06:00 committed by GitHub
parent 1984d2de11
commit ff10c26332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -16,6 +16,7 @@ package org.eclipse.jetty.security;
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 @@ public class PropertyUserStore extends UserStore implements PathWatcher.Listener
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<String> known = new HashSet<>();

View File

@ -70,7 +70,10 @@ public class Modules implements Iterable<Module>
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)

View File

@ -1823,7 +1823,12 @@ public class XmlConfiguration
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