On Thu, 28 Nov 2024 15:45:43 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> I need to verify the thrown exception in the test: >> >> * If the socket passed created using `Socket::new`, a >> `SocketException("already connected")` is thrown >> * If the socket passed created using `SocketChannel.open().socket()`, an >> `AlreadyConnectedException` is thrown >> >> AFAICT, the verifier needs to be passed along with the socket, and this >> implies either separate tests, which is what the current code does, or a >> separate test method source as in >> >> >> static List<Arguments> >> connectedSocketFactoriesAndReconnectFailureVerifiers() { >> return List.of( >> Arguments.of( >> (Function<SocketAddress, Socket>) >> ConnectFailTest::createConnectedSocket, >> (Consumer<Executable>) executable -> { >> SocketException exception = >> assertThrows(SocketException.class, executable); >> assertEquals("already connected", >> exception.getMessage()); >> }), >> Arguments.of( >> (Function<SocketAddress, Socket>) >> ConnectFailTest::createConnectedNioSocket, >> (Consumer<Executable>) executable -> >> assertThrows(AlreadyConnectedException.class, executable)) >> ); >> } >> >> >> Am I mistaken? > > I checked the socket adaptor and there is needed a bug here. SocketChannel > throws AlreadyConnectedException and the socket adaptor should map that to > SocketException("already connected"). It doesn't do that so we should fix it. I will push an enhancement here. Allow me some time, please. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22160#discussion_r1862426675