Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit 0cd320c

Browse files
committed
chore
1 parent 4a4984c commit 0cd320c

File tree

3 files changed

+11
-64
lines changed

3 files changed

+11
-64
lines changed

engine/src/main/java/de/gesellix/docker/engine/AttachConfig.java

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ public Streams getStreams() {
2222
return streams;
2323
}
2424

25-
public Callbacks getCallbacks() {
26-
return callbacks;
27-
}
28-
2925
public Object onFailure(Exception e) {
3026
return callbacks.onFailure.apply(e);
3127
}
@@ -40,7 +36,7 @@ public void setOnFailure(Function<Exception, ?> onFailure) {
4036
*/
4137
@Deprecated
4238
public void setOnFailure(Closure<?> onFailure) {
43-
callbacks.onFailure = onFailure::call;
39+
setOnFailure(onFailure::call);
4440
}
4541

4642
public Object onResponse(Response r) {
@@ -57,7 +53,7 @@ public void setOnResponse(Function<Response, ?> onResponse) {
5753
*/
5854
@Deprecated
5955
public void setOnResponse(Closure<?> onResponse) {
60-
callbacks.onResponse = onResponse::call;
56+
setOnResponse(onResponse::call);
6157
}
6258

6359
public Object onSinkClosed(Response r) {
@@ -74,7 +70,7 @@ public void setOnSinkClosed(Function<Response, ?> onSinkClosed) {
7470
*/
7571
@Deprecated
7672
public void setOnSinkClosed(Closure<?> onSinkClosed) {
77-
callbacks.onSinkClosed = onSinkClosed::call;
73+
setOnSinkClosed(onSinkClosed::call);
7874
}
7975

8076
public Object onSinkWritten(Response r) {
@@ -91,7 +87,7 @@ public void setOnSinkWritten(Function<Response, ?> onSinkWritten) {
9187
*/
9288
@Deprecated
9389
public void setOnSinkWritten(Closure<?> onSinkWritten) {
94-
callbacks.onSinkWritten = onSinkWritten::call;
90+
setOnSinkWritten(onSinkWritten::call);
9591
}
9692

9793
public Object onSourceConsumed() {
@@ -108,10 +104,10 @@ public void setOnSourceConsumed(Supplier<?> onSourceConsumed) {
108104
*/
109105
@Deprecated
110106
public void setOnSourceConsumed(Closure<?> onSourceConsumed) {
111-
callbacks.onSourceConsumed = () -> {
107+
setOnSourceConsumed(() -> {
112108
onSourceConsumed.call();
113109
return null;
114-
};
110+
});
115111
}
116112

117113
public static class Streams {
@@ -158,45 +154,5 @@ public static class Callbacks {
158154
private Function<Response, ?> onSinkClosed = (Response r) -> null;
159155
private Function<Response, ?> onSinkWritten = (Response r) -> null;
160156
private Supplier<?> onSourceConsumed = () -> null;
161-
162-
public Function<Exception, ?> getOnFailure() {
163-
return onFailure;
164-
}
165-
166-
public void setOnFailure(Function<Exception, ?> onFailure) {
167-
this.onFailure = onFailure;
168-
}
169-
170-
public Function<Response, ?> getOnResponse() {
171-
return onResponse;
172-
}
173-
174-
public void setOnResponse(Function<Response, ?> onResponse) {
175-
this.onResponse = onResponse;
176-
}
177-
178-
public Function<Response, ?> getOnSinkClosed() {
179-
return onSinkClosed;
180-
}
181-
182-
public void setOnSinkClosed(Function<Response, ?> onSinkClosed) {
183-
this.onSinkClosed = onSinkClosed;
184-
}
185-
186-
public Function<Response, ?> getOnSinkWritten() {
187-
return onSinkWritten;
188-
}
189-
190-
public void setOnSinkWritten(Function<Response, ?> onSinkWritten) {
191-
this.onSinkWritten = onSinkWritten;
192-
}
193-
194-
public Supplier<?> getOnSourceConsumed() {
195-
return onSourceConsumed;
196-
}
197-
198-
public void setOnSourceConsumed(Supplier<?> onSourceConsumed) {
199-
this.onSourceConsumed = onSourceConsumed;
200-
}
201157
}
202158
}

engine/src/main/java/de/gesellix/docker/engine/ConnectionProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public Response intercept(Chain chain) throws IOException {
2424
// attention: this connection is *per request*, so sink and source might be overwritten
2525
Connection connection = chain.connection();
2626
if (connection == null) {
27-
throw new IllegalStateException("Connection is null. This one should only be used in a network interceptor, not in an application interceptor.");
27+
throw new IllegalStateException("Connection is null. This one should only be used as a network interceptor, not as application interceptor.");
2828
}
2929

3030
if (source != null) {

engine/src/main/java/de/gesellix/docker/engine/OkResponseCallback.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.TimerTask;
1616
import java.util.concurrent.CountDownLatch;
1717
import java.util.concurrent.TimeUnit;
18-
import java.util.function.Function;
1918
import java.util.function.Supplier;
2019

2120
public class OkResponseCallback implements Callback {
@@ -24,18 +23,10 @@ public class OkResponseCallback implements Callback {
2423

2524
private final ConnectionProvider connectionProvider;
2625
private final AttachConfig attachConfig;
27-
private final Function<Response, ?> onResponse;
28-
private final Function<Response, ?> onSinkClosed;
29-
private final Function<Response, ?> onSinkWritten;
30-
private final Supplier<?> onSourceConsumed;
3126

3227
public OkResponseCallback(ConnectionProvider connectionProvider, AttachConfig attachConfig) {
3328
this.connectionProvider = connectionProvider;
3429
this.attachConfig = attachConfig;
35-
this.onResponse = attachConfig.getCallbacks().getOnResponse();
36-
this.onSinkClosed = attachConfig.getCallbacks().getOnSinkClosed();
37-
this.onSinkWritten = attachConfig.getCallbacks().getOnSinkWritten();
38-
this.onSourceConsumed = attachConfig.getCallbacks().getOnSourceConsumed();
3930
}
4031

4132
@Override
@@ -62,12 +53,12 @@ public void onResponse(@NotNull final Call call, @NotNull final Response respons
6253
final BufferedSink bufferedSink = Okio.buffer(getConnectionProvider().getSink());
6354
bufferedSink.writeAll(stdinSource);
6455
bufferedSink.flush();
65-
onSinkWritten.apply(response);
56+
attachConfig.onSinkWritten(response);
6657
CountDownLatch done = new CountDownLatch(1);
6758
delayed(100, "writer", () -> {
6859
try {
6960
bufferedSink.close();
70-
onSinkClosed.apply(response);
61+
attachConfig.onSinkClosed(response);
7162
}
7263
catch (Exception e) {
7364
log.warn("error", e);
@@ -102,7 +93,7 @@ public void onResponse(@NotNull final Call call, @NotNull final Response respons
10293
bufferedStdout.flush();
10394
CountDownLatch done = new CountDownLatch(1);
10495
delayed(100, "reader", () -> {
105-
onSourceConsumed.get();
96+
attachConfig.onSourceConsumed();
10697
return null;
10798
}, done);
10899
done.await(5, TimeUnit.SECONDS);
@@ -125,7 +116,7 @@ public void onResponse(@NotNull final Call call, @NotNull final Response respons
125116
log.debug("no stdout.");
126117
}
127118

128-
onResponse.apply(response);
119+
attachConfig.onResponse(response);
129120
}
130121

131122
public static void delayed(long delay, String name, final Supplier<?> action, final CountDownLatch done) {

0 commit comments

Comments
 (0)