From 9b6bed78dc2f648f630634c61590ae701b653490 Mon Sep 17 00:00:00 2001 From: Mikko Kortelainen Date: Mon, 13 May 2024 12:48:34 +0300 Subject: [PATCH] remove extra throws from ClientFactory.open (#157) * remove extra throws from ClientFactory.open * remove throws from ClientFactory.open --- .../com/teragrep/rlp_03/client/ClientFactory.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/teragrep/rlp_03/client/ClientFactory.java b/src/main/java/com/teragrep/rlp_03/client/ClientFactory.java index ed093f7c..171e6a49 100644 --- a/src/main/java/com/teragrep/rlp_03/client/ClientFactory.java +++ b/src/main/java/com/teragrep/rlp_03/client/ClientFactory.java @@ -83,13 +83,8 @@ public ClientFactory(ConnectContextFactory connectContextFactory, EventLoop even * * @param inetSocketAddress destination {@link InetSocketAddress} to connect to. * @return a {@link Client} {@link CompletableFuture}. - * @throws IOException if connection attempt fails. - * @throws InterruptedException if waiting for connection establishment is interrupted. - * @throws ExecutionException if connection establishment fails to complete successfully. - * @throws TimeoutException if connection establishment times out. */ - public CompletableFuture open(InetSocketAddress inetSocketAddress) - throws IOException, InterruptedException, ExecutionException, TimeoutException { + public CompletableFuture open(InetSocketAddress inetSocketAddress) { // this is for returning ready connection CompletableFuture readyContextFuture = new CompletableFuture<>(); Consumer establishedContextConsumer = readyContextFuture::complete; @@ -100,14 +95,14 @@ public CompletableFuture open(InetSocketAddress inetSocketAddress) try { connectContext = connectContextFactory .create(inetSocketAddress, clientDelegate, establishedContextConsumer); + LOGGER.debug("registering to eventLoop <{}>", eventLoop); + eventLoop.register(connectContext); + LOGGER.debug("registered to eventLoop <{}>", eventLoop); } catch (IOException ioException) { clientDelegate.close(); - throw ioException; + readyContextFuture.completeExceptionally(ioException); } - LOGGER.debug("registering to eventLoop <{}>", eventLoop); - eventLoop.register(connectContext); - LOGGER.debug("registered to eventLoop <{}>", eventLoop); return readyContextFuture.thenApply(clientDelegate::create); }