SPR-17492: FastByteArrayOutputStream.read byte-to-int conversion

This commit is contained in:
Vojtech Janota
2018-11-13 22:04:46 +01:00
committed by Juergen Hoeller
parent 88cb126511
commit 12f168290d
2 changed files with 11 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -137,6 +138,15 @@ public class FastByteArrayOutputStreamTests {
assertEquals(inputStream.read(), this.helloBytes[3]);
}
@Test
public void getInputStreamReadBytePromotion() throws Exception {
byte[] bytes = new byte[] { -1 };
this.os.write(bytes);
InputStream inputStream = this.os.getInputStream();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
assertEquals(bais.read(), inputStream.read());
}
@Test
public void getInputStreamReadAll() throws Exception {
this.os.write(this.helloBytes);