JDK-8369706 : Proxy selector + IPv6 may break socks proxy URI generation
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 17.0.16
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2025-10-13
  • Updated: 2025-10-13
Description
ADDITIONAL SYSTEM INFORMATION :
openjdk 17.0.16 2025-07-15
OpenJDK Runtime Environment (build 17.0.16+8-Ubuntu-0ubuntu124.04.1)
OpenJDK 64-Bit Server VM (build 17.0.16+8-Ubuntu-0ubuntu124.04.1, mixed mode, sharing)


PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

A DESCRIPTION OF THE PROBLEM :

Class: /usr/lib/jvm/java-1.17.0-openjdk-amd64!/java.base/java/net/SocksSocketImpl.class
Example of broken URI: socket://%5bfc00:0:0:0:0:0:6440:102%5d:6200

Likely problem:

```

                String host = epoint.getHostString();
                if (epoint.getAddress() instanceof Inet6Address && !host.startsWith("[") && host.indexOf(58) >= 0) {
                    host = "[" + host + "]";
                }

                URI uri;
                try {
                    uri = new URI("socket://" + ParseUtil.encodePath(host) + ":" + epoint.getPort());
                } catch (URISyntaxException e) {
                    assert false : e;

                    uri = null;
                }
```

the host is properly put in square brackets in
host = "[" + host + "]";

however this should not escape the square brackets:
uri = new URI("socket://" + ParseUtil.encodePath(host) + ":" + epoint.getPort());

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I do not know what the exact source is but the call comes from oracle.ons. 

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
probably as a normal url should look like
socket://[fc00:0:0:0:0:0:6440:102]:6200
ACTUAL -
socket://%5bfc00:0:0:0:0:0:6440:102%5d:6200 - resulting in a mangled url object

---------- BEGIN SOURCE ----------
Sorry, I don't have any.
---------- END SOURCE ----------