Replace try with try-with-resources
Update existing try/finally/close blocks to use "try with resources" See gh-9781
This commit is contained in:
committed by
Phillip Webb
parent
798fe5ed53
commit
d16af43664
@@ -186,8 +186,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
|
||||
|
||||
private long getNestedLibraryTime(File file) {
|
||||
try {
|
||||
JarFile jarFile = new JarFile(file);
|
||||
try {
|
||||
try (JarFile jarFile = new JarFile(file)) {
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
@@ -196,9 +195,6 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
jarFile.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Ignore and just use the source file timestamp
|
||||
@@ -381,13 +377,9 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
|
||||
private long size;
|
||||
|
||||
CrcAndSize(File file) throws IOException {
|
||||
FileInputStream inputStream = new FileInputStream(file);
|
||||
try {
|
||||
try (FileInputStream inputStream = new FileInputStream(file)) {
|
||||
load(inputStream);
|
||||
}
|
||||
finally {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
CrcAndSize(InputStream inputStream) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user