RFR: JDK-8297299 SequenceInputStream should not use Vector [v2]
Markus KARG
duke at openjdk.org
Sun Nov 20 13:10:18 UTC 2022
On Sun, 20 Nov 2022 12:06:55 GMT, Markus KARG <duke at openjdk.org> wrote:
>> The updated code now changes the behaviour in the other direction:
>>
>> In the original code, if `s2` was null a NPE was thrown in `peekNextStream` when `s1` was exhausted.
>>
>> In the current code, `s2` is silently ignored if it is null.
>>
>> A safer alternative that preserves the behaviour of nulls seems to be the replace `List.of` with `Arrays.asList`.
>>
>> These subtle changes in behaviour demonstrates the problem with even trivial updates to legacy code...
>
> It depends on *how far* we want to align the behavior. I do see a benefit in accepting `s2` being `null`. I do not see a benefit in throwing NPE at a *later* time. Why should an application want to expect that? I do understand your opinion but I think that backwards compatibility also should have limits, and in this particular case I would say such a limit is clearly reached. Otherwise we must not replace Vector at all, because someone could actually rely on the synchronization, also.
@AlanBateman WDYT?
-------------
PR: https://git.openjdk.org/jdk/pull/11249
More information about the core-libs-dev
mailing list