Use try-with-resources language construct where feasible
Closes gh-2063 Co-authored-by: igor-suhorukov <igor.suhorukov@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -62,13 +62,9 @@ public final class SpringProperties {
|
||||
ClassLoader.getSystemResource(PROPERTIES_RESOURCE_LOCATION));
|
||||
if (url != null) {
|
||||
logger.debug("Found 'spring.properties' file in local classpath");
|
||||
InputStream is = url.openStream();
|
||||
try {
|
||||
try (InputStream is = url.openStream()) {
|
||||
localProperties.load(is);
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -90,8 +90,7 @@ public class XmlValidationModeDetector {
|
||||
*/
|
||||
public int detectValidationMode(InputStream inputStream) throws IOException {
|
||||
// Peek into the file to look for DOCTYPE.
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
try {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
boolean isDtdValidated = false;
|
||||
String content;
|
||||
while ((content = reader.readLine()) != null) {
|
||||
@@ -115,9 +114,6 @@ public class XmlValidationModeDetector {
|
||||
// Leave the decision up to the caller.
|
||||
return VALIDATION_AUTO;
|
||||
}
|
||||
finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user