Skip to content

Commit

Permalink
TcpServerBinder logs "Failed to create a connection" twice (apple#3113
Browse files Browse the repository at this point in the history
)

Motivation:

`TcpServerBinder` uses `beforeOnError` to log any failures to create a
connection (to capture connection info) and then it goes to
`SimpleSingleSubscriber` that logs it again.

Modifications:

- Use new `Single.subscribe(...)` overload that takes `errorConsumer` to
log "Failed to create a connection";
- Log full `Channel` info instead of just remote address to keep
consistent patter of starting all network-level logs with channel id;

Result:

Exception is logged only once.
  • Loading branch information
idelpivnitskiy authored and mgodave committed Nov 19, 2024
1 parent a32db4d commit fc04bb3
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,10 @@ protected void initChannel(final Channel channel) {
connectionSingle = wrapConnectionAcceptors(connectionSingle, channel, executionContext, config,
earlyConnectionAcceptor, lateConnectionAcceptor, connectionAcceptor);

connectionSingle.beforeOnError(cause -> {
// Getting the remote-address may involve volatile reads and potentially a syscall, so guard it.
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Failed to create a connection for remote address {}", channel.remoteAddress(),
cause);
}
connectionSingle.subscribe(connectionConsumer, cause -> {
LOGGER.debug("{} Failed to create a connection", channel, cause);
close(channel, cause);
}).subscribe(connectionConsumer);
});
}
});

Expand Down

0 comments on commit fc04bb3

Please sign in to comment.