mirror of https://github.com/apache/lucene.git
LUCENE-6791: sketchy MockFileSystem reflection should be in AccessController block
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1702038 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5db80b0b90
commit
2489b18c86
|
@ -26,6 +26,8 @@ import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.FileLock;
|
import java.nio.channels.FileLock;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.nio.channels.WritableByteChannel;
|
import java.nio.channels.WritableByteChannel;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,6 +139,9 @@ public class FilterFileChannel extends FileChannel {
|
||||||
@Override
|
@Override
|
||||||
protected void implCloseChannel() throws IOException {
|
protected void implCloseChannel() throws IOException {
|
||||||
// our only way to call delegate.implCloseChannel()
|
// 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()) {
|
for (Class<?> clazz = delegate.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||||
final Method method;
|
final Method method;
|
||||||
try {
|
try {
|
||||||
|
@ -147,11 +152,13 @@ public class FilterFileChannel extends FileChannel {
|
||||||
try {
|
try {
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
method.invoke(delegate);
|
method.invoke(delegate);
|
||||||
return;
|
return null;
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
throw new IOError(e);
|
throw new IOError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue