RFR: 8364434: Inconsistent BufferedContext state after GC [v3]
Nikita Gubarkov
ngubarkov at openjdk.org
Fri Aug 8 16:18:11 UTC 2025
On Thu, 7 Aug 2025 21:01:46 GMT, Alexey Ushakov <avu at openjdk.org> wrote:
>> I don't really understand how this could simplify the check.
>> For wrapping, instead of `obj == null ? null : new WeakReference<>(obj)` it would become `Optional.ofNullable(obj).flatMap(e -> Optional.of(new WeakReference<>(obj)))`.
>> And for comparing the state, it would need to repeat the same logic with special treatment of `null` refs, just replacing the null check with `isEmpty()` - is this what you meant?
>> Overall, it seems easier to me to understand the null-check version, than the one wrapped into `Optional`.
>
> Actually, state change is also oneliner, but if you think that it's too complex for understanding, let's keep the original version.
> !mbRef.flatMap(e-> Optional.ofNullable(e.get())).equals(Optional.ofNullable(obj));
Actually, that version wouldn't work, as it doesn't distinguish between null ref itself and null ref value. So yes, let's better keep the null checks
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26576#discussion_r2263422407
More information about the client-libs-dev
mailing list