sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1734539 - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java src/main/config/security.policy
Date Fri, 11 Mar 2016 11:25:21 GMT
Author: desruisseaux
Date: Fri Mar 11 11:25:21 2016
New Revision: 1734539

URL: http://svn.apache.org/viewvc?rev=1734539&view=rev
Log:
Conservatively remove the use of AccessController.doPrivileged(...) for ServiceLoader,
because it may create by reflection classes that we do not control.
We will need to revisit in the context of Jigsaw.

Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
    sis/branches/JDK8/src/main/config/security.policy

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java?rev=1734539&r1=1734538&r2=1734539&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
[UTF-8] Fri Mar 11 11:25:21 2016
@@ -20,9 +20,6 @@ import java.util.Map;
 import java.util.IdentityHashMap;
 import java.util.ServiceLoader;
 import java.util.ServiceConfigurationError;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.io.FilePermission;
 import org.apache.sis.internal.util.Utilities;
 
 
@@ -89,21 +86,20 @@ public final class DefaultFactories exte
     public static synchronized <T> T forClass(final Class<T> type) {
         T factory = type.cast(FACTORIES.get(type));
         if (factory == null && !FACTORIES.containsKey(type)) {
-            factory = AccessController.doPrivileged((PrivilegedAction<T>) () ->
{
-                T prefered = null;
-                T fallback = null;
-                for (final T candidate : ServiceLoader.load(type)) {
-                    if (Utilities.isSIS(candidate.getClass())) {
-                        if (prefered != null) {
-                            throw new ServiceConfigurationError("Found two implementations
of " + type);
-                        }
-                        prefered = candidate;
-                    } else if (fallback == null) {
-                        fallback = candidate;
+            T fallback = null;
+            for (final T candidate : ServiceLoader.load(type)) {
+                if (Utilities.isSIS(candidate.getClass())) {
+                    if (factory != null) {
+                        throw new ServiceConfigurationError("Found two implementations of
" + type);
                     }
+                    factory = candidate;
+                } else if (fallback == null) {
+                    fallback = candidate;
                 }
-                return (prefered != null) ? prefered : fallback;
-            }, null, new FilePermission("<<ALL FILES>>", "read"));      // For
reading META-INF/services/* files.
+            }
+            if (factory == null) {
+                factory = fallback;
+            }
             /*
              * Verifies if the factory that we just selected is the same implementation than
an existing instance.
              * The main case for this test is org.apache.sis.referencing.factory.GeodeticObjectFactory,
where the

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java?rev=1734539&r1=1734538&r2=1734539&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
[UTF-8] Fri Mar 11 11:25:21 2016
@@ -158,11 +158,11 @@ public final class Shutdown extends Thre
     }
 
     /**
-     * Unregister the supervisor MBean, executes the disposal tasks and shutdowns the {@code
sis-utility} threads.
+     * Unregisters the supervisor MBean, executes the disposal tasks and shutdowns the {@code
sis-utility} threads.
      *
      * @param  caller The class invoking this method, to be used only for logging purpose,
or {@code null}
      *         if the logging system is not available anymore (i.e. the JVM itself is shutting
down).
-     * @throws Exception If an error occurred during unregistration of the supervisor MBean
+     * @throws Exception if an error occurred during unregistration of the supervisor MBean
      *         or during a resource disposal.
      */
     public static void stop(final Class<?> caller) throws Exception {

Modified: sis/branches/JDK8/src/main/config/security.policy
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/src/main/config/security.policy?rev=1734539&r1=1734538&r2=1734539&view=diff
==============================================================================
--- sis/branches/JDK8/src/main/config/security.policy [UTF-8] (original)
+++ sis/branches/JDK8/src/main/config/security.policy [UTF-8] Fri Mar 11 11:25:21 2016
@@ -1,15 +1,17 @@
 //
 // Security policy for running Apache SIS in a security-constrained environment.
 // The first grant block below contains the permissions that are most likely to
-// be needed for SIS use. Other grant block contains permissions needed only if
+// be needed for SIS use. Other grant blocks contain permissions needed only if
 // the JavaDB is used or if MBeans monitoring is desired.
 //
 grant {
-  permission java.lang.RuntimePermission          "shutdownHooks";
-  permission java.lang.RuntimePermission          "getenv.SIS_DATA";
-  permission java.util.PropertyPermission         "java.naming.factory.initial", "read";
-  permission java.util.PropertyPermission         "derby.system.home", "read";
-  permission java.lang.RuntimePermission          "getClassLoader";
+  permission java.lang.RuntimePermission   "shutdownHooks";
+  permission java.lang.RuntimePermission   "getenv.SIS_DATA";
+  permission java.util.PropertyPermission  "java.naming.factory.initial", "read";
+  permission java.util.PropertyPermission  "derby.system.home", "read";
+  permission java.lang.RuntimePermission   "getClassLoader";
+
+  // Apache SIS suppresses those checks only for its own classes or fields.
   permission java.lang.reflect.ReflectPermission  "suppressAccessChecks";
 
   // Actually only need access to the ${SIS_DATA} directory.



Mime
View raw message