From 2005582a28b47ce7aac35702c485559fd62e6a90 Mon Sep 17 00:00:00 2001 From: Steve Vaughan Date: Thu, 11 Aug 2022 16:52:39 -0400 Subject: [PATCH] HDFS-16702. MiniDFSCluster should report cause of exception in assert error (#4680) When the MiniDFSClsuter detects that an exception caused an exit, it should include that exception as the cause for the AssertionError that it throws. The current AssertError simply reports the message "Test resulted in an unexpected exit" and provides a stack trace to the location of the check for an exit exception. This patch adds the original exception as the cause of the AssertError. --- .../test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java index 484958e3c3..c4e99b1833 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java @@ -2159,10 +2159,11 @@ public void shutdown(boolean deleteDfsDir, boolean closeFileSystem) { LOG.info("Shutting down the Mini HDFS Cluster"); if (checkExitOnShutdown) { if (ExitUtil.terminateCalled()) { - LOG.error("Test resulted in an unexpected exit", - ExitUtil.getFirstExitException()); + Exception cause = ExitUtil.getFirstExitException(); + LOG.error("Test resulted in an unexpected exit", cause); ExitUtil.resetFirstExitException(); - throw new AssertionError("Test resulted in an unexpected exit"); + throw new AssertionError("Test resulted in an unexpected exit: " + + cause.toString(), cause); } } if (closeFileSystem) {