mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '3.4.x' into 3.5.x
Closes gh-47057
This commit is contained in:
+1
-6
@@ -706,6 +706,7 @@ public class NestedJarFile extends JarFile {
|
||||
JarEntryInputStream(ZipContent.Entry entry) throws IOException {
|
||||
this.uncompressedSize = entry.getUncompressedSize();
|
||||
this.content = entry.openContent();
|
||||
this.remaining = this.uncompressedSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -727,9 +728,6 @@ public class NestedJarFile extends JarFile {
|
||||
}
|
||||
result = count;
|
||||
}
|
||||
if (this.remaining == 0) {
|
||||
close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -741,9 +739,6 @@ public class NestedJarFile extends JarFile {
|
||||
this.pos += result;
|
||||
this.remaining -= result;
|
||||
}
|
||||
if (this.remaining == 0) {
|
||||
close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+50
@@ -431,6 +431,56 @@ class NestedJarFileTests {
|
||||
.hasMessage("Content mismatch when reading security info for entry 'content' (content check)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void readingToEndOfStoredContentCausesAvailableToReachZero() throws IOException {
|
||||
try (NestedJarFile jar = new NestedJarFile(this.file)) {
|
||||
JarEntry entry = jar.getEntry("nested.jar");
|
||||
try (InputStream input = jar.getInputStream(entry)) {
|
||||
assertThat(input.available()).isGreaterThan(0);
|
||||
StreamUtils.copyToByteArray(input);
|
||||
assertThat(input.available()).isZero();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void readingToEndOfDeflatedContentCausesAvailableToReachZero() throws IOException {
|
||||
try (NestedJarFile jar = new NestedJarFile(this.file)) {
|
||||
JarEntry entry = jar.getEntry("d/9.dat");
|
||||
try (InputStream input = jar.getInputStream(entry)) {
|
||||
assertThat(input.available()).isGreaterThan(0);
|
||||
StreamUtils.copyToByteArray(input);
|
||||
assertThat(input.available()).isZero();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void skippingBeyondEndOfStoredContentCausesAvailableToReachZero() throws IOException {
|
||||
try (NestedJarFile jar = new NestedJarFile(this.file)) {
|
||||
JarEntry entry = jar.getEntry("nested.jar");
|
||||
try (InputStream input = jar.getInputStream(entry)) {
|
||||
assertThat(input.available()).isGreaterThan(0);
|
||||
long skipped = input.skip(1000);
|
||||
assertThat(skipped).isLessThan(1000);
|
||||
assertThat(input.available()).isZero();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void skippingBeyondEndOfDeflatedContentCausesAvailableToReachZero() throws IOException {
|
||||
try (NestedJarFile jar = new NestedJarFile(this.file)) {
|
||||
JarEntry entry = jar.getEntry("d/9.dat");
|
||||
try (InputStream input = jar.getInputStream(entry)) {
|
||||
assertThat(input.available()).isGreaterThan(0);
|
||||
long skipped = input.skip(1000);
|
||||
assertThat(skipped).isLessThan(1000);
|
||||
assertThat(input.available()).isZero();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> collectComments(JarFile jarFile) throws IOException {
|
||||
try (jarFile) {
|
||||
List<String> comments = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user