RFR: 8332623: Remove setTTL()/getTTL() methods from DatagramSocketImpl/MulticastSocket and MulticastSocket.send(DatagramPacket, byte)
Alan Bateman
alanb at openjdk.org
Wed Jun 11 10:30:34 UTC 2025
On Wed, 11 Jun 2025 10:05:28 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> Can I please get a review of this change which proposes to remove the deprecated-for-removal methods from `MulticastSocket` and `DatagramSocketImpl`?
>
> The following methods on `java.net.MulticastSocket` and `java.net.DatagramSocketImpl`:
>
>
> public void setTTL(byte ttl) throws IOException
> public byte getTTL() throws IOException
>
>
> and this other one on `MulticastSocket`:
>
>
> public void send(DatagramPacket p, byte ttl) throws IOException
>
>
> have been deprecated for removal since Java 23, through https://bugs.openjdk.org/browse/JDK-8332181. Even before that they have been deprecated since Java 1.2 and Java 1.4.
>
> The commit in this PR removes them completely. This PR also removes some tests that were specifically testing the `setTTL()/getTTL()/send(DatagramPacket, byte)` methods. A few other tests have been adjusted to use the alternate `getTimeToLive()/setTimeToLive()` methods where appropriate.
>
> Existing tests in tier1, tier2 and tier3 continue to pass with these changes.
test/jdk/java/net/MulticastSocket/SetTTLTo0.java line 26:
> 24: /* @test
> 25: * @bug 4148757
> 26: * @summary Make sure MulticastSocket.setTimeToLive() can be set to 0
I think the original okay as this test just checks that you are set the TTL to 0.
test/jdk/java/nio/channels/DatagramChannel/AdaptorMulticasting.java line 410:
> 408: DatagramPacket p = new DatagramPacket(message, message.length);
> 409: p.setSocketAddress(target);
> 410: final int oldTTL = s.getTimeToLive();
Just replacing it with s.send(p) should be okay here, no need to set/restore TTL.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25744#discussion_r2139782287
PR Review Comment: https://git.openjdk.org/jdk/pull/25744#discussion_r2139778959
More information about the net-dev
mailing list