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

SocketPermissionTest.java problematic Optional usage in joinGroupMulticastTest

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 11, 16, 17
    • core-libs
    • generic
    • generic

      The coding in SocketPermissionTest.java joinGroupMulticastTest() looks problematic :

      https://github.com/openjdk/jdk/blob/master/test/jdk/java/net/SocketPermission/SocketPermissionTest.java#L224


                    // Positive ( requires a functional network interface )
                    Optional<NetworkInterface> onif = probe().ip4MulticastInterfaces().findFirst();
                    if (!onif.isPresent()) {
                        s.setNetworkInterface(onif.get());

      In case of !onif.isPresent() , we call in the next line onif.get() , that leads always to a

      > java.util.NoSuchElementException: No value present
      > at java.util.Optional.get(Optional.java:135)
      >
      > at
      > SocketPermissionTest.joinGroupMulticastTest(SocketPermissionTest.java:221)

            chegar Chris Hegarty
            mbaesken Matthias Baesken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: