Frans Verhoef created LANG-1430:
-----------------------------------
Summary: ExceptionUtils#getRootCause(Throwable t) does not work as documented in javadoc
Key: LANG-1430
URL:
https://issues.apache.org/jira/browse/LANG-1430 Project: Commons Lang
Issue Type: Bug
Components: lang.exception.*
Affects Versions: 3.8.1, 3.8
Reporter: Frans Verhoef
In version 3.8 the following bugfix was introduced:
LANG-1364: ExceptionUtils#getRootCause(Throwable t) should return t if no lower level cause exists Thanks to Zheng Xie.
In general I agree with the consistency it brings, but now the javadocs is not agreeing with the way it actually works.
{code:java}
/**
168 * <p>Introspects the <code>Throwable</code> to obtain the root cause.</p>
169 *
170 * <p>This method walks through the exception chain to the last element,
171 * "root" of the tree, using {@link Throwable#getCause()}, and
172 * returns that exception.</p>
173 *
174 * <p>From version 2.2, this method handles recursive cause structures
175 * that might otherwise cause infinite loops. If the throwable parameter
176 * has a cause of itself, then null will be returned. If the throwable
177 * parameter cause chain loops, the last element in the chain before the
178 * loop is returned.</p>
179 *
180 * @param throwable the throwable to get the root cause for, may be null
181 * @return the root cause of the <code>Throwable</code>,
182 * <code>null</code> if null throwable input
183 */
{code}
The sentence in red should be something like:
{code:java}
If the throwable parameter has a cause of itself, then itself will be returned.{code}
As the method will not return null, but itself instead, as of the fix LANG-1364
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)