Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1
-
None
-
None
-
Operating System: Windows 2000
Platform: PC
-
37038
Description
The ExceptionUtils.getThrowables(throwable) can loop for ever if
throwable.getCause() == throwable.
The following code should fix this:
public static Throwable[] getThrowables(final Throwable throwable) {
List list = new ArrayList();
if (throwable != null) {
Throwable cause = throwable.getCause();
list.add(throwable);
while (cause != null && cause != throwable)
}
return (Throwable[]) list.toArray(new Throwable[list.size()]);
}
Also, the getCauseUsingWellKnownTypes(throwable) should be enhanced to avoid the
same problems:
private static Throwable getCauseUsingWellKnownTypes(Throwable throwable) {
if (throwable instanceof Nestable && throwable.getCause() != throwable)
else if (throwable instanceof SQLException)
{ return ((SQLException) throwable).getNextException(); }else if (throwable instanceof InvocationTargetException)
{ return ((InvocationTargetException) throwable).getTargetException(); }else
{ return null; }}
Cheers
Andy