File tree 2 files changed +11
-1
lines changed
main/java/org/springframework/util
test/java/org/springframework/util 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -367,7 +367,7 @@ public int read() {
367
367
else {
368
368
if (this .nextIndexInCurrentBuffer < this .currentBufferLength ) {
369
369
this .totalBytesRead ++;
370
- return this .currentBuffer [this .nextIndexInCurrentBuffer ++];
370
+ return this .currentBuffer [this .nextIndexInCurrentBuffer ++] & 0xFF ;
371
371
}
372
372
else {
373
373
if (this .buffersIterator .hasNext ()) {
Original file line number Diff line number Diff line change 16
16
17
17
package org .springframework .util ;
18
18
19
+ import java .io .ByteArrayInputStream ;
19
20
import java .io .ByteArrayOutputStream ;
20
21
import java .io .IOException ;
21
22
import java .io .InputStream ;
@@ -137,6 +138,15 @@ public void getInputStreamRead() throws Exception {
137
138
assertEquals (inputStream .read (), this .helloBytes [3 ]);
138
139
}
139
140
141
+ @ Test
142
+ public void getInputStreamReadBytePromotion () throws Exception {
143
+ byte [] bytes = new byte [] { -1 };
144
+ this .os .write (bytes );
145
+ InputStream inputStream = this .os .getInputStream ();
146
+ ByteArrayInputStream bais = new ByteArrayInputStream (bytes );
147
+ assertEquals (bais .read (), inputStream .read ());
148
+ }
149
+
140
150
@ Test
141
151
public void getInputStreamReadAll () throws Exception {
142
152
this .os .write (this .helloBytes );
You can’t perform that action at this time.
0 commit comments