Commit 244b5391 authored by Andy Wilkinson's avatar Andy Wilkinson

Fix file handle leak in JarFileArchiveTests

Closes gh-19655
parent 9baf0e8f
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -174,11 +174,12 @@ class JarFileArchiveTests { ...@@ -174,11 +174,12 @@ class JarFileArchiveTests {
} }
try (JarFile jarFile = new JarFile(file)) { try (JarFile jarFile = new JarFile(file)) {
ZipEntry nestedEntry = jarFile.getEntry("nested/zip64.jar"); ZipEntry nestedEntry = jarFile.getEntry("nested/zip64.jar");
JarFile nestedJarFile = jarFile.getNestedJarFile(nestedEntry); try (JarFile nestedJarFile = jarFile.getNestedJarFile(nestedEntry)) {
Iterator<JarEntry> iterator = nestedJarFile.iterator(); Iterator<JarEntry> iterator = nestedJarFile.iterator();
for (int i = 0; i < 65537; i++) { for (int i = 0; i < 65537; i++) {
assertThat(iterator.hasNext()).as(i + "nth file is present").isTrue(); assertThat(iterator.hasNext()).as(i + "nth file is present").isTrue();
iterator.next(); iterator.next();
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment