Skip to content

Commit

Permalink
close clientDelegate in case connectContextFactory.create throws (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
kortemik authored Apr 9, 2024
1 parent 8123988 commit 328c023
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public boolean accept(FrameContext frameContext) {
}

@Override
public void close() throws Exception {
public void close() {
LOGGER.debug("client FrameDelegate close");
}

Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/teragrep/rlp_03/client/ClientFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,16 @@ public Client open(InetSocketAddress inetSocketAddress)
Consumer<EstablishedContext> establishedContextConsumer = readyContextFuture::complete;

ClientDelegate clientDelegate = new ClientDelegate();
ConnectContext connectContext = connectContextFactory
.create(inetSocketAddress, clientDelegate, establishedContextConsumer);

ConnectContext connectContext;
try {
connectContext = connectContextFactory
.create(inetSocketAddress, clientDelegate, establishedContextConsumer);
}
catch (IOException ioException) {
clientDelegate.close();
throw ioException;
}
LOGGER.debug("registering to eventLoop <{}>", eventLoop);
eventLoop.register(connectContext);
LOGGER.debug("registered to eventLoop <{}>", eventLoop);
Expand Down

0 comments on commit 328c023

Please sign in to comment.