Skip to content

BREAKING: Improves the Outcall.#580

Merged
andyHa merged 13 commits intodevelopfrom
feature/aha/outcall-cleanup
Nov 20, 2025
Merged

BREAKING: Improves the Outcall.#580
andyHa merged 13 commits intodevelopfrom
feature/aha/outcall-cleanup

Conversation

@andyHa
Copy link
Member

@andyHa andyHa commented Nov 19, 2025

Description

Provides some cleanup and refactoring for the Outcall. The breaking change is that it
as been moved from the xml package to the commons package.

Additionally, some methods have been deprecated. Most notably, for all methods which customized the HttpClient.Builder via modifyClient (directly or indirectly) we
now ask for a clientSelector. If a client has already been built for a given clientSelector,
we re-use the existing client and thus support keepalive and connection pooling. This
should drastically speed up repeated requests to the same host.

If no re-use is intended, null can be used as selector.

Additional Notes

  • This PR fixes or works on following ticket(s): SIRI-
  • This PR is related to PR:

Checklist

  • Code change has been tested and works locally
  • Code was formatted via IntelliJ and follows SonarLint & best practices
  • Patch Tasks: Is local execution of Patch Tasks necessary? If so, please also mark the PR with the tag.

Due to historic reasons, this class was placed in the xml package.
As it evolved into a full block generic HTTP client, we moved it to
the commons package.
By trying to re-use existing HttpClients, we can utilize the
internal connection pool and thus drastically speed up repeated
requests against the same host.

As a client might be customized through its builder, we now ask for
a clientSelector to distinguish these.

If null is used as clientSelector, no re-use will happen.
@andyHa andyHa added 💣 BREAKING CHANGE Contains non-backwards compatible changes to public methods or changes the behavior of existing code 🧬 Enhancement Contains new features labels Nov 19, 2025
* @return the underlying {@link HttpClient.Builder}
*/
public HttpClient.Builder modifyClient() {
return modifyClient(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vielleicht wäre es eleganter den clientSelector einmalig im Constructor zu setzen anstatt ihn immer mitschleifen zu müssen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector is only required if the builder is customized. For many many cases, the single central http client can be re-used. Therefore, the constructor was left untouched and the selector has been moved here.

The few cases where we customize the builder are always either: modify timeout, provide a cookie manager or accept self-signed certificates.

Especially with cookie managers we want to enforce a decision if the resulting client can be cached or not and therefore require a parameter here.

* @return the underlying {@link HttpClient.Builder}
* @deprecated Use {@link #modifyClient(String)}
*/
@Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the rationale behind deprecating the methods without the clientSelector? Often we only need one request, and with simple ones like

Outcall call = new Outcall(URI.create(SERVER_URL));
String response = call.postData(params, StandardCharsets.ISO_8859_1).getData();

no clientSelector needs to be specified. If however we want to add a cookie manager or want to trust self-signed certificates, suddenly we need to specify null. Either it should be always mandatory, so maybe we should add the clientSelector to the constructor, or it should be optional, maybe even with a new withClientSelector method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, for these simple cases, no client selector is needed and thus none needs to be specified. If the cookie manager is specified, it is essential that a decision is made if the client (including the cookie manager) may be shared and re-used or not. Therefore, in this exact case, we require the parameter to enforce this decision to be made.

This is breaking as some constants were public. Use HttpHeaders from
guava for proper constants.
@andyHa andyHa merged commit 6c194c0 into develop Nov 20, 2025
4 checks passed
@andyHa andyHa deleted the feature/aha/outcall-cleanup branch November 20, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💣 BREAKING CHANGE Contains non-backwards compatible changes to public methods or changes the behavior of existing code 🧬 Enhancement Contains new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants