You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bu...@apache.org on 2019/06/04 16:48:41 UTC

[hbase] branch branch-2.2 updated: HBASE-22536 TestForeignExceptionSerialization fails when run on JDK11

This is an automated email from the ASF dual-hosted git repository.

busbey pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.2 by this push:
     new f37a249  HBASE-22536 TestForeignExceptionSerialization fails when run on JDK11
f37a249 is described below

commit f37a2495e554072f8a9a7b41525c1d7d1fd48e70
Author: Sakthi <sa...@gmail.com>
AuthorDate: Mon Jun 3 22:47:27 2019 -0700

    HBASE-22536 TestForeignExceptionSerialization fails when run on JDK11
    
    Signed-off-by: Sean Busbey <bu...@apache.org>
    (cherry picked from commit 2280c8f4a88350278447515deb0811c42d0bb476)
---
 .../TestForeignExceptionSerialization.java            | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/errorhandling/TestForeignExceptionSerialization.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/errorhandling/TestForeignExceptionSerialization.java
index 127e72f..6b6ef0c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/errorhandling/TestForeignExceptionSerialization.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/errorhandling/TestForeignExceptionSerialization.java
@@ -17,12 +17,13 @@
  */
 package org.apache.hadoop.hbase.errorhandling;
 
-import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
+import java.util.Objects;
+
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.testclassification.MasterTests;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -75,7 +76,15 @@ public class TestForeignExceptionSerialization {
     assertTrue(generic.getMessage().contains(errorMsg));
 
     ForeignException e = ForeignException.deserialize(ForeignException.serialize(srcName, generic));
-    assertArrayEquals("Local stack trace got corrupted", generic.getStackTrace(), e.getCause().getStackTrace());
+
+    // Workaround for java 11 - replaced assertArrayEquals with individual elements comparison
+    // using custom comparison helper method
+    assertEquals("Stacktrace lengths don't match", generic.getStackTrace().length,
+        e.getCause().getStackTrace().length);
+    for (int i = 0; i < generic.getStackTrace().length; i++) {
+      assertTrue("Local stack trace got corrupted at " + i + "th index",
+          compareStackTraceElement(generic.getStackTrace()[i], e.getCause().getStackTrace()[i]));
+    }
 
     e.printStackTrace(); // should have ForeignException and source node in it.
     assertTrue(e.getCause().getCause() == null);
@@ -84,4 +93,10 @@ public class TestForeignExceptionSerialization {
     assertTrue(e.getCause().getMessage().contains(errorMsg));
   }
 
+  // Helper method to compare two stackTraceElements
+  private boolean compareStackTraceElement(StackTraceElement obj1, StackTraceElement obj2) {
+    return obj1.getClassName().equals(obj2.getClassName()) && obj1.getLineNumber() == obj2
+        .getLineNumber() && Objects.equals(obj1.getMethodName(), obj2.getMethodName()) && Objects
+        .equals(obj1.getFileName(), obj2.getFileName());
+  }
 }