gnodet commented on code in PR #26170:
URL: https://github.com/apache/camel/pull/26170#discussion_r3951403989
##########
components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java:
##########
@@ -143,6 +147,30 @@ public void httpGetWithProxyOnComponent() {
assertExchange(exchange);
}
+ @Test
+ public void httpsTargetWithProxyDefaultsToHttpProxyScheme() throws
Exception {
+ // CAMEL-24632: proxy scheme must default to "http" regardless of the
target endpoint scheme
+ HttpEndpoint endpoint = context.getEndpoint(
+ "https://www.example.com?proxyHost=myproxy&proxyPort=8080",
HttpEndpoint.class);
+
+ HttpClientConfigurer configurer = endpoint.getHttpClientConfigurer();
+ assertThat(configurer).isNotNull();
+
+ HttpClientBuilder builder = HttpClientBuilder.create();
+ configurer.configureHttpClient(builder);
+
+ Field proxyField = HttpClientBuilder.class.getDeclaredField("proxy");
Review Comment:
⚠️ **Fragile test — reflection on internal `HttpClientBuilder` field.**
`HttpClientBuilder.class.getDeclaredField("proxy")` accesses an undocumented
private field of an Apache HttpComponents 5 internal class. If that field is
renamed or refactored in a future httpclient5 version, this line throws
`NoSuchFieldException` and the entire `throws Exception` method fails —
silently removing your regression coverage without any compilation warning.
The existing tests in this file (`testHttpGetWithProxy`,
`httpGetWithProxyOnComponent`) use a real embedded `HttpServer` proxy — that
same approach is more reliable here. Alternatively, intercept at the
`ProxyHttpClientConfigurer` level or use `HttpClientContext` post-execution to
assert the proxy route.
If the reflection approach is intentionally kept for speed, the
`NoSuchFieldException` should at minimum produce a clear failure message:
```suggestion
Field proxyField;
try {
proxyField = HttpClientBuilder.class.getDeclaredField("proxy");
} catch (NoSuchFieldException e) {
throw new AssertionError(
"HttpClientBuilder internal field 'proxy' no longer
exists — update this test", e);
}
proxyField.setAccessible(true);
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]