Skip to content

EphemeralPortTest failing intermittently  #6122

@reckart

Description

@reckart

When I run ./gradlew :build, the following test sometimes fails

EphemeralPortTest > automatic_supplier() FAILED
    java.net.BindException: Address already in use
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:555)
        at java.base/sun.nio.ch.Net.bind(Net.java:544)
        at java.base/sun.nio.ch.NioSocketImpl.bind(NioSocketImpl.java:643)
        at java.base/java.net.ServerSocket.bind(ServerSocket.java:393)
        at java.base/java.net.ServerSocket.<init>(ServerSocket.java:279)
        at java.base/java.net.ServerSocket.<init>(ServerSocket.java:172)
        at aQute.bnd.test.net.EphemeralPortTest.automatic_supplier(EphemeralPortTest.java:17)

1 test completed, 1 failed

I don't really see how it can fail because what it does is check if a port is free and then allocate the port again. So my guess is that when the port is allocated and then released, maybe the OS does not immediately release it (race condition).

Has anybody also seen this?

macOS 14.4.1
openjdk version "17.0.3" 2022-04-19 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions