Use try-with-resource to close resources
Closes gh-24807
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -182,8 +182,7 @@ public abstract class PropertiesLoaderUtils {
|
||||
URL url = urls.nextElement();
|
||||
URLConnection con = url.openConnection();
|
||||
ResourceUtils.useCachesIfNecessary(con);
|
||||
InputStream is = con.getInputStream();
|
||||
try {
|
||||
try (InputStream is = con.getInputStream()) {
|
||||
if (resourceName.endsWith(XML_FILE_EXTENSION)) {
|
||||
props.loadFromXML(is);
|
||||
}
|
||||
@@ -191,9 +190,6 @@ public abstract class PropertiesLoaderUtils {
|
||||
props.load(is);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user