You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "drzhonghao (via GitHub)" <gi...@apache.org> on 2023/04/28 07:02:33 UTC

[GitHub] [lucene] drzhonghao opened a new issue, #12250: MappedByteBufferIndexInputProvider can better throw UndeclaredThrowableException

drzhonghao opened a new issue, #12250:
URL: https://github.com/apache/lucene/issues/12250

   ### Description
   
   MappedByteBufferIndexInputProvider has the following code:
   
    private static BufferCleaner newBufferCleaner(final MethodHandle unmapper) {
   
   ...
   
   try {
           unmapper.invokeExact(buffer);
         } catch (Throwable t) {
           throw new IOException("Unable to unmap the mapped buffer: " + resourceDescription, t);
         }
   
    }
   This method rethrow IOException, when calling invokeExact fails. However, other methods throw UndeclaredThrowableException for the same errors. For example, SnowballProgram.find_among is as follows:
   
   protected int find_among(Among v[]) {
   
    ..,
    
   try {
             res = (boolean) w.method.invokeExact(this);
           } catch (Error | RuntimeException e) {
             throw e;
           } catch (Throwable e) {
             throw new UndeclaredThrowableException(e);
           }
   }
   Another example is AttributeFactory.createInstance
   
   :
   
    
    protected A createInstance() {
           try {
             // be explicit with casting, so javac compiles correct call to polymorphic signature:
             final AttributeImpl impl = (AttributeImpl) constr.invokeExact();
             // now cast to generic type:
             return (A) impl;
           } catch (Error | RuntimeException e) {
             throw e;
           } catch (Throwable e) {
             throw new UndeclaredThrowableException(e);
           }
         }
   
      
   UndeclaredThrowableException looks more reasonable.  Can this be fixed?
   
   ### Version and environment details
   
   _No response_


-- 
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-unsubscribe@lucene.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] uschindler commented on issue #12250: MappedByteBufferIndexInputProvider can better throw UndeclaredThrowableException

Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on issue #12250:
URL: https://github.com/apache/lucene/issues/12250#issuecomment-1585298481

   For mmapdirectory any error in the BufferClean must be treated as IOException, so the code is correct.


-- 
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-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] uschindler commented on issue #12250: MappedByteBufferIndexInputProvider can better throw UndeclaredThrowableException

Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on issue #12250:
URL: https://github.com/apache/lucene/issues/12250#issuecomment-1585296623

   This is not a bug. In reality the throwable is never thrown here because the called method never throws any exception. The catch block is only a safety guard around the stupid MethodHandle.
   
   The same applies to the other two examples.


-- 
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-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] uschindler closed issue #12250: MappedByteBufferIndexInputProvider can better throw UndeclaredThrowableException

Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler closed issue #12250: MappedByteBufferIndexInputProvider can better throw UndeclaredThrowableException
URL: https://github.com/apache/lucene/issues/12250


-- 
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-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org