JDK-6749061 : (dc) NPE in MembershipRegistry.invalidateAll in close after failed attempt to join multicast group
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2008-09-16
  • Updated: 2010-04-02
  • Resolved: 2009-02-16
Related Reports
Duplicate :  
Description
The following test results in a NullPointerException (Linux only)

import java.net.*;
import java.nio.channels.*;

public class Test {
    public static void main(String[] args) throws Exception {
        DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET6)
            .setOption(StandardSocketOption.SO_REUSEADDR, true)
            .bind(new InetSocketAddress(0));
        InetAddress group = InetAddress.getByName("ff02::a");
        NetworkInterface ni = NetworkInterface.getByName("eth0");
        InetAddress source = InetAddress.getByName("::1");
        try {
            dc.join(group, ni, source);
        } catch (Exception x) { }

        dc.close();
    }
}

$ java Test
java.lang.NullPointerException
    at sun.nio.ch.MembershipRegistry.invalidateAll(MembershipRegistry.java:123)
    at sun.nio.ch.DatagramChannelImpl.implCloseSelectableChannel(DatagramChannelImpl.java:963)
    at java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(AbstractSelectableChannel.java:218)
    at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:111)

Comments
EVALUATION This bug was fixed as part of update to the socket-channel API via 6781363.
16-02-2009

EVALUATION Attempting to join an IPv6 multicast group for source-specific membership always fails on Linux with UnsupportedOperationException because of reliability issues with the IPv6 stack on that platform (UOE is allowed by the spec). This results in a case where the membership registry is created but isn't initialized by any memberships. Trivial fix.
16-09-2008