Skip to content

Conversation

@MBaesken
Copy link
Member

@MBaesken MBaesken commented Dec 15, 2025

We have a Linux machine with IPV6 disabled.
There the test javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.java fails.
Error is

java.lang.RuntimeException: Server failed to start.
at SubjectAltNameIP.doClientSide(SubjectAltNameIP.java:139)
at SubjectAltNameIP.<init>(SubjectAltNameIP.java:189)
at SubjectAltNameIP.main(SubjectAltNameIP.java:176)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
at java.base/java.lang.Thread.run(Thread.java:1516)
Caused by: java.net.SocketException: Protocol family unavailable

After looking into the test, it turned out the IPV6 address ::1 was passed in the notion [::1] to the isIPv6LiteralAddress, but this method must get the address without '[' and ']' .
Additionally I adjusted the exception a bit so that it directly mentions IPV6 and not just some 'protol family' .


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8373676: Test javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.java fails on a machine without IPV6 (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28825/head:pull/28825
$ git checkout pull/28825

Update a local copy of the PR:
$ git checkout pull/28825
$ git pull https://git.openjdk.org/jdk.git pull/28825/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28825

View PR using the GUI difftool:
$ git pr show -t 28825

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28825.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 15, 2025

👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 15, 2025

@MBaesken This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8373676: Test javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.java fails on a machine without IPV6

Reviewed-by: jpai, dfuchs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 29 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8373676: Test javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.java fails on a machine without IPV6 8373676: Test javax/net/ssl/HttpsURLConnection/SubjectAltNameIP.java fails on a machine without IPV6 Dec 15, 2025
@openjdk openjdk bot added security security-dev@openjdk.org net net-dev@openjdk.org labels Dec 15, 2025
@openjdk
Copy link

openjdk bot commented Dec 15, 2025

@MBaesken The following labels will be automatically applied to this pull request:

  • net
  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 15, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 15, 2025

Webrevs

Comment on lines 287 to 288
if (ipv6av) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family ipv6, ipv6 on machine available");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception does not really make sense. Are you really sure it's possible to get here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like to get into the else case starting at line 284 or before the patch like 282 , ipv6_available() / ipv6av can be false ; or also the second part of the if check can be false

!(family == java_net_InetAddress_IPv4 &&  v4MappedAddress == JNI_FALSE))

so we should distinguish the 2 cases. Not sure if this really happens, on our system showing the error we got the other one Caused by: java.net.SocketException: Protocol family ipv6, ipv6 on machine unavailable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just write the old message "Protocol family unavailable" for this case and enhance the else case ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking more at the checks, I think we can always use the exception
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family ipv6, ipv6 on machine unavailable");
without the if and else. At least as long as the other if checks do not change. Do you agree?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I would expect. I have not double checked.

Copy link
Member

@dfuch dfuch Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you are right - we enter the if part if:

ipv6 is available AND ( family != IPv4 OR mapped == true)
=> we either have an IPv6 address or we have an IPv4 address that will be mapped to an IPv6 address

So if we enter the else, either we have an IPv4 address, or we don't. If we don't, then we are here because IPv6 is not available.


/*
* @test
* @bug 8369950
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you please add this bug id to the @bug annotation here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's useful. The implementation changes are unrelated. It could be better to mark the JBS issue with one of the noreg labels.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be best to split out the exception message improvement in a new JBS issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be best to split out the exception message improvement in a new JBS issue.

Sure , we can do this.
I created https://bugs.openjdk.org/browse/JDK-8373704
Improve SocketException: Protocol family unavailable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Matthias!

@MBaesken
Copy link
Member Author

I removed the net_util_md.c exception message changes.

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks OK to me.

It's a bit odd that this sun.net.util.IPAddressUtil.isIPv6LiteralAddress("[::1]") returns false where as InetAddress.ofLiteral("[::1]") returns a valid InetAddress. But IPAddressUtil is an internal implementation util, so that's what the expectation maybe of that implementation. The change to this test looks OK to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 16, 2025
@dfuch
Copy link
Member

dfuch commented Dec 16, 2025

It's a bit odd that this sun.net.util.IPAddressUtil.isIPv6LiteralAddress("[::1]") returns false where as InetAddress.ofLiteral("[::1]") returns a valid InetAddress. But IPAddressUtil is an internal implementation util, so that's what the expectation maybe of that implementation. The change to this test looks OK to me.

FWIW InetAddress.ofLiteral accepts the enclosing "[]" because that's what InetAddress.getByName does.
And as you noted sun.net.util.IPAddressUtil.isIPv6LiteralAddress is an internal API - it parses the literal according to the IPv6 literal syntax (which doesn't include the "[]")

    jshell> InetAddress.getByName("[::1]")
    $1 ==> /0:0:0:0:0:0:0:1

Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MBaesken
Copy link
Member Author

Thanks for the reviews ! Maybe someone wants to look also at https://bugs.openjdk.org/browse/JDK-8373704 / #28851 ?

@MBaesken
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Dec 17, 2025

Going to push as commit 9e2008b.
Since your change was applied there have been 34 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 17, 2025
@openjdk openjdk bot closed this Dec 17, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 17, 2025
@openjdk
Copy link

openjdk bot commented Dec 17, 2025

@MBaesken Pushed as commit 9e2008b.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated net net-dev@openjdk.org security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

4 participants