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:
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)
The exception comes from this line: https://github.com/belaban/JGroups/blob/4.x/src/org/jgroups/protocols/UDP.java#L558
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
sudo ifconfig lo:0 127.0.2.1 up