Skip to content

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Sep 22, 2025

This internal API had several unused methods.

In addition, application of the client configurators happens in OkHttpServices now. That removes as much OkHttp stuff as possible from DatabaseClientFactory. This will greatly simplify shifting to the JDK HTTP client some time in the future.

Copilot AI review requested due to automatic review settings September 22, 2025 17:24
@rjrudin rjrudin requested a review from stevebio as a code owner September 22, 2025 17:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the RESTServices API by removing unused methods and consolidating OkHttp client configuration logic into the OkHttpServices class. The main goal is to simplify the separation between HTTP client concerns and database client factory logic, preparing for a potential future migration to the JDK HTTP client.

Key changes:

  • Removed several unused methods from the RESTServices interface
  • Moved OkHttp client configurator application from DatabaseClientFactory into OkHttpServices
  • Introduced a ConnectionConfig record to encapsulate connection parameters

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
RESTServices.java Removed unused interface methods (getRetryStatus, setMaxDelay, connect, getDatabaseClient, setDatabaseClient) and MIMETYPE_MULTIPART_FORM constant
OkHttpServices.java Refactored to accept configuration via constructor, moved client configurator logic here, simplified connection handling
OkHttpUtil.java Added clientConfigurators parameter to newOkHttpClientBuilder method
DatabaseClientImpl.java Removed setDatabaseClient call from constructor
OkHttpClientBuilderFactory.java Updated to pass null for clientConfigurators parameter
DatabaseClientFactory.java Simplified client creation by moving configurator logic to OkHttpServices, updated type declarations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


static OkHttpClient.Builder newOkHttpClientBuilder(String host, DatabaseClientFactory.SecurityContext securityContext) {
return OkHttpUtil.newOkHttpClientBuilder(host, securityContext);
return OkHttpUtil.newOkHttpClientBuilder(host, securityContext, null);
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

Passing null for clientConfigurators could cause a NullPointerException when the forEach method is called on line 85 of OkHttpUtil.java. Consider passing an empty list instead.

Copilot uses AI. Check for mistakes.
throw new MarkLogicIOException(e);
} finally {
client = null;
logger.debug("Releasing connection");
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

The okHttpClient field is not being set to null after release, but the comment on lines 95-98 indicates it should be. This could lead to inconsistent state.

Suggested change
logger.debug("Releasing connection");
logger.debug("Releasing connection");
okHttpClient = null; // Ensure client is set to null after release

Copilot uses AI. Check for mistakes.
}

clientConfigurators.add(configurator);
clientConfigurators.add((OkHttpClientConfigurator) configurator);
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

Extra space before the closing parenthesis in the cast. Should be (OkHttpClientConfigurator) configurator.

Suggested change
clientConfigurators.add((OkHttpClientConfigurator) configurator);
clientConfigurators.add((OkHttpClientConfigurator) configurator);

Copilot uses AI. Check for mistakes.
@rjrudin rjrudin force-pushed the feature/cleanup-rest-services branch from 4301aa1 to 0034359 Compare September 22, 2025 18:07
This internal API had several unused methods.

In addition, application of the client configurators happens in OkHttpServices now. That removes as much OkHttp stuff as possible from DatabaseClientFactory. This will greatly simplify shifting to the JDK HTTP client some time in the future.
@rjrudin rjrudin force-pushed the feature/cleanup-rest-services branch from 0034359 to cc94b53 Compare September 22, 2025 18:25
@rjrudin rjrudin merged commit 38e2e7b into develop Sep 23, 2025
2 checks passed
@rjrudin rjrudin deleted the feature/cleanup-rest-services branch September 23, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants