parent
909cacec42
commit
c0b4b5787f
|
@ -249,8 +249,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
|||
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
InputStream is = encodedResource.getResource().getInputStream();
|
||||
try {
|
||||
try (InputStream is = encodedResource.getResource().getInputStream()) {
|
||||
if (encodedResource.getEncoding() != null) {
|
||||
getPropertiesPersister().load(props, new InputStreamReader(is, encodedResource.getEncoding()));
|
||||
}
|
||||
|
@ -258,9 +257,6 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
|||
getPropertiesPersister().load(props, is);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
return registerBeanDefinitions(props, prefix, encodedResource.getResource().getDescription());
|
||||
}
|
||||
catch (IOException ex) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -60,9 +60,7 @@ public class MediaTypeFactory {
|
|||
* @return a multi-value map, mapping media types to file extensions.
|
||||
*/
|
||||
private static MultiValueMap<String, MediaType> parseMimeTypes() {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME);
|
||||
try (InputStream is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME)) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII));
|
||||
MultiValueMap<String, MediaType> result = new LinkedMultiValueMap<>();
|
||||
String line;
|
||||
|
@ -82,15 +80,6 @@ public class MediaTypeFactory {
|
|||
catch (IOException ex) {
|
||||
throw new IllegalStateException("Could not load '" + MIME_TYPES_FILE_NAME + "'", ex);
|
||||
}
|
||||
finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
}
|
||||
catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -158,15 +158,16 @@ public class HessianExporter extends RemoteExporter implements InitializingBean
|
|||
OutputStream osToUse = outputStream;
|
||||
|
||||
if (this.debugLogger != null && this.debugLogger.isDebugEnabled()) {
|
||||
PrintWriter debugWriter = new PrintWriter(new CommonsLogWriter(this.debugLogger));
|
||||
@SuppressWarnings("resource")
|
||||
HessianDebugInputStream dis = new HessianDebugInputStream(inputStream, debugWriter);
|
||||
@SuppressWarnings("resource")
|
||||
HessianDebugOutputStream dos = new HessianDebugOutputStream(outputStream, debugWriter);
|
||||
dis.startTop2();
|
||||
dos.startTop2();
|
||||
isToUse = dis;
|
||||
osToUse = dos;
|
||||
try (PrintWriter debugWriter = new PrintWriter(new CommonsLogWriter(this.debugLogger))){
|
||||
@SuppressWarnings("resource")
|
||||
HessianDebugInputStream dis = new HessianDebugInputStream(inputStream, debugWriter);
|
||||
@SuppressWarnings("resource")
|
||||
HessianDebugOutputStream dos = new HessianDebugOutputStream(outputStream, debugWriter);
|
||||
dis.startTop2();
|
||||
dos.startTop2();
|
||||
isToUse = dis;
|
||||
osToUse = dos;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isToUse.markSupported()) {
|
||||
|
|
Loading…
Reference in New Issue