Protect against Exceptions in ResultHandler code

This commit is contained in:
Eric Bottard
2017-09-17 20:59:27 +02:00
parent 12dff36d8b
commit 076a183d08
2 changed files with 8 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ import org.springframework.shell.ResultHandler;
*
* @author Eric Bottard
*/
public abstract class TerminalAwareResultHandler<T> implements ResultHandler<T> {
public abstract class TerminalAwareResultHandler<T> implements ResultHandler<T> {
protected Terminal terminal;
@Autowired @Lazy

View File

@@ -47,7 +47,13 @@ public class TypeHierarchyResultHandler implements ResultHandler<Object> {
}
Class<?> clazz = result.getClass();
ResultHandler handler = getResultHandler(clazz);
handler.handleResult(result);
try {
handler.handleResult(result);
}
catch (Exception e) {
// Protect against exceptions happening in ResultHandlers
getResultHandler(e.getClass()).handleResult(e);
}
}
private ResultHandler getResultHandler(Class<?> clazz) {