[ https://issues.apache.org/jira/browse/LANG-1726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17803352#comment-17803352 ]
Niall Pemberton commented on LANG-1726: --------------------------------------- Václav has identified the main issue. It looks like the intention of the original commit was to simply rename the method, I assume the intention was to make it more understandable as to what it does, but there are two problems with it # The return type was incorrectly from <T> to <T extends RuntimeException> which makes it unusable since the return type must match the return type of the calling method which will not be a RuntimeException # The original _*rethrow*_ method name accurately described what it did (it rethrows the original exception, but tricks the compiler into thinking its a RuntimeException). Changing the name to _*asRuntimeException*_ introduces a confusion because it just rethrows the original exception, which may not be a RuntimeException. So, for me, the first thing is to decide what todo. Ideally IMO we should get rid of the new _*asRuntimeException*_ method. I guess since its part of a release, that means it should be deprecated with a note to use the original _*rethrow*_ method. Once its agreed what todo about this, then I think the javadoc can be corrected or improved. > ExceptionUtils.asRuntimeException is not a good replacement for deprecated > ExceptionUtils.rethrow > ------------------------------------------------------------------------------------------------- > > Key: LANG-1726 > URL: https://issues.apache.org/jira/browse/LANG-1726 > Project: Commons Lang > Issue Type: Bug > Components: lang.exception.* > Affects Versions: 3.14.0 > Reporter: Václav Haisman > Priority: Major > Fix For: 3.15.0 > > > I have been doing pass over deprecated warning in our code and one of them is > that {{org.apache.commons.lang3.exception.ExceptionUtils#rethrow}} is > deprecated. Its comment says "Use asRuntimeException(Throwable)." However, > {{asRuntimeException()}} is not a good replacement. It lacks the generic type > parameter R that the rethrow method has. In fact, the comment that says... > {noformat} > Returns: > Never actually returned, this generic type matches any type which the calling > site requires. [..] > {noformat} > ...is lying. -- This message was sent by Atlassian Jira (v8.20.10#820010)