Change this "try" to a try-with-resources
Closes gh-1671
This commit is contained in:
committed by
Stephane Nicoll
parent
909cacec42
commit
c0b4b5787f
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user