On Wed, 25 May 2022 10:16:54 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

> > Thinking more about it: `IllegalStateException` is fine for a closed 
> > `MemorySession`. If used by wrong thread the exception was indeed 
> > confusing. Now that the abiguity is gone, I can change our (Lucene) code 
> > and just transform every ISE to an already closed in our code. I just 
> > wanted to bring up that issue here.
> > PR is here: [apache/lucene#912](https://github.com/apache/lucene/pull/912)
> 
> I've been thinking something similar. I'd suggest to keep the API as is, and 
> maybe revise it at a later point if lack of a specific exception for the 
> "already closed" case proves to be too cumbersome to workaround.

Basically, with this patch you only get ISE if you are accessing _in a moment 
in time_ when you are not supposed to. Similarly, when calling `close`, you get 
ISE if you are closing a segment that is in a bad state (e.g. already closed, 
or temporarily locked by some native call). This feels consistent. The 
confinement exception was the confounding factor, I think, and a lot of checks 
against the exception message came from there.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8865

Reply via email to