]
Bela Ban resolved JGRP-2527.
----------------------------
Resolution: Done
NPE if binding JGroups to an IP without interface
-------------------------------------------------
Key: JGRP-2527
URL:
https://issues.redhat.com/browse/JGRP-2527
Project: JGroups
Issue Type: Bug
Affects Versions: 4.2.9
Reporter: Pedro Ruivo
Assignee: Bela Ban
Priority: Minor
Fix For: 4.2.12, 5.1.5
If you bind JGroups to 127.0.2.1 (or any IP without an interface, like 127.0.0.0/8 -
loopback IP addresses (refers to self) RFC 5735), JGroups fails with an NPE:
{noformat}
Caused by: java.lang.NullPointerException
at org.jgroups.protocols.UDP.dumpSocketInfo(UDP.java:558)
at org.jgroups.protocols.UDP.createSockets(UDP.java:422)
at org.jgroups.protocols.UDP.start(UDP.java:292)
at org.jgroups.stack.ProtocolStack.startStack(ProtocolStack.java:868)
at org.jgroups.JChannel.startStack(JChannel.java:980)
at org.jgroups.JChannel._preConnect(JChannel.java:844)
at org.jgroups.JChannel.connect(JChannel.java:349)
at org.jgroups.JChannel.connect(JChannel.java:343)
{noformat}
The exception comes from this line:
[
https://github.com/belaban/JGroups/blob/4.x/src/org/jgroups/protocols/UDP...]
{{NetworkInterface.getByInetAddress(bind_addr)}} returns {{null}} since the IP does not
have an interface. It would be nice to have a null check here to prevent the NPE.
This is useful for local testing when `port_range=0`. It allows having a dedicated IP for
each JGroups instance.
Workaround:
The workaround requires you to create a virtual interface
{noformat}
sudo ifconfig lo:0 127.0.2.1 up
{noformat}