FWIW: The choice to ignore the original exception goes back to here...

https://issues.apache.org/jira/browse/LUCENE-3588

...circa 2011, where it was focused on catching NPE and throwing 
AlreadyClosedException instead, w/o any particular discussion as to why to 
throw away the original NPE.

If i had to guess it's simply because at that time AlreadyClosedException 
didn't support wrapping any other Throwable.  That wasn't added until 
LUCENE-5958 (circa 2014) which was focused on making sure "tragic" errors 
kept a record of what caused the tragedy, and then include that as the 
'cause' of the AlreadyClosedExceptions throw by 'ensureOpen()'

There didn't seem to be any discussion at that time about reviewing other 
code that might be throwing AlreadyClosedException from a 'catch' block 
that could also be updated to include the cause.

I'd say open a PR to review & update all code that results in 
AlreadyClosedException originating from a catch block?



: Date: Tue, 17 Oct 2023 11:24:03 -0400
: From: Michael Sokolov <msoko...@gmail.com>
: Reply-To: dev@lucene.apache.org
: To: Lucene Dev <dev@lucene.apache.org>
: Subject: ByteBufferIndexInput.alreadyClosed creates an exception that doesn't
:     track its cause
: 
: I was messing around with something that was resulting in
: AlreadyClosedException being thrown and I noticed that we weren't
: tracking the exception that caused it. I found this in
: ByteBufferIndexInput:
: 
:    // the unused parameter is just to silence javac about unused variables
:    AlreadyClosedException alreadyClosed(RuntimeException unused) {
: -    return new AlreadyClosedException("Already closed: " + this);
: +    return new AlreadyClosedException("Already closed: " + this, unused);
:    }
: 
: and added the cause there, which helped me find and fix my wicked
: ways. Is there a reason we decided not to wrap the "unused"
: RuntimeException there?
: 
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
: For additional commands, e-mail: dev-h...@lucene.apache.org
: 
: 

-Hoss
http://www.lucidworks.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to