uschindler opened a new pull request, #12705: URL: https://github.com/apache/lucene/pull/12705
See the dev thread by @msokolov @ https://lists.apache.org/thread/qts8wvrjs54gkgz04pk4p93fg0wjbq3o The handling of NPE is very special in ByteBufferIndexInput and also MemorySegmentIndexInput: To signal a closed input we set the buffers to NULL so any code trying to work on the inputs hits an NullPointerException. This is to avoid any null checks or isOpen checks everywhere in the code, which might be expensive, as the variable/field is not constant. But it must on the other hand be avoided that the NPE gets visible outside of the IndexInputs, because it looks like a buggy null checks and may cause support issues. So we have to hide it by all means, as the NPE is *not* an error but a signal that the IndexInput was closed. There are a few cases where a real NPE can still happen, e.g., when somebody accidentally passes a null array to one of the read methods. In that case the NPE is important and should be thrown from the visibility of the caller. The workaround here to not add the NPE as a cause (and making it visible to call er outside code) is to do a safety check: If the NPE is catched, the code now checks that the "closed" condition applies (buffers are null or the byte buffer guard is invalided). If and only if the closed check is right, it throws AlreadyCosedException. In all other cases it rethrows the original NPE. I alos added a test which failed before my change. The changes were applied to all MemorySegmentIndexInput variants in the MR JAR and the original ByteBufferIndexInput (+ its guard). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org