Skip to content

Conversation

CennyMo
Copy link
Contributor

@CennyMo CennyMo commented Aug 10, 2025

No description provided.

@CennyMo CennyMo force-pushed the subscription branch 3 times, most recently from 005b206 to 5a3414d Compare August 10, 2025 07:19
Copy link

codecov bot commented Aug 10, 2025

Codecov Report

❌ Patch coverage is 95.83333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.34%. Comparing base (8961496) to head (5a3414d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...hub/protocol/pulsar/admin/jdk/InnerHttpClient.java 80.00% 0 Missing and 1 partial ⚠️
...tocol/pulsar/admin/jdk/PulsarAdminBuilderImpl.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #47      +/-   ##
============================================
+ Coverage     53.06%   55.34%   +2.27%     
- Complexity       95      102       +7     
============================================
  Files            21       22       +1     
  Lines           603      636      +33     
  Branches         57       59       +2     
============================================
+ Hits            320      352      +32     
  Misses          235      235              
- Partials         48       49       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@Copilot 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 HTTP client configuration by replacing the original TLS and HTTP engine configurations with a unified HttpClientConfig approach. The changes modernize the configuration API by using external configuration classes from the io.github.openfacade.http package.

  • Replaces direct TLS configuration with HttpClientConfig-based approach
  • Updates test classes to use parameterized tests and builder patterns
  • Migrates from custom TlsConfig to external TlsConfig implementation

Reviewed Changes

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

Show a summary per file
File Description
TlsClientWrongHostTest.java Updated to use new TlsConfig.Builder and HttpClientConfig.Builder pattern
TlsClientTest.java Refactored all test methods to use builder pattern and removed helper method
ClustersTest.java Converted to parameterized test using MethodSource
BrokersTest.java Converted to parameterized test using MethodSource
BaseTest.java Updated to use HttpClientConfig.Builder instead of direct Configuration
PulsarAdminBuilderImpl.java Replaced TLS-specific methods with HttpClientConfig methods
PulsarAdminBuilder.java Updated interface to use HttpClientConfig instead of TlsConfig
InnerHttpClient.java Simplified TLS detection logic using HttpClientConfig
SslContextUtil.java Updated to use external TlsConfig with method-based access
InnerReactiveClient.java Replaced custom HTTP client creation with ReactorHttpClientFactory
Configuration.java Removed TLS-specific fields and replaced with HttpClientConfig

Comment on lines 15 to 17
this.httpPrefix = "https://" + conf.host + ":" + conf.port;
} else {
this.httpPrefix = "http://" + conf.host + ":" + conf.port;
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

The conditional logic is inverted. When TLS config is null, it should use HTTP (not HTTPS), and when TLS config exists, it should use HTTPS. The current logic assigns HTTPS prefix when TLS config is null.

Suggested change
this.httpPrefix = "https://" + conf.host + ":" + conf.port;
} else {
this.httpPrefix = "http://" + conf.host + ":" + conf.port;
this.httpPrefix = "http://" + conf.host + ":" + conf.port;
} else {
this.httpPrefix = "https://" + conf.host + ":" + conf.port;

Copilot uses AI. Check for mistakes.

Comment on lines 44 to 52
private PulsarAdmin createPulsarAdmin(TlsConfig tlsConfig) throws PulsarAdminException {
HttpClientConfig.Builder builder = new HttpClientConfig.Builder();
builder.tlsConfig(tlsConfig);
return PulsarAdmin.builder()
.port(getPort())
.tlsEnabled(true)
.tlsConfig(tlsConfig)
.build();
.port(getPort())
.httpClientConfig(builder.build())
.build();
}

Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

[nitpick] The createPulsarAdmin helper method is now only used once and duplicates the same builder pattern used elsewhere. Consider removing this method and inlining the builder code in the remaining test that uses it.

Copilot uses AI. Check for mistakes.

Comment on lines +55 to +83
TlsConfig.Builder builder = new TlsConfig.Builder();
builder.verifyDisabled(false);
builder.hostnameVerifyDisabled(true);
builder.versions(null);
builder.cipherSuites(null);
builder.keyStore(new File(CLIENT_KEYSTORE_FILE).getAbsolutePath(),
CLIENT_CERT_PASSWORD.toCharArray());
builder.trustStore(new File(CLIENT_TRUSTSTORE_FILE).getAbsolutePath(),
CLIENT_CERT_PASSWORD.toCharArray());
HttpClientConfig.Builder clientConfigBuilder = new HttpClientConfig.Builder();
clientConfigBuilder.tlsConfig(builder.build());
PulsarAdmin pulsarAdmin = PulsarAdmin.builder()
.port(getPort())
.httpClientConfig(clientConfigBuilder.build())
.build();
pulsarAdmin.brokers().healthcheck(TopicVersion.V1);
}

@Test
public void testTlsCustomProtocol() throws PulsarAdminException {
TlsConfig tlsConfig = new TlsConfig(
new File(CLIENT_KEYSTORE_FILE).getAbsolutePath(),
CLIENT_CERT_PASSWORD.toCharArray(),
new File(CLIENT_TRUSTSTORE_FILE).getAbsolutePath(),
CLIENT_CERT_PASSWORD.toCharArray(),
false,
true,
new String[]{"TLSv1.2"},
null
);
PulsarAdmin pulsarAdmin = createPulsarAdmin(tlsConfig);
TlsConfig.Builder builder = new TlsConfig.Builder();
builder.verifyDisabled(false);
builder.hostnameVerifyDisabled(true);
builder.versions(new String[]{"TLSv1.2"});
builder.cipherSuites(null);
builder.keyStore(new File(CLIENT_KEYSTORE_FILE).getAbsolutePath(),
CLIENT_CERT_PASSWORD.toCharArray());
builder.trustStore(new File(CLIENT_TRUSTSTORE_FILE).getAbsolutePath(),
CLIENT_CERT_PASSWORD.toCharArray());
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

[nitpick] The TLS configuration builder pattern is repeated across multiple test methods. Consider extracting a helper method to create the base TlsConfig.Builder with common settings (keyStore, trustStore) to reduce code duplication.

Copilot uses AI. Check for mistakes.

@hezhangjian hezhangjian merged commit a3424cc into protocol-laboratory:main Aug 10, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants