Change this "try" to a try-with-resources
Closes gh-1671
This commit is contained in:
committed by
Stephane Nicoll
parent
909cacec42
commit
c0b4b5787f
@@ -461,9 +461,8 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
|
||||
* @throws IOException if properties loading failed
|
||||
*/
|
||||
protected Properties loadProperties(Resource resource, String filename) throws IOException {
|
||||
InputStream is = resource.getInputStream();
|
||||
Properties props = newProperties();
|
||||
try {
|
||||
try (InputStream is = resource.getInputStream()) {
|
||||
String resourceFilename = resource.getFilename();
|
||||
if (resourceFilename != null && resourceFilename.endsWith(XML_SUFFIX)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -494,9 +493,6 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
|
||||
}
|
||||
return props;
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
@@ -370,11 +369,8 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou
|
||||
if (encoding == null) {
|
||||
encoding = "ISO-8859-1";
|
||||
}
|
||||
try {
|
||||
return loadBundle(new InputStreamReader(stream, encoding));
|
||||
}
|
||||
finally {
|
||||
stream.close();
|
||||
try (InputStreamReader bundleReader = new InputStreamReader(stream, encoding)) {
|
||||
return loadBundle(bundleReader);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user