Skip to content

Commit 69a2ccf

Browse files
committed
unwrap CompletionException
1 parent 2d28c8d commit 69a2ccf

File tree

1 file changed

+11
-1
lines changed
  • hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/util

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,17 @@ public static <T> T callAs(Subject subject, Callable<T> action) throws Completio
149149
* @return the result of the action
150150
*/
151151
public static <T> T doAs(Subject subject, PrivilegedAction<T> action) {
152-
return callAs(subject, privilegedActionToCallable(action));
152+
try {
153+
return callAs(subject, privilegedActionToCallable(action));
154+
} catch (CompletionException ce) {
155+
Exception cause = (Exception) (ce.getCause());
156+
if (cause != null) {
157+
throw sneakyThrow(cause);
158+
} else {
159+
// This should never happen, as CompletionException should always wrap an exception
160+
throw ce;
161+
}
162+
}
153163
}
154164

155165
/**

0 commit comments

Comments
 (0)