Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public static <T> T doAs(Principal principal, PrivilegedExceptionAction<T> actio
Throwable cause = pae.getCause();
Throwables.propagateIfPossible(cause, Exception.class);
throw new RuntimeException("doAs method encountered an unexpected exception", pae);
} catch (Error t) {
LOG.warn("doAs method encountered an unexpected error", t);
throw new RuntimeException("doAs method encountered an unexpected exception", t);
} catch (Error error) {
LOG.warn("doAs method encountered an unexpected error", error);
throw error;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will be the exception when propogating to the client side?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current behavior is the server will crash.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,22 @@ public void testThread() throws Exception {
return null;
});
}

@Test
public void testErrorIsPropagated() {
UserPrincipal principal = new UserPrincipal("testErrorIsPropagated");
AssertionError error = new AssertionError("test error");

AssertionError thrown =
Assertions.assertThrows(
AssertionError.class,
() ->
PrincipalUtils.doAs(
principal,
() -> {
throw error;
}));

Assertions.assertSame(error, thrown);
}
}
Loading