Skip to content

Commit 20eff9e

Browse files
Merge pull request #796 from cortlepp/fix/AXIS2-6044
fix: correct http proxy configuration precedence (#AXIS2-6044)
2 parents dd74683 + 247d04e commit 20eff9e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

modules/transport/http/src/main/java/org/apache/axis2/transport/http/impl/httpclient5/HTTPProxyConfigurator.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,18 @@ public static void configure(MessageContext messageContext, RequestConfig.Builde
7676
String proxyUser = null;
7777
String proxyPassword = null;
7878

79-
// Getting configuration values from Axis2.xml
79+
80+
// First: get settings from system properties
81+
String host = System.getProperty(HTTPTransportConstants.HTTP_PROXY_HOST);
82+
if (host != null) {
83+
proxyHost = host;
84+
}
85+
String port = System.getProperty(HTTPTransportConstants.HTTP_PROXY_PORT);
86+
if (port != null && !port.isEmpty()) {
87+
proxyPort = Integer.parseInt(port);
88+
}
89+
90+
// Override with settings from Axis2.xml
8091
Parameter proxySettingsFromAxisConfig = messageContext.getConfigurationContext()
8192
.getAxisConfiguration().getParameter(HTTPTransportConstants.ATTR_PROXY);
8293
if (proxySettingsFromAxisConfig != null) {
@@ -99,17 +110,16 @@ public static void configure(MessageContext messageContext, RequestConfig.Builde
99110
if (proxyUser.length() > proxyUserDomainIndex + 1) {
100111
String user = proxyUser.substring(proxyUserDomainIndex + 1);
101112
proxyCredentials = new NTCredentials(user, proxyPassword.toCharArray(), proxyHost,
102-
domain);
113+
domain);
103114
}
104115
}
105116
}
106117
}
107118

108-
// If there is runtime proxy settings, these settings will override
109-
// settings from axis2.xml
119+
// Override with settings from MessageContext
110120
HttpTransportProperties.ProxyProperties proxyProperties =
111121
(HttpTransportProperties.ProxyProperties) messageContext
112-
.getProperty(HTTPConstants.PROXY);
122+
.getProperty(HTTPConstants.PROXY);
113123
if (proxyProperties != null) {
114124
String proxyHostProp = proxyProperties.getProxyHostName();
115125
if (proxyHostProp == null || proxyHostProp.length() <= 0) {
@@ -132,16 +142,7 @@ public static void configure(MessageContext messageContext, RequestConfig.Builde
132142

133143
}
134144

135-
// Overriding proxy settings if proxy is available from JVM settings
136-
String host = System.getProperty(HTTPTransportConstants.HTTP_PROXY_HOST);
137-
if (host != null) {
138-
proxyHost = host;
139-
}
140145

141-
String port = System.getProperty(HTTPTransportConstants.HTTP_PROXY_PORT);
142-
if (port != null && !port.isEmpty()) {
143-
proxyPort = Integer.parseInt(port);
144-
}
145146

146147
// AXIS2-6051, CredentialsProvider no longer has setCredentials() however BasicCredentialsProvider
147148
// does have it. clientContext.getCredentialsProvider() returns CredentialsProvider.

0 commit comments

Comments
 (0)