import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
/**
* The {@link ExceptionUtils} class defines some static utility methods
@NonNullByDefault
public class ExceptionUtils {
- public static @Nullable Throwable getRootThrowable(@Nullable Throwable throwable) {
+ public static Throwable getRootThrowable(Throwable throwable) {
List<Throwable> list = new ArrayList<>();
- while (throwable != null && !list.contains(throwable)) {
+ while (!list.contains(throwable)) {
list.add(throwable);
- throwable = throwable.getCause();
+ Throwable throwableLocal = throwable.getCause();
+ if (throwableLocal != null) {
+ throwable = throwableLocal;
+ }
}
return throwable;
}