You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/03/11 12:43:29 UTC

svn commit: r1734540 - in /sis/branches/JDK7: ./ 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

Author: desruisseaux
Date: Fri Mar 11 11:43:28 2016
New Revision: 1734540

URL: http://svn.apache.org/viewvc?rev=1734540&view=rev
Log:
Merge the conservative removal of an AccessController.doPrivileged(...) applied to ServiceLoader.
See https://issues.apache.org/jira/browse/SIS-320 for more information.

Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
    sis/branches/JDK7/src/main/config/security.policy

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 11 11:43:28 2016
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1734484
+/sis/branches/JDK8:1584960-1734539
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java?rev=1734540&r1=1734539&r2=1734540&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] Fri Mar 11 11:43:28 2016
@@ -20,8 +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 org.apache.sis.internal.util.Utilities;
 
 
@@ -88,22 +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(new PrivilegedAction<T>() {
-            @Override public T run() {  // No indentation for easier merges from the JDK8 branch (which use lambda).
-                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;
-            }});
+            }
+            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/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java?rev=1734540&r1=1734539&r2=1734540&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java [UTF-8] Fri Mar 11 11:43:28 2016
@@ -162,11 +162,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/JDK7/src/main/config/security.policy
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/src/main/config/security.policy?rev=1734540&r1=1734539&r2=1734540&view=diff
==============================================================================
--- sis/branches/JDK7/src/main/config/security.policy [UTF-8] (original)
+++ sis/branches/JDK7/src/main/config/security.policy [UTF-8] Fri Mar 11 11:43:28 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.