Skip to content

channel().localAddress() not always return an InetSocketAddress#330

Open
fbacchella wants to merge 1 commit into
logstash-plugins:mainfrom
fbacchella:beatshandler_format
Open

channel().localAddress() not always return an InetSocketAddress#330
fbacchella wants to merge 1 commit into
logstash-plugins:mainfrom
fbacchella:beatshandler_format

Conversation

@fbacchella

Copy link
Copy Markdown
Contributor

channel().localAddress() not always return an InetSocketAddress, for example during unit tests.

So check they are the right type before type cast.

It must be merged before PR #329.

@fbacchella

Copy link
Copy Markdown
Contributor Author

Travis failed only for jruby 1.7.27. All others succeeded. Is that something related to this PR or more generic .

@fbacchella fbacchella force-pushed the beatshandler_format branch from 4ac6c49 to 13374df Compare June 24, 2018 09:07
@robbavey robbavey self-assigned this Jul 2, 2018

@robbavey robbavey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment on code duplication and a spacing nitpick. Other than that, this looks great - thanks for the contribution!

SocketAddress local = context.channel().localAddress();
SocketAddress remote = context.channel().remoteAddress();

String localhost ;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: unnecessary space before ;

if (local instanceof InetSocketAddress) {
InetSocketAddress inetlocal = (InetSocketAddress)local;
localhost = inetlocal.getAddress().getHostAddress() + ":" + inetlocal.getPort();
} else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you refactor this to remove the code duplication?

@fbacchella fbacchella force-pushed the beatshandler_format branch from 13374df to 8600bf9 Compare July 2, 2018 16:50
@fbacchella

Copy link
Copy Markdown
Contributor Author

$ rvm use jruby-9.1.13.0 --install --binary --fuzzy
curl: (22) The requested URL returned error: 404 Not Found

The travis failure is not mine.

…example during unit tests.

So check they are the right type before type cast.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants