Skip to content

Commit

Permalink
[Fix #3460] Fix ClassCastException on Exception mapping (#3461)
Browse files Browse the repository at this point in the history
* [Fix #3460] Fix ClassCastException on Exception mapping

* Revert "[Fix #3460] Fix ClassCastException on Exception mapping"

This reverts commit 6f729ff.

* [Fix #3460] Conservative approach
  • Loading branch information
fjtirado authored Apr 5, 2024
1 parent 73b0e84 commit 19e3630
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,13 @@ private <R> Function<R, T> fromErrorCode(String errorCode) {
public <R extends Exception, U> T mapException(R exception) {
FunctionHolder<T, U> holder = (FunctionHolder<T, U>) mapper.getOrDefault(exception.getClass(), defaultHolder);
U body = holder.getContentGenerator().apply(exception);
if (exception instanceof ProcessInstanceExecutionException || exception instanceof WorkItemExecutionException) {
Throwable rootCause = exception.getCause();

while (rootCause != null) {
if (mapper.containsKey(rootCause.getClass())) {
holder = (FunctionHolder<T, U>) mapper.get(rootCause.getClass());
break;
}
rootCause = rootCause.getCause();
Throwable rootCause = exception.getCause();
while (rootCause != null) {
if (mapper.containsKey(rootCause.getClass())) {
holder = (FunctionHolder<T, U>) mapper.get(rootCause.getClass());
exception = (R) rootCause;
}
rootCause = rootCause.getCause();
}
return holder.getResponseGenerator().apply(exception).apply(body);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void execute404() {
.accept(ContentType.JSON).when()
.post("/serviceNotFound")
.then()
.statusCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
.statusCode(HttpURLConnection.HTTP_NOT_FOUND);
}

@Test
Expand Down

0 comments on commit 19e3630

Please sign in to comment.