Refactor two-client usage.#333
Conversation
java-client/src/main/java/org/opensearch/client/transport/aws/AwsSdk2Transport.java
Outdated
Show resolved
Hide resolved
java-client/src/main/java/org/opensearch/client/transport/aws/AwsSdk2Transport.java
Outdated
Show resolved
Hide resolved
|
It looks better @dblock comparing to 2 clients |
a6d4617 to
948399d
Compare
|
Made some updates, thanks @reta. Seeing intermittent |
|
@dblock the |
Signed-off-by: dblock <dblock@amazon.com>
948399d to
ac5cc66
Compare
Signed-off-by: dblock <dblock@amazon.com>
It's just a double-close on cleanup, fixed. |
java-client/src/main/java/org/opensearch/client/transport/aws/AwsSdk2Transport.java
Show resolved
Hide resolved
Signed-off-by: dblock <dblock@amazon.com>
170d383 to
a4988a6
Compare
| } catch (InterruptedException e) { | ||
| throw new IOException("HttpRequest was interrupted", e); | ||
| } | ||
| } else { |
There was a problem hiding this comment.
This else is probably redundant at this point, right?
There was a problem hiding this comment.
Java is not smart enough to evaluate all paths and conclude that this code can never be reached. If you remove it, there will be an error that the method must return a value, and I don't want a catch all else where we make an assumption on the type of connection instance.
|
@saratvemulapalli care to do 2PR? |
| */ | ||
| public AwsSdk2Transport( | ||
| @Nonnull SdkAsyncHttpClient asyncHttpClient, | ||
| @CheckForNull SdkHttpClient httpClient, |
There was a problem hiding this comment.
Just a minor comment: Should we call this syncHttpClient?
| @Nonnull Region signingRegion, | ||
| @CheckForNull AwsSdk2TransportOptions options) { | ||
| this(httpClient, asyncHttpClient, host, "es", signingRegion, options); | ||
| this((SdkAutoCloseable) httpClient, host, signingServiceName, signingRegion, options); |
There was a problem hiding this comment.
Same here as well syncHttpClient?
Signed-off-by: dblock <dblock@amazon.com>
93631d7 to
baa0428
Compare
I am late to the party! |
|
@dblock Should we backport this to 2.x? |
* Refactor two-client usage. Signed-off-by: dblock <dblock@amazon.com> * Avoid double-closing the client on cleanup. Signed-off-by: dblock <dblock@amazon.com> * Refactor constructors to take sync/async explicitly. Signed-off-by: dblock <dblock@amazon.com> * Corrected comments and cleaned up variable naming. Signed-off-by: dblock <dblock@amazon.com> Signed-off-by: dblock <dblock@amazon.com> (cherry picked from commit a0ca15c) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Refactor two-client usage. * Avoid double-closing the client on cleanup. * Refactor constructors to take sync/async explicitly. * Corrected comments and cleaned up variable naming. (cherry picked from commit a0ca15c) Signed-off-by: dblock <dblock@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: dblock dblock@amazon.com
Description
I really dislike that this code uses two different clients like it does. Is this better? Should I go further and add a class that wraps either of
SdkAutoCloseableand implements theexecutemethod so we don't have to check the type other than when creating the wrapper?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.