Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix Netty leaks #1397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,20 @@ public void delete() {

HttpRequestProvider requestProvider = httpDeleteRequestProvider();

ResponseCallback<Void> callback = new ResponseCallback<>();
try (ResponseCallback<Void> callback = new ResponseCallback<>()) {

HttpResponseHandler responseHandler = new HttpResponseHandler(requestProvider, callback);
HttpResponseHandler responseHandler = new HttpResponseHandler(requestProvider, callback);

Channel channel = getChannel();
Channel channel = getChannel();

channel.pipeline().addLast(responseHandler);
channel.pipeline().addLast(responseHandler);

sendRequest(requestProvider, channel);
sendRequest(requestProvider, channel);

callback.awaitResult();
callback.awaitResult();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public void get(ResultCallback<Frame> resultCallback) {
Expand All @@ -141,12 +144,13 @@ public void get(ResultCallback<Frame> resultCallback) {
}

public <T> T get(TypeReference<T> typeReference) {
try (ResponseCallback<T> callback = new ResponseCallback<>()) {
get(typeReference, callback);

ResponseCallback<T> callback = new ResponseCallback<>();

get(typeReference, callback);

return callback.awaitResult();
return callback.awaitResult();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public <T> void get(TypeReference<T> typeReference, ResultCallback<T> resultCallback) {
Expand Down Expand Up @@ -267,12 +271,13 @@ public void run() {
}

public <T> T post(final Object entity, TypeReference<T> typeReference) {
try (ResponseCallback<T> callback = new ResponseCallback<>()) {
post(entity, typeReference, callback);

ResponseCallback<T> callback = new ResponseCallback<>();

post(entity, typeReference, callback);

return callback.awaitResult();
return callback.awaitResult();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public <T> void post(final Object entity, TypeReference<T> typeReference, final ResultCallback<T> resultCallback) {
Expand Down Expand Up @@ -372,12 +377,13 @@ private void setDefaultHeaders(HttpRequest request) {
}

public <T> T post(TypeReference<T> typeReference, InputStream body) {
try (ResponseCallback<T> callback = new ResponseCallback<>()) {
post(typeReference, callback, body);

ResponseCallback<T> callback = new ResponseCallback<>();

post(typeReference, callback, body);

return callback.awaitResult();
return callback.awaitResult();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public <T> void post(TypeReference<T> typeReference, ResultCallback<T> resultCallback, InputStream body) {
Expand Down Expand Up @@ -464,28 +470,30 @@ public void put(InputStream body, com.github.dockerjava.core.MediaType mediaType

Channel channel = getChannel();

ResponseCallback<Void> resultCallback = new ResponseCallback<>();
try (ResponseCallback<Void> resultCallback = new ResponseCallback<>()) {
HttpResponseHandler responseHandler = new HttpResponseHandler(requestProvider, resultCallback);

HttpResponseHandler responseHandler = new HttpResponseHandler(requestProvider, resultCallback);
channel.pipeline().addLast(new ChunkedWriteHandler());
channel.pipeline().addLast(responseHandler);

channel.pipeline().addLast(new ChunkedWriteHandler());
channel.pipeline().addLast(responseHandler);

HttpRequest request = requestProvider.getHttpRequest(resource);
HttpRequest request = requestProvider.getHttpRequest(resource);

// don't accept FullHttpRequest here
if (request instanceof FullHttpRequest) {
throw new DockerClientException("fatal: request is instance of FullHttpRequest");
}
// don't accept FullHttpRequest here
if (request instanceof FullHttpRequest) {
throw new DockerClientException("fatal: request is instance of FullHttpRequest");
}

request.headers().set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
request.headers().remove(HttpHeaderNames.CONTENT_LENGTH);
request.headers().set(HttpHeaderNames.CONTENT_TYPE, mediaType.getMediaType());
request.headers().set(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
request.headers().remove(HttpHeaderNames.CONTENT_LENGTH);
request.headers().set(HttpHeaderNames.CONTENT_TYPE, mediaType.getMediaType());

channel.write(request);
channel.write(new ChunkedStream(new BufferedInputStream(body, 1024 * 1024)));
channel.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
channel.write(request);
channel.write(new ChunkedStream(new BufferedInputStream(body, 1024 * 1024)));
channel.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);

resultCallback.awaitResult();
resultCallback.awaitResult();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.