Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8032451

(dc) DatagramChannel.join should support include-mode filtering on OS X

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 9
    • 7u45
    • core-libs
    • b03
    • os_x

    Description

      FULL PRODUCT VERSION :
      js$ java -version
      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      js$ sw_vers
      ProductName:Mac OS X
      ProductVersion:10.7.5
      BuildVersion:11G63b


      A DESCRIPTION OF THE PROBLEM :
      Subscribing to source-specific multicast with an IP4 configured network address fails with the following exception:

      Exception in thread "Thread-1" java.lang.UnsupportedOperationException
      at sun.nio.ch.DatagramChannelImpl.innerJoin(DatagramChannelImpl.java:869)
      at sun.nio.ch.DatagramChannelImpl.join(DatagramChannelImpl.java:896)

      The join method is called with the following Java init code:

                  NetworkInterface nif = getNetworkInterface();
                  InetAddress groupa = InetAddress.getByName(ip);
                  DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)
                          .setOption(StandardSocketOptions.SO_REUSEADDR, true)
                          .bind(new InetSocketAddress(port))
                          .setOption(StandardSocketOptions.IP_MULTICAST_IF, nif);
                  dc.configureBlocking(false);
                  for (String source : sources) {
                      InetAddress sourcea = InetAddress.getByName(source);
                      MembershipKey key = dc.join(groupa, nif, sourcea);
                  }

      ip is set to a value such as "232.1.1.5", port is set to a value such as '9991' and source is set to a value such as '10.0.1.200'

      javadocs at http://docs.oracle.com/javase/7/docs/api/java/nio/channels/DatagramChannel.html show similar invocation sequence.

      The same code works on linux and windows platforms without the exception so it sounds likely the native C code for Java_sun_nio_ch_Net_joinOrDrop4 has specific code for MACOSX.



      ADDITIONAL REGRESSION INFORMATION:
      Source-Specific Multicast (SSM) via DatagramChannel class is available only in JDK7 so I cannot say this would have ever worked on macos before.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      My expectation is that no exception would be thrown and subscription via the 3 parameter join() is supported on macos.

      ACTUAL -
      Exception in thread "Thread-1" java.lang.UnsupportedOperationException
      at sun.nio.ch.DatagramChannelImpl.innerJoin(DatagramChannelImpl.java:869)
      at sun.nio.ch.DatagramChannelImpl.join(DatagramChannelImpl.java:896)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      I have tested this C code to work correctly on macos so I would suggest the same source code would find its way to the Java_sun_nio_ch_Net_joinOrDrop4.c source code for JVM.

          struct ip_mreq_source imsr;
          memset(&imsr, 0, sizeof(imsr));
          imsr.imr_multiaddr.s_addr = inet_addr(g_addr_s);
          imsr.imr_sourceaddr.s_addr = inet_addr(s_addr_s);
          imsr.imr_interface.s_addr = INADDR_ANY;


          err = setsockopt(con->fd, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP,
                        (char*) &imsr, sizeof(imsr));

      Attachments

        Issue Links

          Activity

            People

              alanb Alan Bateman
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: