-
Notifications
You must be signed in to change notification settings - Fork 191
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
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
@@ -257,6 +207,8 @@ public <RequestT, ResponseT, ErrorT> ResponseT performRequest( | |||
} catch (InterruptedException e) { | |||
throw new IOException("HttpRequest was interrupted", e); | |||
} | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This else
is probably redundant at this point, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor comment: Should we call this syncHttpClient
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as well syncHttpClient
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed.
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
SdkAutoCloseable
and implements theexecute
method 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.