Repository: calcite Updated Branches: refs/heads/master e78f8c61e -> 2b93eaa35
[CALCITE-2287] FlatList.equals() throws StackOverflowError (Zhong Yu) Close apache/calcite#682 Project: http://git-wip-us.apache.org/repos/asf/calcite/repo Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/7924eb0e Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/7924eb0e Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/7924eb0e Branch: refs/heads/master Commit: 7924eb0eb38e7955b054919788baf45f9e72cd6f Parents: 08e4322 Author: yuzhong <[email protected]> Authored: Fri Apr 27 15:05:25 2018 +0800 Committer: Julian Hyde <[email protected]> Committed: Tue May 1 02:01:32 2018 -0700 ---------------------------------------------------------------------- .../org/apache/calcite/runtime/FlatLists.java | 32 ++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/calcite/blob/7924eb0e/core/src/main/java/org/apache/calcite/runtime/FlatLists.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/calcite/runtime/FlatLists.java b/core/src/main/java/org/apache/calcite/runtime/FlatLists.java index 13c92ff..94cfce1 100644 --- a/core/src/main/java/org/apache/calcite/runtime/FlatLists.java +++ b/core/src/main/java/org/apache/calcite/runtime/FlatLists.java @@ -333,7 +333,9 @@ public class FlatLists { Flat1List that = (Flat1List) o; return Objects.equals(this.t0, that.t0); } - return Collections.singletonList(t0).equals(o); + return o instanceof List + && ((List) o).size() == 1 + && Objects.equals(t0, ((List) o).get(0)); } public int hashCode() { @@ -444,7 +446,11 @@ public class FlatLists { return Objects.equals(this.t0, that.t0) && Objects.equals(this.t1, that.t1); } - return Arrays.asList(t0, t1).equals(o); + if (o instanceof List) { + List lo = (List) o; + return lo.size() == 2 && o.equals(this); + } + return false; } public int hashCode() { @@ -574,7 +580,9 @@ public class FlatLists { && Objects.equals(this.t1, that.t1) && Objects.equals(this.t2, that.t2); } - return o.equals(this); + return o instanceof List + && ((List) o).size() == 3 + && Arrays.asList(t0, t1, t2).equals(o); } public int hashCode() { @@ -686,7 +694,7 @@ public class FlatLists { } public String toString() { - return "[" + t0 + ", " + t1 + ", " + t2 + "," + t3 + "]"; + return "[" + t0 + ", " + t1 + ", " + t2 + ", " + t3 + "]"; } public T get(int index) { @@ -723,7 +731,9 @@ public class FlatLists { && Objects.equals(this.t2, that.t2) && Objects.equals(this.t3, that.t3); } - return o.equals(this); + return o instanceof List + && ((List) o).size() == 4 + && Arrays.asList(t0, t1, t2, t3).equals(o); } public int hashCode() { @@ -851,7 +861,7 @@ public class FlatLists { } public String toString() { - return "[" + t0 + ", " + t1 + ", " + t2 + "," + t3 + ", " + t4 + "]"; + return "[" + t0 + ", " + t1 + ", " + t2 + ", " + t3 + ", " + t4 + "]"; } public T get(int index) { @@ -891,7 +901,9 @@ public class FlatLists { && Objects.equals(this.t3, that.t3) && Objects.equals(this.t4, that.t4); } - return o.equals(this); + return o instanceof List + && ((List) o).size() == 5 + && Arrays.asList(t0, t1, t2, t3, t4).equals(o); } public int hashCode() { @@ -1035,7 +1047,7 @@ public class FlatLists { } public String toString() { - return "[" + t0 + ", " + t1 + ", " + t2 + "," + t3 + ", " + t4 + return "[" + t0 + ", " + t1 + ", " + t2 + ", " + t3 + ", " + t4 + ", " + t5 + "]"; } @@ -1079,7 +1091,9 @@ public class FlatLists { && Objects.equals(this.t4, that.t4) && Objects.equals(this.t5, that.t5); } - return o.equals(this); + return o instanceof List + && ((List) o).size() == 6 + && Arrays.asList(t0, t1, t2, t3, t4, t5).equals(o); } public int hashCode() {
