Describe the bug
When the http_proxy / https_proxy environment variable ends with a trailing slash — e.g. http_proxy=http://proxy.example.com:8080/ — feature installation fails with a raw java.lang.NumberFormatException: For input string: "8080/" instead of a Liberty diagnostic message.
InstallKernelMap.checkValidProxy() already owns a dedicated message for this exact situation (ERROR_TOOL_INVALID_PROXY_PORT → CWWKF1368E: The proxy server port number {0} is invalid. Port number must be a number that ranges from 1 to 65535.) and it does validate the 1–65535 range. But the Integer.parseInt(port) call that feeds that check is not wrapped in a try/catch, so a non-numeric port escapes as an unchecked NumberFormatException before the intended message can ever be emitted.
Note that http://proxy.example.com:8080/ is a syntactically valid URI (RFC 3986, empty path) and is accepted as-is by curl, apt, pip, npm and Docker, so it is a very common value to find already exported in a corporate environment. Even if Liberty decides the trailing slash must be rejected, the failure should surface as CWWKF1368E, not as a raw JDK exception.
Steps to reproduce
export http_proxy=http://proxy.example.com:8080/ # note the trailing slash
export https_proxy=http://proxy.example.com:8080/
mvn io.openliberty.tools:liberty-maven-plugin:3.12.3:create \
io.openliberty.tools:liberty-maven-plugin:3.12.3:install-feature
Removing the trailing slash from both variables makes the build succeed.
Expected behaviour
Either:
- the trailing slash / empty path is tolerated and the port parsed as
8080 (preferred — it is a valid URI); or
- the value is rejected with the message that already exists for it,
CWWKF1368E (or ERROR_IMPROPER_HTTPPROXY_FORMAT / ERROR_IMPROPER_HTTPSPROXY_FORMAT), naming the offending variable.
Actual behaviour
[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.12.3:install-feature
(default-cli) on project my-app: Execution default-cli of goal
io.openliberty.tools:liberty-maven-plugin:3.12.3:install-feature failed:
For input string: "8080/" -> [Help 1]
Stack trace (mvn -e), abridged to the relevant frames:
Caused by: java.lang.NumberFormatException: For input string: "8080/"
at java.lang.Integer.parseInt (Integer.java:668)
at java.lang.Integer.parseInt (Integer.java:786)
at com.ibm.ws.install.internal.InstallKernelMap.checkValidProxy (InstallKernelMap.java:1200)
at com.ibm.ws.install.internal.InstallKernelMap.setProxy (InstallKernelMap.java:1165)
at com.ibm.ws.install.internal.InstallKernelMap.get (InstallKernelMap.java:321)
at com.ibm.ws.install.map.InstallMap.get (InstallMap.java:275)
at io.openliberty.tools.common.plugins.util.InstallFeatureUtil.downloadPublicKeys (InstallFeatureUtil.java:1342)
at io.openliberty.tools.common.plugins.util.InstallFeatureUtil.verifyFeatures (InstallFeatureUtil.java:1319)
at io.openliberty.tools.common.plugins.util.InstallFeatureUtil.installFeatures (InstallFeatureUtil.java:791)
at io.openliberty.tools.maven.server.InstallFeatureMojo.installFeatures (InstallFeatureMojo.java:122)
The raw message gives no hint that an environment variable is at fault, which makes this very hard to diagnose — the same complaint was raised in OpenLiberty/ci.maven#1910.
Diagnosis
Two observations from dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java:
getProxyVariables(String, String) splits the environment value on @ (credentials) and then on : to derive <protocol>.proxyHost / <protocol>.proxyPort. The last segment is used verbatim as the port, so any path component — including a lone / — is carried into the port string.
checkValidProxy(String) then calls Integer.parseInt on that string with no try/catch, even though the very next statement is the 1–65535 range check that raises ERROR_TOOL_INVALID_PROXY_PORT.
Because the values are read through System.getenv in getEnvMap(), this cannot be worked around from the caller side: a JVM cannot modify its own environment, and getEnvMap() does not consult already-set https.proxyPort / http.proxyHost system properties, so passing them via MAVEN_OPTS has no effect.
The failure is reached only through feature signature verification (downloadPublicKeys). Setting the Liberty Maven Plugin's <features><verify>skip</verify></features> makes the same build succeed with the unchanged slashed proxy, which confirms the localisation. The feature ESAs themselves download fine, since they go through the Maven resolver and its own settings.xml proxy configuration.
Suggested fix
Parse the environment value with java.net.URI and take getHost() / getPort(), which handles the scheme, optional credentials, and any path or trailing slash uniformly. Failing that, a minimal fix would be to strip anything after the port in getProxyVariables and to wrap the Integer.parseInt in checkValidProxy so that a non-numeric port reports the existing CWWKF1368E instead of escaping as a NumberFormatException.
Diagnostic information
- Open Liberty version: 26.0.0.9 (
wlp-1.0.117.cl260920260824-0859)
- Affected bundle:
com.ibm.ws.install_1.0.117.jar
liberty-maven-plugin: reproduced on both 3.12.1 and 3.12.3 (so not a plugin regression)
ci.common: 1.8.43
- Java: OpenJDK 17.0.7 (Temurin-17.0.7+7)
- Maven: 3.9.5
- OS: Linux (Fedora, x86_64)
Related issues
Describe the bug
When the
http_proxy/https_proxyenvironment variable ends with a trailing slash — e.g.http_proxy=http://proxy.example.com:8080/— feature installation fails with a rawjava.lang.NumberFormatException: For input string: "8080/"instead of a Liberty diagnostic message.InstallKernelMap.checkValidProxy()already owns a dedicated message for this exact situation (ERROR_TOOL_INVALID_PROXY_PORT→CWWKF1368E: The proxy server port number {0} is invalid. Port number must be a number that ranges from 1 to 65535.) and it does validate the 1–65535 range. But theInteger.parseInt(port)call that feeds that check is not wrapped in atry/catch, so a non-numeric port escapes as an uncheckedNumberFormatExceptionbefore the intended message can ever be emitted.Note that
http://proxy.example.com:8080/is a syntactically valid URI (RFC 3986, empty path) and is accepted as-is by curl, apt, pip, npm and Docker, so it is a very common value to find already exported in a corporate environment. Even if Liberty decides the trailing slash must be rejected, the failure should surface asCWWKF1368E, not as a raw JDK exception.Steps to reproduce
Removing the trailing slash from both variables makes the build succeed.
Expected behaviour
Either:
8080(preferred — it is a valid URI); orCWWKF1368E(orERROR_IMPROPER_HTTPPROXY_FORMAT/ERROR_IMPROPER_HTTPSPROXY_FORMAT), naming the offending variable.Actual behaviour
Stack trace (
mvn -e), abridged to the relevant frames:The raw message gives no hint that an environment variable is at fault, which makes this very hard to diagnose — the same complaint was raised in OpenLiberty/ci.maven#1910.
Diagnosis
Two observations from
dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/InstallKernelMap.java:getProxyVariables(String, String)splits the environment value on@(credentials) and then on:to derive<protocol>.proxyHost/<protocol>.proxyPort. The last segment is used verbatim as the port, so any path component — including a lone/— is carried into the port string.checkValidProxy(String)then callsInteger.parseInton that string with notry/catch, even though the very next statement is the 1–65535 range check that raisesERROR_TOOL_INVALID_PROXY_PORT.Because the values are read through
System.getenvingetEnvMap(), this cannot be worked around from the caller side: a JVM cannot modify its own environment, andgetEnvMap()does not consult already-sethttps.proxyPort/http.proxyHostsystem properties, so passing them viaMAVEN_OPTShas no effect.The failure is reached only through feature signature verification (
downloadPublicKeys). Setting the Liberty Maven Plugin's<features><verify>skip</verify></features>makes the same build succeed with the unchanged slashed proxy, which confirms the localisation. The feature ESAs themselves download fine, since they go through the Maven resolver and its ownsettings.xmlproxy configuration.Suggested fix
Parse the environment value with
java.net.URIand takegetHost()/getPort(), which handles the scheme, optional credentials, and any path or trailing slash uniformly. Failing that, a minimal fix would be to strip anything after the port ingetProxyVariablesand to wrap theInteger.parseIntincheckValidProxyso that a non-numeric port reports the existingCWWKF1368Einstead of escaping as aNumberFormatException.Diagnostic information
wlp-1.0.117.cl260920260824-0859)com.ibm.ws.install_1.0.117.jarliberty-maven-plugin: reproduced on both 3.12.1 and 3.12.3 (so not a plugin regression)ci.common: 1.8.43Related issues
http_proxy=host:port(no scheme) producedenvMap is null; fixed in Liberty 25.0.0.8 by addingCWWKF1400E. That validation does not cover a trailing slash, which still reachesparseInt.ERROR_IMPROPER_httpPROXY_FORMATraised for a proxy configuration the user believed valid.http_proxywith username and password rejected; the comment thread is where the requiredhttp://<proxy-host>:<proxy-port>format was stated.