src/main/java/com/bah/lucene/blockcache/BlockCache.java
protected void freeBuffer(final ByteBuffer buffer) throws IOException {
    if (buffer == null) {
      return;
    }
    if (UNMAP_SUPPORTED) {
      try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
          @Override
          public Void run() throws Exception {
            final Method getCleanerMethod = buffer.getClass().getMethod("cleaner");
            getCleanerMethod.setAccessible(true);
            final Object cleaner = getCleanerMethod.invoke(buffer);
            if (cleaner != null) {
              cleaner.getClass().getMethod("clean").invoke(cleaner);
            }
            return null;
          }
        });
      } catch (PrivilegedActionException e) {
        final IOException ioe = new IOException("unable to unmap the mapped buffer");
        ioe.initCause(e.getCause());
        throw ioe;
      }
    }
  }
protected void freeBuffer(final ByteBuffer buffer) throws IOException {
    if (buffer == null) {
      return;
    }
    if (UNMAP_SUPPORTED) {
      try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
          @Override
          public Void run() throws Exception {
            final Method getCleanerMethod = buffer.getClass().getMethod("cleaner");
            getCleanerMethod.setAccessible(true);
            final Object cleaner = getCleanerMethod.invoke(buffer);
            if (cleaner != null) {
              cleaner.getClass().getMethod("clean").invoke(cleaner);
            }
            return null;
          }
        });
      } catch (PrivilegedActionException e) {
        final IOException ioe = new IOException("unable to unmap the mapped buffer");
        ioe.initCause(e.getCause());
        throw ioe;
      }
    }
  }
protected void freeBuffer ( final ByteBuffer buffer ) throws IOException { if ( buffer == null ) { return ; } if ( UNMAP_SUPPORTED ) { try { AccessController . doPrivileged ( new PrivilegedExceptionAction < Void > ( ) { @ Override public Void run ( ) throws Exception { final Method getCleanerMethod = buffer . getClass ( ) . getMethod ( "cleaner" ) ; getCleanerMethod . setAccessible ( true ) ; final Object cleaner = getCleanerMethod . invoke ( buffer ) ; if ( cleaner != null ) { cleaner . getClass ( ) . getMethod ( "clean" ) . invoke ( cleaner ) ; } return null ; } } ) ; } catch ( PrivilegedActionException e ) { final IOException ioe = new IOException ( "unable to unmap the mapped buffer" ) ; ioe . initCause ( e . getCause ( ) ) ; throw ioe ; } } }
This code was copied form MMAPDirectory in Lucene.
This code was copied form MMAPDirectory in Lucene .