git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1702139 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2015-09-10 01:09:42 +00:00
parent 99762f7339
commit 37ec9f4344
1 changed files with 3 additions and 26 deletions

View File

@ -17,17 +17,13 @@ package org.apache.lucene.mockfile;
* limitations under the License.
*/
import java.io.IOError;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Objects;
/**
@ -138,27 +134,8 @@ public class FilterFileChannel extends FileChannel {
@Override
protected void implCloseChannel() throws IOException {
// our only way to call delegate.implCloseChannel()
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
for (Class<?> clazz = delegate.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
final Method method;
try {
method = clazz.getDeclaredMethod("implCloseChannel");
} catch (NoSuchMethodException e) {
continue;
}
try {
method.setAccessible(true);
method.invoke(delegate);
return null;
} catch (ReflectiveOperationException e) {
throw new IOError(e);
}
}
throw new AssertionError();
}
});
// we can't call implCloseChannel, but calling this instead is "ok":
// http://mail.openjdk.java.net/pipermail/nio-dev/2015-September/003322.html
delegate.close();
}
}