[ 
https://issues.apache.org/jira/browse/LUCENE-7796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15979298#comment-15979298
 ] 

Hoss Man commented on LUCENE-7796:
----------------------------------

Strawman:

* add {{Error rethrowAsUnchecked(...)}} to work the way this issue suggests it 
should
** or {{RuntimeException}} if you prefer -- no opinion, just going based on the 
cast currently done in {{Rethrow}}
** personally i think the "Sneaky" code looks sketchy as hell and would feel a 
lot more comfortable using the more obvious and easy to understand {{throw new 
RuntimeException(t)}}
* rename existing {{void rethrow(...)}} methods to {{void 
rethrowIfNonNull(...)}} (they can delegate to {{rethrowAsUnchecked}})
* some existing type specific impls (like the {{IOException}} version in 
{{IOUtils}} can/should probably be renamed to be clear what they're for and 
have javadoc (links back to the "main" versions) justifying their differences

bq. A cleanup of other "rethrow-hack" places would require moving Rethrow from 
test utils back to the core and I think (but didn't look further) we actually 
moved it the other way around so as to prevent people from using it... So I'm a 
bit lost as to which direction I should go with this patch

If the idiom/code is in use (outside of tests), then the code is in use -- we 
could consider those usages "bugs" and "fix" the code to not need a 
{{reThrow(...)}} type function, but as long as that code is going to exist, 
having one copy of it (in core) seems better then having 2,3,5,100 copies of it.

bq. // TODO: remove the impl in test-framework, this one is more elegant :-)

wait ... am i missing something? aren't those 2 impls identical?????

> Make reThrow idiom declare RuntimeException return type so callers may use it 
> in a way that compiler knows subsequent code is unreachable
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-7796
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7796
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Dawid Weiss
>            Assignee: Dawid Weiss
>            Priority: Trivial
>             Fix For: 6.x, master (7.0)
>
>
> A spinoff from LUCENE-7792: reThrow can be declared to return an unchecked 
> exception so that callers can choose to use {{throw reThrow(...)}} as an 
> idiom to let the compiler know any subsequent code will be unreachable.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to