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

MulticastSocket.setTimeToLive is broken on mac os X

XMLWordPrintable

    • x86
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_40"
      Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

      (also tested java 9 from source code)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin mac2 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64


      A DESCRIPTION OF THE PROBLEM :
      This is the exact same bug as https://bugs.openjdk.java.net/browse/JDK-6250763, which was only fixed on Linux.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Join a multicast group on some other machine.

      Then, use client code to specify time to live of zero, which should never leave the machine, but its completely ignored and does.

      Or reuse tests from JDK-6250763

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      setTimeToLive should work
      ACTUAL -
      setTimeToLive is completely ignored. I Looked at the code, apparently it was coded for solaris, and then the linux case was ifdef'ed.

      Guys, its solaris thats the wierd one, special case it instead :)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
        // join a multicast group on another machine to ensure you see the packets

        public static void main(String args[]) throws Exception {
          MulticastSocket socket = new MulticastSocket();
          socket.setTimeToLive(0); // has no impact unless jvm flag -Djava.net.preferIPv4Stack=true
          SocketAddress destination = new InetSocketAddress(InetAddress.getByName("224.2.2.4"), 44444);
          socket.joinGroup(destination, null);
          socket.send(new DatagramPacket("abcd".getBytes(), 4, destination));
          socket.close();
        }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      -Djava.net.preferIPv4Stack=true is *not* really a workaround, as it totally prevents ipv6 from working. Its wrongly named, it should have been called -Djava.net.forceIPv4Stack

            robm Robert Mckenna
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: