Skip to content

Commit a1e8bc7

Browse files
committed
Fix NegativeArraySizeException in awaitCompletion()
1 parent 19a3b3c commit a1e8bc7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/com/github/dockerjava/core/command/FrameReader.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.github.dockerjava.api.model.Frame;
88
import com.github.dockerjava.api.model.StreamType;
99

10+
import javax.annotation.CheckForNull;
11+
1012
/**
1113
* Breaks the input into frame. Similar to how a buffered reader would readLies.
1214
* <p/>
@@ -42,14 +44,16 @@ private static StreamType streamType(byte streamType) {
4244
/**
4345
* @return A frame, or null if no more frames.
4446
*/
47+
@CheckForNull
4548
public Frame readFrame() throws IOException {
4649

4750
if (rawStreamDetected) {
48-
4951
int read = inputStream.read(rawBuffer);
50-
52+
if (read == -1) {
53+
return null;
54+
}
55+
5156
return new Frame(StreamType.RAW, Arrays.copyOf(rawBuffer, read));
52-
5357
} else {
5458

5559
byte[] header = new byte[HEADER_SIZE];

0 commit comments

Comments
 (0)