Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 4d95f75

Browse files
committed
SPARK-5984: Fix TimSort bug causes ArrayOutOfBoundsException
1 parent 479a106 commit 4d95f75

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

core/src/test/java/org/apache/spark/util/collection/TestTimSort.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
import java.util.*;
44

55
/**
6-
* This codes generates a int array which fails the standard TimSort, Borrowed from
7-
* the reporter of this bug.
6+
* This codes generates a int array which fails the standard TimSort.
87
*
8+
* The blog that reported the bug
99
* http://www.envisage-project.eu/timsort-specification-and-verification/
10+
*
11+
* The algorithms to reproduce the bug is obtained from the reporter of the bug
12+
* https://github.com/abstools/java-timsort-bug
13+
*
14+
* Licensed under Apache License 2.0
15+
* https://github.com/abstools/java-timsort-bug/blob/master/LICENSE
1016
*/
1117
public class TestTimSort {
1218

core/src/test/scala/org/apache/spark/util/collection/SorterSuite.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ class SorterSuite extends FunSuite {
6565
}
6666
}
6767

68-
test("bug of TimSort") {
68+
// http://www.envisage-project.eu/timsort-specification-and-verification/
69+
test("SPARK-5984 TimSort bug") {
6970
val data = TestTimSort.getTimSortBugTestSet(67108864)
7071
new Sorter(new IntArraySortDataFormat).sort(data, 0, data.length, Ordering.Int)
71-
(0 to data.length - 2).foreach(i => assert(data(i) <= data(i+1)))
72+
(0 to data.length - 2).foreach(i => assert(data(i) <= data(i + 1)))
7273
}
7374

7475
/** Runs an experiment several times. */

0 commit comments

Comments
 (0)