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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fbacchella
Copy link
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
Contributor Author

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

Copy link
Contributor

@robbavey robbavey left a comment

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
Contributor

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
Contributor

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
Copy link
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