dragonwell-project / dragonwell8

Alibaba Dragonwell8 JDK
http://dragonwell-jdk.io
GNU General Public License v2.0
4.2k stars 497 forks source link

[Bug] java.net.Socket::isConnected behaves differently from openJDK #437

Closed luoxiner closed 1 year ago

luoxiner commented 1 year ago

Description the method java.net.Socket::isConnected behaves differently from openJDK this different behavior cause the java.net.Socket::getRemoteSocketAddress returns an unexpected null value.

the openJDK specification of java.net.Socket::isConnected is Returns the connection state of the socket. Note: Closing a socket doesn't clear its connection state, which means this method will return true for a closed socket (see isClosed()) if it was successfuly connected prior to being closed. Returns: true if the socket was successfuly connected to a server Since: 1.4

public boolean isConnected() {
    if (WispEngine.transparentWispSwitch())
        return asyncImpl.isConnected(); // return the SocketChannelImpl.isConnected

    // Before 1.3 Sockets were always connected during creation
    return connected || oldImpl;
}

Expected behavior return the same value as openJDk

JDK version openjdk version "1.8.0_322" OpenJDK Runtime Environment (Alibaba Dragonwell 8.10.11) (build 1.8.0_322-b01) OpenJDK 64-Bit Server VM (Alibaba Dragonwell 8.10.11) (build 25.322-b01, mixed mode)

zhengxiaolinX commented 1 year ago

Thanks a lot for reporting this! It is indeed a discordance, and we are working on that.

zhengxiaolinX commented 1 year ago

Done as completed.