-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
At least 2 defects in javalib Collectors#joiner method #3409
Comments
Later: I re-wrote the test so that it can execute without knowing the accumulator implementation type.
|
A fix for this issue is ready a day or two after |
…cala-native#3421) (cherry picked from commit 5b5db37)
Whilst studying the ripples of PR #3396, I discovered two defects in the javalib
Colectors#joining
method(s).The first is user visible, albeit hard to provoke: the
combiner.apply(arg1, arg2)
function fail the deliminatorwith which the collector was created between arg1 & arg2.
(For the detail oriented, the collector can not be created with a null deliminator, but it can be created with
an empty string as the deliminator. It is hard to distinguish the cases of the empty string not being added
and it having been properly added. Other deliminators are clearly visible to the determined.)
Imagine the case of
Collectors.joining("|")
. A currently private test gives the expected results on JVM butfails on Scala Native:
The second defect is visible to people wanting to use the
Collector.joining#merge
method. Normally, thiswould be either nobody or library writers.
Reverse engineering (but not looking at the JDK code) shows that JVM
uses a
StringJoiner
for the accumulator A method in[T, A, R]
. Scala Native uses aStringBuilder
.To be fair (& defensive),
StringJoiner
was not available when that code was written.Normally the A methods is abstract and "do not care". In the admittedly abstruse Test mentioned above, the
difference means that the same Test can not be compiled & run on both JVM and Scala Native.
Those writing implementations of parallel stream methods, say a parallel
collect()
are likely to use thecombiner
method and encounter difficulties.The text was updated successfully, but these errors were encountered: