On Sun, 27 Nov 2022 17:49:25 GMT, Markus KARG <d...@openjdk.org> wrote:

>>> I think the public visibility of my Twitter account is not wide enough to 
>>> get really robust answers, unfortunately.
>> 
>> One alternative is to search GitHub. It's amazing how fast they can search 
>> such a huge code corpus.
>> 
>> Example: 
>> https://github.com/search?l=&q=%22new+SequenceInputStream%22+-filename%3ASequenceInputStreamTest.java&type=code
>> 
>> One problem with GitHub search is that often you get a lot of duplicate 
>> matches. In the example above I have filtered out 
>> `SequenceInputStreamTest.java` which showed up a lot.
>
> Twitter survey results after one week: 5.4% of all voters have actually used 
> SIS before! This number is big enough to consider SIS as "not irrelevant". 
> OTOH this number is so small that any further poll whether this 5.4% actually 
> used the one-arg or two-arg constructor would not provide stable results. 
> Looking at the results of @jensli's GitHub search tells us that apparently 
> *all* of those findings are using 2-args. So we actually need to be careful, 
> not to break (up to) 5.4% of all existing applications.
> 
> So what could be our plan to improve the live of that 5.4%? Some thoughts:
> 1. We could safely add a `public InputStream concat(InputStream)` *default 
> method* to `InputStream` as a factory for *anonymous* sequences. This allows 
> any IS implementation to provide an optimized variant if needed/wanted, 
> falling back to the existing SIS *by default* as a starting point (until we 
> come up with a better fallback implementation).
> 2. Having done that, we could deprecate-for-removal SIS with the clear note 
> that from now on `concat` should be used instead. This triggers people to 
> overhaul their existing code little by little, while we gain time to work on 
> a replacement for SIS.
> 3. We then could provide a **non-public** `ConcatenatedInputStream` which 
> holds **exactly two** IS (`first` and `last` MUST be given), and make that 
> one the default implementation of `concat`, gaining a modern, 
> easy-to-maintain, fully tested, high-performance, sequence of streams.
> 4. Some fine day we do remove SIS, effectively getting rid of the discussed 
> quirky behavior.
> 
> @AlanBateman How does that sound? Shall I go on with a PR for step 1.?

I did a search of 30M classes in 130k artifacts from Maven Central and it found 
usages in 1670 classes in 852 artifacts. I haven't dug into it too closely but 
it looks like the usages are mostly (if not all) the 2-arg constructor.

If you have the cycles, then prototyping a _concat_ method (you could try both 
instance and static) would help inform on issues and whether this is worth 
doing. Adding methods to older, and widely used, classes such as InputStream 
will often encounter compatibility issues. For the instance method you'll need 
to think about security/snooping issues. I think it would also be useful to 
survey libraries that provide an equivalent and if there is much usage.

SIS may be legacy but I don't think there is a case to deprecate it at this 
time.

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

PR: https://git.openjdk.org/jdk/pull/11249

Reply via email to