Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #69: Coverity defects #70

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Try/catch the remote address instead of checking if the channel is ac…
…tive
51-code committed Aug 16, 2024
commit 1f289609e781df082d7c53df6bd4f0ed7e9ab651
9 changes: 6 additions & 3 deletions src/main/java/com/teragrep/lsh_01/HttpServerHandler.java
Original file line number Diff line number Diff line change
@@ -63,12 +63,15 @@ public HttpServerHandler(

@Override
public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest msg) {
if (!ctx.channel().isActive()) {
LOGGER.error("The channel bound to the ChannelHandlerContext is not connected, can't handle the message.");
final String remoteAddress;
try {
remoteAddress = ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().getHostAddress();
}
catch (NullPointerException e) {
LOGGER.error("Couldn't get the remote address, returning.");
return;
}

final String remoteAddress = ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().getHostAddress();
msg.retain();
final MessageProcessor messageProcessor = new MessageProcessor(
ctx,