8234083: DatagramSocket should report SO_BROADCAST as a supported option
authorpconcannon
Thu, 21 Nov 2019 16:33:00 +0000
changeset 59206 61091a42f19d
parent 59205 afcc8af048e6
child 59207 7a3218ad8e7c
8234083: DatagramSocket should report SO_BROADCAST as a supported option Summary: DatagramSocket had a setBroadcast and getBroadcast setter/getter pair but curiously didn't report SO_BROADCAST as a supported option. Note: the source code changes were accidentally pushed with 8234103 so this changeset only has the test changes. The reviewers listed below had already reviewed the full (source+test) changes. Reviewed-by: alanb, vtewari, chegar
test/jdk/java/net/SocketOption/OptionsTest.java
--- a/test/jdk/java/net/SocketOption/OptionsTest.java	Thu Nov 21 12:14:29 2019 +0000
+++ b/test/jdk/java/net/SocketOption/OptionsTest.java	Thu Nov 21 16:33:00 2019 +0000
@@ -84,12 +84,16 @@
         Test.create(StandardSocketOptions.SO_RCVBUF, Integer.valueOf(8 * 100)),
         Test.create(StandardSocketOptions.SO_REUSEADDR, Boolean.FALSE),
         Test.create(StandardSocketOptions.SO_REUSEPORT, Boolean.FALSE),
+        Test.create(StandardSocketOptions.SO_BROADCAST, Boolean.FALSE),
+        Test.create(StandardSocketOptions.SO_BROADCAST, Boolean.TRUE),
         Test.create(StandardSocketOptions.IP_TOS, Integer.valueOf(0)),  // lower-bound
         Test.create(StandardSocketOptions.IP_TOS, Integer.valueOf(100)),
         Test.create(StandardSocketOptions.IP_TOS, Integer.valueOf(255))  //upper-bound
     };
 
     static Test<?>[] multicastSocketTests = new Test<?>[] {
+        Test.create(StandardSocketOptions.SO_BROADCAST, Boolean.FALSE),
+        Test.create(StandardSocketOptions.SO_BROADCAST, Boolean.TRUE),
         Test.create(StandardSocketOptions.IP_MULTICAST_IF, getNetworkInterface()),
         Test.create(StandardSocketOptions.IP_MULTICAST_TTL, Integer.valueOf(0)),   // lower-bound
         Test.create(StandardSocketOptions.IP_MULTICAST_TTL, Integer.valueOf(10)),
@@ -285,6 +289,8 @@
                 return Integer.valueOf(socket.getReceiveBufferSize());
             } else if (option.equals(StandardSocketOptions.SO_REUSEADDR)) {
                 return Boolean.valueOf(socket.getReuseAddress());
+            } else if (option.equals(StandardSocketOptions.SO_BROADCAST)) {
+                return Boolean.valueOf(socket.getBroadcast());
             } else if (option.equals(StandardSocketOptions.SO_REUSEPORT) && reuseport) {
                 return Boolean.valueOf(socket.getOption(StandardSocketOptions.SO_REUSEPORT));
             } else if (option.equals(StandardSocketOptions.IP_TOS)) {
@@ -304,6 +310,8 @@
                 return Integer.valueOf(socket.getReceiveBufferSize());
             } else if (option.equals(StandardSocketOptions.SO_REUSEADDR)) {
                 return Boolean.valueOf(socket.getReuseAddress());
+            } else if (option.equals(StandardSocketOptions.SO_BROADCAST)) {
+                return Boolean.valueOf(socket.getBroadcast());
             } else if (option.equals(StandardSocketOptions.SO_REUSEPORT) && reuseport) {
                 return Boolean.valueOf(socket.getOption(StandardSocketOptions.SO_REUSEPORT));
             } else if (option.equals(StandardSocketOptions.IP_TOS)) {