mirror of https://github.com/apache/lucene.git
MMapDirectory with MemorySegment: Confirm that scope/session is no longer alive before throwing AlreadyClosedException (#12707)
This commit is contained in:
parent
9729123369
commit
bbf197fdc2
|
@ -183,8 +183,8 @@ Improvements
|
|||
|
||||
* GITHUB#12586: Remove over-counting of deleted terms. (Guo Feng)
|
||||
|
||||
* GITHUB#12705: Improve handling of NullPointerException in MMapDirectory's IndexInputs.
|
||||
(Uwe Schindler, Michael Sokolov)
|
||||
* GITHUB#12705, GITHUB#12705: Improve handling of NullPointerException and IllegalStateException
|
||||
in MMapDirectory's IndexInputs. (Uwe Schindler, Michael Sokolov)
|
||||
|
||||
Optimizations
|
||||
---------------------
|
||||
|
|
|
@ -105,9 +105,11 @@ abstract class MemorySegmentIndexInput extends IndexInput implements RandomAcces
|
|||
AlreadyClosedException alreadyClosed(RuntimeException e) {
|
||||
// we use NPE to signal if this input is closed (to not have checks everywhere). If NPE happens,
|
||||
// we check the "is closed" condition explicitly by checking that our "curSegment" is null.
|
||||
// if it is an IllegalStateException, it can only come from MemorySegment API (other thread has
|
||||
// closed input)
|
||||
if (this.curSegment == null || e instanceof IllegalStateException) {
|
||||
if (this.curSegment == null) {
|
||||
return new AlreadyClosedException("Already closed: " + this);
|
||||
}
|
||||
// we also check if the session of all segments is still alive:
|
||||
if (Arrays.stream(segments).allMatch(s -> s.session().isAlive()) == false) {
|
||||
return new AlreadyClosedException("Already closed: " + this);
|
||||
}
|
||||
// otherwise rethrow unmodified NPE/ISE (as it possibly a bug with passing a null parameter to
|
||||
|
|
|
@ -103,9 +103,11 @@ abstract class MemorySegmentIndexInput extends IndexInput implements RandomAcces
|
|||
AlreadyClosedException alreadyClosed(RuntimeException e) {
|
||||
// we use NPE to signal if this input is closed (to not have checks everywhere). If NPE happens,
|
||||
// we check the "is closed" condition explicitly by checking that our "curSegment" is null.
|
||||
// if it is an IllegalStateException, it can only come from MemorySegment API (other thread has
|
||||
// closed input)
|
||||
if (this.curSegment == null || e instanceof IllegalStateException) {
|
||||
if (this.curSegment == null) {
|
||||
return new AlreadyClosedException("Already closed: " + this);
|
||||
}
|
||||
// we also check if the scope of all segments is still alive:
|
||||
if (Arrays.stream(segments).allMatch(s -> s.scope().isAlive()) == false) {
|
||||
return new AlreadyClosedException("Already closed: " + this);
|
||||
}
|
||||
// otherwise rethrow unmodified NPE/ISE (as it possibly a bug with passing a null parameter to
|
||||
|
|
|
@ -103,9 +103,11 @@ abstract class MemorySegmentIndexInput extends IndexInput implements RandomAcces
|
|||
AlreadyClosedException alreadyClosed(RuntimeException e) {
|
||||
// we use NPE to signal if this input is closed (to not have checks everywhere). If NPE happens,
|
||||
// we check the "is closed" condition explicitly by checking that our "curSegment" is null.
|
||||
// if it is an IllegalStateException, it can only come from MemorySegment API (other thread has
|
||||
// closed input)
|
||||
if (this.curSegment == null || e instanceof IllegalStateException) {
|
||||
if (this.curSegment == null) {
|
||||
return new AlreadyClosedException("Already closed: " + this);
|
||||
}
|
||||
// we also check if the scope of all segments is still alive:
|
||||
if (Arrays.stream(segments).allMatch(s -> s.scope().isAlive()) == false) {
|
||||
return new AlreadyClosedException("Already closed: " + this);
|
||||
}
|
||||
// otherwise rethrow unmodified NPE/ISE (as it possibly a bug with passing a null parameter to
|
||||
|
|
Loading…
Reference in New Issue