forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrameStreamProcessor.java
More file actions
53 lines (47 loc) · 1.37 KB
/
Copy pathFrameStreamProcessor.java
File metadata and controls
53 lines (47 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Created on 23.06.2015
*/
package com.github.dockerjava.core.async;
import java.io.IOException;
import java.io.InputStream;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.model.Frame;
import com.github.dockerjava.core.command.FrameReader;
/**
*
*
* @author Marcus Linke
*
*/
@SuppressWarnings("unused")
@Deprecated
public class FrameStreamProcessor implements ResponseStreamProcessor<Frame> {
@Override
public void processResponseStream(InputStream response, ResultCallback<Frame> resultCallback) {
resultCallback.onStart(response);
FrameReader frameReader = new FrameReader(response);
try {
Frame frame = frameReader.readFrame();
while (frame != null) {
try {
resultCallback.onNext(frame);
} catch (Exception e) {
resultCallback.onError(e);
} finally {
frame = frameReader.readFrame();
}
}
} catch (Throwable t) {
resultCallback.onError(t);
} finally {
try {
frameReader.close();
response.close();
} catch (IOException e) {
resultCallback.onError(e);
} finally {
resultCallback.onComplete();
}
}
}
}