[
https://issues.apache.org/jira/browse/LUCENE-7796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15984637#comment-15984637
]
Dawid Weiss commented on LUCENE-7796:
-------------------------------------
bq. Are you really sure exceptions are never null in all these places?
I have reviewed it manually (and will again, if there's an agreement on this).
The tests pass -- I ran it a few times now.
bq. Why not add the new method, and deprecate the old one?
Yes, that's my "less radical" approach -- I planned this for 6x. But we can as
well do this on master, no problem there.
bq. Is there a strong technical reason to remove the deprecated method from
master or is it just "but that doesnt seem right to have one there"? Its a
million times more important to not introduce bugs in exception handling.
I removed it because I wanted to make sure it's not used in the code. And I did
review those existing usages on a case-by-case basis (there were about ~50 of
them). I'm also concerned about correctness and it's true that this patch
touches code paths that are very likely not frequently (or at all) touched in
tests. Hence manual review.
Also note that just about the only difference that can happen is passing null
to that method (which no longer accepts it), which I tried to guard against in
all places I wasn't 100% sure about non-null argument. Even if you don't use
the return type (i.e., you don't use the {{throw}}), the call to this new
method is not going to be ignored (it'll always throw an exception on non-null
argument, just like previously).
So the chances of screwing up are there, sure, but they seem minimal.
> 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)
>
> Attachments: LUCENE-7796.patch
>
>
> 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]