RFR: 8287104: AddressChangeListener thread inherits CCL and can cause memory leak for webapp-servers [v2]

Jaikiran Pai jpai at openjdk.java.net
Wed May 25 09:30:47 UTC 2022


On Tue, 24 May 2022 09:42:19 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Aleksei's review suggestion - use a better Thread name
>
> src/java.base/windows/classes/sun/net/dns/ResolverConfigurationImpl.java line 49:
> 
>> 47:     // Addresses have changed. We default to true to make sure we
>> 48:     // resolve the first time it is requested.
>> 49:     private static volatile boolean changed = true;
> 
> The field `changed` is only accessed when `synchronized` on `lock` - except for this initialization line here. I wonder if the volatile is actually needed. A better fix might be to rename it to `nochanges` and revert its semantics, which would allow to leave it initialized to false.  Or maybe just revert changes to line 49.
> Otherwise looks good to me.

Hello Daniel,

> The field changed is only accessed when synchronized on lock - except for this initialization line here. I wonder if the volatile is actually needed. 

You are right - I had missed the fact that the `loadConfig()` method gets called with the `lock` held, the same lock which is then used for updating `changed`. So making this `volatile` isn't necessary. I have undone just the `volatile` change and updated this PR.

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

PR: https://git.openjdk.java.net/jdk/pull/8827


More information about the net-dev mailing list