mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '4.1.x'
Closes gh-51521
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@ class NestedByteChannel implements SeekableByteChannel {
|
||||
while (dst.remaining() > 0) {
|
||||
int count = this.resources.getData().read(dst, this.position);
|
||||
if (count <= 0) {
|
||||
return (total != 0) ? 0 : count;
|
||||
return (total != 0) ? total : count;
|
||||
}
|
||||
total += count;
|
||||
this.position += count;
|
||||
|
||||
+9
-1
@@ -118,11 +118,19 @@ class NestedByteChannelTests {
|
||||
void readReadsBytesAndIncrementsPosition() throws IOException {
|
||||
ByteBuffer dst = ByteBuffer.allocate(10);
|
||||
assertThat(this.channel.position()).isZero();
|
||||
this.channel.read(dst);
|
||||
assertThat(this.channel.read(dst)).isEqualTo(10);
|
||||
assertThat(this.channel.position()).isEqualTo(10L);
|
||||
assertThat(dst.array()).isNotEqualTo(ByteBuffer.allocate(10).array());
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenDataCannotFillBufferReadReturnsBytesRead() throws IOException {
|
||||
ByteBuffer dst = ByteBuffer.allocate(8192);
|
||||
assertThat(this.channel.position()).isZero();
|
||||
assertThat(this.channel.read(dst)).isEqualTo(638);
|
||||
assertThat(this.channel.position()).isEqualTo(638L);
|
||||
}
|
||||
|
||||
@Test // gh-38592
|
||||
void readReadsAsManyBytesAsPossible() throws Exception {
|
||||
// ZipFileSystem checks that the number of bytes read matches an expected value
|
||||
|
||||
Reference in New Issue
Block a user