JDK-8293842 : IPv6-only systems throws UnsupportedOperationException for several socket/TCP options
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-09-15
  • Updated: 2022-09-19
  • Resolved: 2022-09-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 20
20 masterFixed
Description
A few places in native code tries to create a socket with PF_INET, then check if a socket or TCP option is supported. E.g. in LinuxSocketOptions.c:

static jint socketOptionSupported(jint level, jint optname) {
    jint one = 1;
    jint rv, s;
    socklen_t sz = sizeof (one);
    s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (s < 0) {
        return 0;
    }
    rv = getsockopt(s, level, optname, (void *) &one, &sz);
    ...
}

On systems that only supports IPv6, the socket(PF_INET, ...) call fails, and it will incorrectly report those options are unsupported. Affected options include: SO_REUSEPORT, TCP_KEEPIDLE, TCP_KEEPCNT, TCP_QUICKACK.

Comments
Changeset: 9a40b76a Author: Man Cao <manc@openjdk.org> Date: 2022-09-15 22:06:18 +0000 URL: https://git.openjdk.org/jdk/commit/9a40b76ac594f5bd80e74ee906af615f74f9a41a
15-09-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10278 Date: 2022-09-15 07:25:04 +0000
15-09-2022

Failures due to this typically look like: java.lang.UnsupportedOperationException: 'TCP_KEEPIDLE' not supported at java.base/sun.nio.ch.AsynchronousSocketChannelImpl.setOption(Unknown Source) at com.sap.db.util.SocketUtils.setKeepAliveOptions(Unknown Source) at com.sap.db.jdbc.Session._setChannelOptions(Session.java:1121) at com.sap.db.jdbc.Session._connect(Session.java:825) at com.sap.db.jdbc.Session.<init>(Session.java:367) ... A quick check is to print the return value from "java.nio.channels.AsynchronousSocketChannel.open().supportedOptions()".
15-09-2022