RFR: 8332623: Remove setTTL()/getTTL() methods from DatagramSocketImpl/MulticastSocket and MulticastSocket.send(DatagramPacket, byte) [v2]

Jaikiran Pai jpai at openjdk.org
Wed Jun 11 10:42:12 UTC 2025


On Wed, 11 Jun 2025 10:23:54 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request incrementally with three additional commits since the last revision:
>> 
>>  - no need to setTimeToLive() in AdaptorMulticasting test
>>  - undo change to "@summary" of a test
>>  - remove sendLock
>
> src/java.base/share/classes/sun/nio/ch/DatagramSocketAdaptor.java line 564:
> 
>> 562:     @SuppressWarnings("removal")
>> 563:     public void send(DatagramPacket p, byte ttl) throws IOException {
>> 564:         sendLock.lock();
> 
> sendLock can be removed too, it's only need because of this send method.

I hadn't noticed that. I have removed it now and updated the PR.

> 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.

Done - reverted the `@summary` to the original one.

> 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.

Done.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25744#discussion_r2139801248
PR Review Comment: https://git.openjdk.org/jdk/pull/25744#discussion_r2139802233
PR Review Comment: https://git.openjdk.org/jdk/pull/25744#discussion_r2139801483


More information about the nio-dev mailing list