Skip to content

Commit 00eacc4

Browse files
committed
HDFS-16702. MiniDFSCluster should report cause of exception in assertion error
1 parent 123d1aa commit 00eacc4

File tree

2 files changed

+15
-5
lines changed
  • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util
  • hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs

2 files changed

+15
-5
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ public String toString() {
9494
if (message == null) {
9595
message = super.toString();
9696
}
97-
return Integer.toString(status) + ": " + message;
97+
String finalString = status + ": " + message;
98+
Throwable cause = getCause();
99+
if (cause != null) {
100+
finalString = finalString + " : \n" + "cause: " + cause.getMessage();
101+
}
102+
return finalString;
98103
}
99104
}
100105

@@ -139,7 +144,12 @@ public String toString() {
139144
if (message == null) {
140145
message = super.toString();
141146
}
142-
return Integer.toString(status) + ": " + message;
147+
String finalString = status + ": " + message;
148+
Throwable cause = getCause();
149+
if (cause != null) {
150+
finalString = finalString + " : \n" + "cause: " + cause.getMessage();
151+
}
152+
return finalString;
143153
}
144154

145155
}

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,10 +2159,10 @@ public void shutdown(boolean deleteDfsDir, boolean closeFileSystem) {
21592159
LOG.info("Shutting down the Mini HDFS Cluster");
21602160
if (checkExitOnShutdown) {
21612161
if (ExitUtil.terminateCalled()) {
2162-
LOG.error("Test resulted in an unexpected exit",
2163-
ExitUtil.getFirstExitException());
2162+
ExitUtil.ExitException exitException = ExitUtil.getFirstExitException();
2163+
LOG.error("Test resulted in an unexpected exit", exitException);
21642164
ExitUtil.resetFirstExitException();
2165-
throw new AssertionError("Test resulted in an unexpected exit");
2165+
throw new AssertionError("Test resulted in an unexpected exit", exitException);
21662166
}
21672167
}
21682168
if (closeFileSystem) {

0 commit comments

Comments
 (0)