[ https://issues.apache.org/jira/browse/LANG-1430?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16745107#comment-16745107 ]
Frans Verhoef edited comment on LANG-1430 at 1/17/19 2:26 PM: -------------------------------------------------------------- Caused me some work to figure out, as suddenly with version 3.8.1 our code was not working anymore, as the contract had changed. was (Author: fverhoef): Cause me some work to figure out, as suddenly with version 3.8.1 our code was not working anymore, as the contract had changed. > 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, 3.8.1 > Reporter: Frans Verhoef > Priority: Minor > > 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 at line 175/176 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)