Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Use java.net.http.HttpClient instead of java.net.Http(s)URLConnection #217
Use java.net.http.HttpClient instead of java.net.Http(s)URLConnection #217
Changes from 18 commits
9ac214a
dc78962
903f141
1ca9814
765b439
988481f
0022ea3
0b3734d
8f8ac86
b12db60
a240d4c
5b122a0
ed1f6ac
e16a8e0
9b696b8
09be2f4
8d78d28
fdf2026
cc25583
3b6e169
85103c6
06f94fd
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
It's
java.lang.AutoCloseable
, so I think any recommendation should favour try-with-resources patterns, no?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.
I didn't change
CliBaseOptions
to implementAutoCloseable
. Usually, an options object shouldn't need to be closed. AddingCliBaseOptions.httpClient
felt a bit smelly, but it seemed like a price worth paying for being able to shareHttpClient
resources between commands. I couldn't find another way to achieve this without a major redesign.I documented calling
CliBaseOptions.httpClient.close()
for the edge cases where it might matter. That's also why I madehttpClient
public.Let me know if you want me to change
CliBaseOptions
to implementAutoCloseable
. Kotlin doesn't have try-with-resources, but it does have aCloseable.use
extension method.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.
I don't think
CliBaseOptions
implementingAutoCloseable
is the right call.We have a couple places where our builders accept
Closeable
, but we also try to avoid it whenever we can.Probably makes more sense to either accept the options on
HttpClient.Builder
directly, or acceptHttpClient.Builder
as an option as a whole.Same comment for the settings on
EvaluatorBuilder
.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.
Sorry I don't understand what you're proposing. Can you elaborate?
I considered passing
HttpClient
toCliCommand
, but thenCliBaseOptions.caCertificates
is no longer meaningful. (It'sHttpClient
that needs to be configured with the certificates.)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.
Sorry but I don't follow. Can you elaborate on what you're proposing?
One option I considered was to pass
HttpClient
to constructors ofCliCommand
subclasses. But this doesn't really work because it makesCliBaseOptions.caCertificates
irrelevant. (It's theHttpClient
that needs to be configured with certificates.)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.
Sorry, so, one suggestion is to add the builder methods on
HttpClient.Builder
toEvaluatorBuilder
:Another option is to accept an
HttpClient.Builder
as an option inEvaluatorBuilder
: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.
Currently we have
EvaluatorBuilder.setHttpClient()
. Your proposals might makeEvaluatorBuilder
more convenient to use if the default HTTP client isn't good enough. But I don't see how any of this relates to theCliBaseOptions.httpClient
discussion, and it's not clear to me if and what change you want there.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.
I'm proposing that both here, and in evaluator builder, we provide knobs for
addCertificates
, and possibly any other options onHttpClient.Builder
.After playing around with this locally, though, I don't feel strongly about this, and am okay with how you are doing it.
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 is true for the rest of the protected members of this class.
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.
I don't see why. It's true for
httpClient
because it delegates tocliOptions.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.
What I mean is that all of the protected members exist to be shared with other commands. It's a tad unncessary that this one is called out in particular as being shared.
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.
It’s the same instance that’s shared, which is especially relevant for HttpClient and not generally the case for other protected members.