diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java index 0916b6064f5..96cc8a5820f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/InspectedContent.java @@ -139,7 +139,7 @@ public class InspectedContent implements Content { private File tempFile; - private final byte[] singleByteBuffer = new byte[0]; + private final byte[] singleByteBuffer = new byte[1]; private InspectingOutputStream(Inspector[] inspectors) { this.inspectors = inspectors; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/InspectedContentTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/InspectedContentTests.java index 097933f0817..35d5b933198 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/InspectedContentTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/InspectedContentTests.java @@ -90,6 +90,13 @@ class InspectedContentTests { 0xa3, 0xbf, 0x4f, 0x1b, 0x2b, 0x0b, 0x82, 0x2c, 0xd1, 0x5d, 0x6c, 0x15, 0xb0, 0xf0, 0x0a, 0x08); } + @Test + void ofWritingSingleByteShouldWork() throws Exception { + InspectedContent content = InspectedContent.of((outputStream) -> outputStream.write('A')); + assertThat(content.size()).isEqualTo(1); + assertThat(readBytes(content)).containsExactly('A'); + } + private byte[] readBytes(InspectedContent content) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); content.writeTo(outputStream);