SocketPermissionTest.java problematic Optional usage in joinGroupMulticastTest

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 11, 16, 17
    • Component/s: 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)

            Assignee:
            Chris Hegarty
            Reporter:
            Matthias Baesken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: