comment
stringlengths
1
45k
method_body
stringlengths
23
281k
target_code
stringlengths
0
5.16k
method_body_after
stringlengths
12
281k
context_before
stringlengths
8
543k
context_after
stringlengths
8
543k
I think this builder pattern needs consideration. For example, it would not be possible for person to create two HttpClient instances from this builder where the first one has a dispatcher and the second one does not, because they are unable to null it out. I would probably remove the constructor that takes the HttpCli...
public HttpClient build() { if (connectionPool != null) { this.httpClientBuilder = httpClientBuilder.connectionPool(connectionPool); } if (dispatcher != null) { this.httpClientBuilder = httpClientBuilder.dispatcher(dispatcher); } return new OkHttpAsyncHttpClient(this.httpClientBuilder.build()); }
}
public HttpClient build() { OkHttpClient.Builder httpClientBuilder = this.okHttpClient == null ? new OkHttpClient.Builder() : this.okHttpClient.newBuilder(); for (Interceptor interceptor : this.networkInterceptors) { httpClientBuilder = httpClientBuilder.addNetworkInterceptor(interceptor); } if (this.readTimeout != nul...
class OkHttpAsyncHttpClientBuilder { private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class); private okhttp3.OkHttpClient.Builder httpClientBuilder; private Dispatcher dispatcher; private ConnectionPool connectionPool; private final static long DEFAULT_READ_TIMEOUT_IN_SEC = 120; privat...
class OkHttpAsyncHttpClientBuilder { private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class); private final okhttp3.OkHttpClient okHttpClient; private final static Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120); private final static Duration DEFAULT_CONNECT_TIMEOUT = Duration.o...
Same here - empty array vs `Mono.empty()`. I am not sure if there's a difference between a `null` responseBody vs a non-null responsebody with empty byte array. Should we instead return `Mono.just(content)` where content could potentially be empty?
public Mono<byte[]> bodyAsByteArray() { if (this.responseBody() == null) { return Mono.empty(); } else { return Mono.using(() -> this.responseBody(), rb -> { try { byte[] content = rb.bytes(); return content.length == 0 ? Mono.empty() : Mono.just(content); } catch (IOException ioe) { throw Exceptions.propagate(ioe); } ...
return content.length == 0 ? Mono.empty() : Mono.just(content);
public Mono<byte[]> bodyAsByteArray() { if (this.responseBody() == null) { return Mono.empty(); } else { return Mono.using(() -> this.responseBody(), rb -> { try { byte[] content = rb.bytes(); return content.length == 0 ? Mono.empty() : Mono.just(content); } catch (IOException ioe) { throw Exceptions.propagate(ioe); } ...
class OkHttpResponse extends HttpResponse { private final okhttp3.Response inner; private final HttpHeaders headers; private final static int BYTE_BUFFER_CHUNK_SIZE = 1024; public OkHttpResponse(okhttp3.Response inner, HttpRequest request) { this.inner = inner; this.headers = fromOkHttpHeaders(this.inner.headers()); su...
class OkHttpResponse extends HttpResponse { private final okhttp3.Response inner; private final HttpHeaders headers; private final static int BYTE_BUFFER_CHUNK_SIZE = 1024; public OkHttpResponse(okhttp3.Response inner, HttpRequest request) { this.inner = inner; this.headers = fromOkHttpHeaders(this.inner.headers()); su...
@Jonathan, thanks for the feedback. Agree with you on reusing builder, I will update PR. On the other hand, I just learned that okhttp3.OkHttpClient instance itself has a `builder()` method. A builder returned by this method can be used to create new OkHttpClient instance with different configuration but it enables O...
public HttpClient build() { if (connectionPool != null) { this.httpClientBuilder = httpClientBuilder.connectionPool(connectionPool); } if (dispatcher != null) { this.httpClientBuilder = httpClientBuilder.dispatcher(dispatcher); } return new OkHttpAsyncHttpClient(this.httpClientBuilder.build()); }
}
public HttpClient build() { OkHttpClient.Builder httpClientBuilder = this.okHttpClient == null ? new OkHttpClient.Builder() : this.okHttpClient.newBuilder(); for (Interceptor interceptor : this.networkInterceptors) { httpClientBuilder = httpClientBuilder.addNetworkInterceptor(interceptor); } if (this.readTimeout != nul...
class OkHttpAsyncHttpClientBuilder { private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class); private okhttp3.OkHttpClient.Builder httpClientBuilder; private Dispatcher dispatcher; private ConnectionPool connectionPool; private final static long DEFAULT_READ_TIMEOUT_IN_SEC = 120; privat...
class OkHttpAsyncHttpClientBuilder { private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class); private final okhttp3.OkHttpClient okHttpClient; private final static Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120); private final static Duration DEFAULT_CONNECT_TIMEOUT = Duration.o...
Yes, we should support that
public HttpClient build() { if (connectionPool != null) { this.httpClientBuilder = httpClientBuilder.connectionPool(connectionPool); } if (dispatcher != null) { this.httpClientBuilder = httpClientBuilder.dispatcher(dispatcher); } return new OkHttpAsyncHttpClient(this.httpClientBuilder.build()); }
}
public HttpClient build() { OkHttpClient.Builder httpClientBuilder = this.okHttpClient == null ? new OkHttpClient.Builder() : this.okHttpClient.newBuilder(); for (Interceptor interceptor : this.networkInterceptors) { httpClientBuilder = httpClientBuilder.addNetworkInterceptor(interceptor); } if (this.readTimeout != nul...
class OkHttpAsyncHttpClientBuilder { private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class); private okhttp3.OkHttpClient.Builder httpClientBuilder; private Dispatcher dispatcher; private ConnectionPool connectionPool; private final static long DEFAULT_READ_TIMEOUT_IN_SEC = 120; privat...
class OkHttpAsyncHttpClientBuilder { private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class); private final okhttp3.OkHttpClient okHttpClient; private final static Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120); private final static Duration DEFAULT_CONNECT_TIMEOUT = Duration.o...
nit: "okHttpClient cannot be null" to make it easier for user to debug.
public OkHttpAsyncHttpClientBuilder(okhttp3.OkHttpClient okHttpClient) { this.okHttpClient = Objects.requireNonNull(okHttpClient, "okHttpClient == null"); }
this.okHttpClient = Objects.requireNonNull(okHttpClient, "okHttpClient == null");
public OkHttpAsyncHttpClientBuilder(okhttp3.OkHttpClient okHttpClient) { this.okHttpClient = Objects.requireNonNull(okHttpClient, "okHttpClient == null"); }
class OkHttpAsyncHttpClientBuilder { private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class); private final okhttp3.OkHttpClient okHttpClient; private final static Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120); private final static Duration DEFAULT_CONNECT_TIMEOUT = Duration.o...
class OkHttpAsyncHttpClientBuilder { private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class); private final okhttp3.OkHttpClient okHttpClient; private final static Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120); private final static Duration DEFAULT_CONNECT_TIMEOUT = Duration.o...