You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2015/09/09 17:41:46 UTC

svn commit: r1702041 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java

Author: rmuir
Date: Wed Sep  9 15:41:46 2015
New Revision: 1702041

URL: http://svn.apache.org/r1702041
Log:
LUCENE-6791: sketchy MockFileSystem reflection should be in AccessController block

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java?rev=1702041&r1=1702040&r2=1702041&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterFileChannel.java Wed Sep  9 15:41:46 2015
@@ -26,6 +26,8 @@ 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;
 
 /**  
@@ -137,21 +139,26 @@ public class FilterFileChannel extends F
   @Override
   protected void implCloseChannel() throws IOException {
     // our only way to call delegate.implCloseChannel()
-    for (Class<?> clazz = delegate.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
-      final Method method;
-      try {
-        method = clazz.getDeclaredMethod("implCloseChannel");
-      } catch (NoSuchMethodException e) {
-        continue;
+    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();
       }
-      try {
-        method.setAccessible(true);
-        method.invoke(delegate);
-        return;
-      } catch (ReflectiveOperationException e) {
-        throw new IOError(e);
-      }
-    }
-    throw new AssertionError();
+    });
   }
 }