gharris1727 opened a new pull request, #12828: URL: https://github.com/apache/kafka/pull/12828
Currently, all RestClient methods are static, and require more complicated mocking mechanisms compared to an implementation which uses instance methods. Additionally, the current model creates a short-lived HttpClient for each request, rather than re-using a shared restClient. This change refactors all of the static methods into instance methods, and passes around a single initialized RestClient throughout the RestServer, ConnectorsResource, and DistributedHerder. The DistributedHerder is given the responsibility of closing the RestClient, similar to the sharedTopicAdmin pattern already established. This restClient can be more easily mocked by dependency injection rather than static mocking. Note: This has one potential change in semantics: Previously the HttpClient was initialized for SSL only when a remote `https://` url was provided, and otherwise just created an HTTP client without an ssl context. Now, the HttpClient is unconditionally created with an SSL context, even if the worker/other workers are configured to use HTTP listeners. The HttpClient javadoc indicates that an HttpClient which is configured with an ssl context can still make outbound requests to destinations over http. Thus this _should_ be a lateral change. During the implementation, I realized that the ConnectorsResource handles request forwarding to other nodes in a distributed cluster, and uses the RestClient to do so. In a standalone connect instance, this error handling is still present on the code-path, but because no standalone herder calls throw RequestTargetException, the error handling is not used. This appears in the refactor where in Connect Standalone, the RestClient is not used in the StandaloneHerder, but a RestClient is expected in the RestServer signature. This also appears in the refactor where in MirrorMaker, the RestClient is used in the DistributedHerder, but no RestServer is started which would handle those requests. Both of these situations are left as-is in this PR, and will need follow-ups to address. Signed-off-by: Greg Harris <greg.har...@aiven.io> ### Committer Checklist (excluded from commit message) - [ ] Verify design and implementation - [ ] Verify test coverage and CI build status - [ ] Verify documentation (including upgrade notes) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org