Skip to content

Commit fb04376

Browse files
committed
SI-9072 Vector ++ concatenation of parallel collection cause inconsistent results
1 parent d395e52 commit fb04376

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/library/scala/collection/immutable/Vector.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ override def companion: GenericCompanion[Vector] = Vector
215215
import Vector.{Log2ConcatFaster, TinyAppendFaster}
216216
if (that.isEmpty) this.asInstanceOf[That]
217217
else {
218-
val again = if (!that.isTraversableAgain) that.toVector else that
218+
val again = if (!that.isTraversableAgain) that.toVector else that.seq
219219
again.size match {
220220
// Often it's better to append small numbers of elements (or prepend if RHS is a vector)
221221
case n if n <= TinyAppendFaster || n < (this.size >> Log2ConcatFaster) =>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package scala.collection.immutable
2+
3+
import org.junit.{Assert, Test}
4+
import org.junit.runner.RunWith
5+
import org.junit.runners.JUnit4
6+
7+
@RunWith(classOf[JUnit4])
8+
class VectorTest {
9+
/**
10+
* Test Vector ++ with a small parallel collection concatenation (SI-9072).
11+
*
12+
*/
13+
@Test
14+
def testPlusPlus(): Unit = {
15+
val smallVec = (0 to 1)
16+
val smallParVec = smallVec.par
17+
val testElementsSize = (0 to 1000).map( _ => Vector.empty ++ smallParVec )
18+
Assert.assertTrue(testElementsSize.forall( v => v.size == 2 ))
19+
}
20+
}

0 commit comments

Comments
 (0)