RFR: 8287206: Use WrongThreadException for confinement errors

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed May 25 10:18:55 UTC 2022


On Tue, 24 May 2022 09:26:44 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This patch tweaks the foreign API to use the newly added `WrongThreadException` instead of `IllegalStateException` to report confinement errors.

> 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.

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

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


More information about the nio-dev mailing list