test/jdk/java/net/SocketPermission/SocketPermissionTest.java question about Optional usage in joinGroupMulticastTest()
Baesken, Matthias
matthias.baesken at sap.com
Tue Jul 6 14:15:47 UTC 2021
Hi Daniel, thanks for confirming , I opened
https://bugs.openjdk.java.net/browse/JDK-8269919
JDK-8269919: SocketPermissionTest.java problematic Optional usage in joinGroupMulticastTest
Best regards, Matthias
-----Original Message-----
From: Daniel Fuchs <daniel.fuchs at oracle.com>
Sent: Dienstag, 6. Juli 2021 16:02
To: Baesken, Matthias <matthias.baesken at sap.com>; net-dev at openjdk.java.net
Cc: Zeller, Arno <arno.zeller at sap.com>
Subject: Re: test/jdk/java/net/SocketPermission/SocketPermissionTest.java question about Optional usage in joinGroupMulticastTest()
Thanks Matthias,
It does look like a bug. We probably have at least one
IPv4 multicast interfaces on all machines in our CI!
Not sure whether randomly selecting the first one is such
a good idea though - we may have to investigate how
stable the test gets if we fix this...
best regards,
-- daniel
On 06/07/2021 13:26, Baesken, Matthias wrote:
> Hi , I wonder about the coding in SocketPermissionTest.java
> joinGroupMulticastTest() :
>
> https://github.com/openjdk/jdk/blob/master/test/jdk/java/net/SocketPermission/SocketPermissionTest.java#L224
> <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)
>
> Is this really intended ? Should it be if (onif.isPresent()) {..} ?
>
> Best regards, Matthias
>
More information about the net-dev
mailing list