db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1585407 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/services/io/FilePermissionServiceImpl.java testing/org/apache/derbyTesting/functionTests/tests/engine/RestrictiveFilePermissionsTest.java
Date Mon, 07 Apr 2014 06:59:09 GMT
Author: kahatlen
Date: Mon Apr  7 06:59:08 2014
New Revision: 1585407

URL: http://svn.apache.org/r1585407
Log:
DERBY-6410: ClassCastException when launching derby from windows subst drive

Avoid calling Files.getFileStore() since it fails when called on a
file that lives on a subst drive. (Because of a bug in the JVM:
JDK-8034057.)

It is used for checking if a specific FileAttributeView is supported
on the file system. The same information can be found by checking if
Files.getFileAttributeView() returns null, which we already do, so
skip the failing call.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FilePermissionServiceImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/RestrictiveFilePermissionsTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FilePermissionServiceImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FilePermissionServiceImpl.java?rev=1585407&r1=1585406&r2=1585407&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FilePermissionServiceImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FilePermissionServiceImpl.java
Mon Apr  7 06:59:08 2014
@@ -23,7 +23,6 @@ package org.apache.derby.iapi.services.i
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.file.FileStore;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.attribute.AclEntry;
@@ -40,20 +39,17 @@ import java.util.Collections;
 final class FilePermissionServiceImpl implements FilePermissionService {
     public boolean limitAccessToOwner(File file) throws IOException {
         Path fileP = file.toPath();
-        FileStore fileStore = Files.getFileStore(fileP);
 
         // If we have a posix view, just return and fall back on
         // the JDK 6 approach.
-        if (fileStore.supportsFileAttributeView(PosixFileAttributeView.class)) {
+        PosixFileAttributeView posixView = Files.getFileAttributeView(
+                fileP, PosixFileAttributeView.class);
+        if (posixView != null) {
             return false;
         }
 
-        if (!fileStore.supportsFileAttributeView(AclFileAttributeView.class)) {
-            return false;
-        }
-
-        AclFileAttributeView aclView =
-                Files.getFileAttributeView(fileP, AclFileAttributeView.class);
+        AclFileAttributeView aclView = Files.getFileAttributeView(
+                fileP, AclFileAttributeView.class);
         if (aclView == null) {
             return false;
         }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/RestrictiveFilePermissionsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/RestrictiveFilePermissionsTest.java?rev=1585407&r1=1585406&r2=1585407&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/RestrictiveFilePermissionsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/RestrictiveFilePermissionsTest.java
Mon Apr  7 06:59:08 2014
@@ -515,12 +515,9 @@ public class RestrictiveFilePermissionsT
     private static Class<?> linkOptionArrayClz;
     private static Class<?> linkOptionClz;
     private static Class<?> stringArrayClz;
-    private static Class<?> fileStoreClz;
 
     private static Method get;
     private static Method getFileAttributeView;
-    private static Method supportsFileAttributeView;
-    private static Method getFileStore;
     private static Method getOwner;
     private static Method getAcl;
     private static Method principal;
@@ -632,8 +629,6 @@ public class RestrictiveFilePermissionsT
                             "java.nio.file.LinkOption");
                         stringArrayClz = Class.forName(
                             "[Ljava.lang.String;");
-                        fileStoreClz = Class.forName(
-                            "java.nio.file.FileStore");
 
                         get = pathsClz.
                             getMethod("get",
@@ -645,11 +640,6 @@ public class RestrictiveFilePermissionsT
                                       new Class[]{pathClz,
                                                   Class.class,
                                                   linkOptionArrayClz});
-                        supportsFileAttributeView = fileStoreClz.getMethod(
-                            "supportsFileAttributeView",
-                            new Class[]{Class.class});
-                        getFileStore = filesClz.getMethod("getFileStore",
-                                                          new Class[]{pathClz});
                         getOwner = filesClz.
                             getMethod(
                                 "getOwner",
@@ -702,16 +692,6 @@ public class RestrictiveFilePermissionsT
 
                         // ACLs supported on this platform? Check the current
                         // file system:
-                        Object fileStore = getFileStore.invoke(
-                            null,
-                            new Object[]{fileP});
-
-                        boolean aclsSupported =
-                            ((Boolean)supportsFileAttributeView.invoke(
-                                fileStore,
-                                new Object[]{aclFileAttributeViewClz})).
-                            booleanValue();
-
                         Object aclView = getFileAttributeView.invoke(
                             null,
                             new Object[]{
@@ -726,8 +706,7 @@ public class RestrictiveFilePermissionsT
                                 posixFileAttributeViewClz,
                                 Array.newInstance(linkOptionClz, 0)});
 
-                        if (aclsSupported && aclView != null &&
-                                posixView == null) {
+                        if (aclView != null && posixView == null) {
                             // Windows
                             Object owner = getOwner.invoke(
                                 null,



Mime
View raw message