You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unable to create a Proxy of ProxyType.SYSTEM. This is how I was able to workaround but it is not ideal since I'm not using the SystemSelector.
static Optional<Proxy> createProxyFromSystemProperties() {
String httpsProxy = System.getProperty("https.proxyHost");
String host = httpsProxy == null ? System.getProperty("http.proxyHost") : httpsProxy;
String noProxy = System.getProperty("http.nonProxyHosts");
String proxyPort = System.getProperty("http.proxyPort");
if (host != null) {
Proxy.Builder proxyBuilder = Proxy.builder()
.type(Proxy.ProxyType.HTTP)
.host(host);
if (noProxy != null) {
Arrays.stream(noProxy.split(Pattern.quote("|")))
// Helidon NoProxy only works if the * is not provided
.map(s -> s.startsWith("*.") ? s.substring(1) : s)
.forEach(proxyBuilder::addNoProxy);
}
if (proxyPort != null) {
proxyBuilder.port(Integer.parseInt(proxyPort));
}
return Optional.ofNullable(proxyBuilder.build());
}
return Optional.empty();
}
Steps to reproduce
I've created the following test classe in project generated by the helidon-quickstart-mp archetype to highlight the issue:
package io.helidon.examples.quickstart.mp;
import io.helidon.webclient.Proxy;
import java.lang.reflect.Field;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class SystemProxyTest {
@Test
void staticMethodCreationTest() throws NoSuchFieldException, IllegalAccessException {
// The javadoc says:
// Create from environment and system properties.
// Returns: a proxy instance configured based on this system settings
Proxy proxy = Proxy.create();
Field field = proxy.getClass().getDeclaredField("type");
field.setAccessible(true);
assertEquals(Proxy.ProxyType.SYSTEM, field.get(proxy));
}
@Test
void builderCreationTest() throws NoSuchFieldException, IllegalAccessException {
// The javadoc says:
// Configure proxy from environment variables and system properties.
// Params:
// useIt – use system selector
Proxy proxy = Proxy.builder()
.useSystemSelector(true)
.build();
Field field = proxy.getClass().getDeclaredField("type");
field.setAccessible(true);
assertEquals(Proxy.ProxyType.SYSTEM, field.get(proxy));
}
}
I've added the official javadoc in that code snippet to highlight that the behavior is different than expected.
The culprit seems to be this condition (which still exists in Helidon 3.0):
Environment Details
Problem Description
Unable to create a Proxy of ProxyType.SYSTEM. This is how I was able to workaround but it is not ideal since I'm not using the SystemSelector.
Steps to reproduce
I've created the following test classe in project generated by the helidon-quickstart-mp archetype to highlight the issue:
I've added the official javadoc in that code snippet to highlight that the behavior is different than expected.
The culprit seems to be this condition (which still exists in Helidon 3.0):
helidon/webclient/webclient/src/main/java/io/helidon/webclient/Proxy.java
Line 429 in 84123e8
The text was updated successfully, but these errors were encountered: