commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1555841 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java test/java/org/apache/commons/configuration/TestHierarchicalConfiguration.java
Date Mon, 06 Jan 2014 14:58:47 GMT
Author: oheger
Date: Mon Jan  6 14:58:47 2014
New Revision: 1555841

URL: http://svn.apache.org/r1555841
Log:
[CONFIGURATION-486] Removed static defaultExpressionEngine field.

Using static fields this way is thread-hostile. Hierarchical configurations now
use the default expression engine instance if not specified otherwise. The new
defaults mechanism defined by CONFIGURATION-559 makes it possible to define
another default expression engine globally.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestHierarchicalConfiguration.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java?rev=1555841&r1=1555840&r2=1555841&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java
Mon Jan  6 14:58:47 2014
@@ -42,7 +42,6 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.tree.ConfigurationNodeVisitorAdapter;
 import org.apache.commons.configuration.tree.DefaultConfigurationNode;
 import org.apache.commons.configuration.tree.DefaultExpressionEngine;
-import org.apache.commons.configuration.tree.DefaultExpressionEngineSymbols;
 import org.apache.commons.configuration.tree.ExpressionEngine;
 import org.apache.commons.configuration.tree.NodeAddData;
 
@@ -173,9 +172,6 @@ public class BaseHierarchicalConfigurati
      */
     private static final long serialVersionUID = 3373812230395363192L;
 
-    /** Stores the default expression engine to be used for new objects.*/
-    private static ExpressionEngine defaultExpressionEngine;
-
     /** Stores the root configuration node.*/
     private ConfigurationNode rootNode;
 
@@ -316,40 +312,6 @@ public class BaseHierarchicalConfigurati
     }
 
     /**
-     * Returns the default expression engine.
-     *
-     * @return the default expression engine
-     * @since 1.3
-     */
-    public static synchronized ExpressionEngine getDefaultExpressionEngine()
-    {
-        if (defaultExpressionEngine == null)
-        {
-            defaultExpressionEngine = new DefaultExpressionEngine(DefaultExpressionEngineSymbols.DEFAULT_SYMBOLS);
-        }
-        return defaultExpressionEngine;
-    }
-
-    /**
-     * Sets the default expression engine. This expression engine will be used
-     * if no specific engine was set for an instance. It is shared between all
-     * hierarchical configuration instances. So modifying its properties will
-     * impact all instances, for which no specific engine is set.
-     *
-     * @param engine the new default expression engine
-     * @since 1.3
-     */
-    public static synchronized void setDefaultExpressionEngine(ExpressionEngine engine)
-    {
-        if (engine == null)
-        {
-            throw new IllegalArgumentException(
-                    "Default expression engine must not be null!");
-        }
-        defaultExpressionEngine = engine;
-    }
-
-    /**
      * Returns the expression engine used by this configuration. This method
      * will never return <b>null</b>; if no specific expression engine was set,
      * the default expression engine will be returned.
@@ -360,7 +322,7 @@ public class BaseHierarchicalConfigurati
     public ExpressionEngine getExpressionEngine()
     {
         return (expressionEngine != null) ? expressionEngine
-                : getDefaultExpressionEngine();
+                : DefaultExpressionEngine.INSTANCE;
     }
 
     /**

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestHierarchicalConfiguration.java?rev=1555841&r1=1555840&r2=1555841&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestHierarchicalConfiguration.java
Mon Jan  6 14:58:47 2014
@@ -855,38 +855,14 @@ public class TestHierarchicalConfigurati
     {
         config.setExpressionEngine(null);
         assertNotNull("Expression engine is null", config.getExpressionEngine());
-        assertSame("Default engine is not used", BaseHierarchicalConfiguration
-                .getDefaultExpressionEngine(), config.getExpressionEngine());
+        assertSame("Default engine is not used",
+                DefaultExpressionEngine.INSTANCE, config.getExpressionEngine());
 
         config.setExpressionEngine(createAlternativeExpressionEngine());
         checkAlternativeSyntax();
     }
 
     /**
-     * Tests setting the default expression engine. This should impact all
-     * configuration instances that do not have their own engine.
-     */
-    @Test
-    public void testSetDefaultExpressionEngine()
-    {
-        ExpressionEngine engineOld = BaseHierarchicalConfiguration.getDefaultExpressionEngine();
-        BaseHierarchicalConfiguration
-                .setDefaultExpressionEngine(createAlternativeExpressionEngine());
-        checkAlternativeSyntax();
-        BaseHierarchicalConfiguration.setDefaultExpressionEngine(engineOld);
-    }
-
-    /**
-     * Tests setting the default expression engine to null. This should not be
-     * allowed.
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testSetDefaultExpressionEngineNull()
-    {
-        BaseHierarchicalConfiguration.setDefaultExpressionEngine(null);
-    }
-
-    /**
      * Tests the copy constructor.
      */
     @Test



Mime
View raw message