commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1488575 - /commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java
Date Sat, 01 Jun 2013 19:56:19 GMT
Author: oheger
Date: Sat Jun  1 19:56:19 2013
New Revision: 1488575

URL: http://svn.apache.org/r1488575
Log:
Adapted beginRead() and beginWrite() methods in CombinedConfiguration.

The readLock() and writeLock() methods were removed. They could cause
problems because they obtained locks without using the standard means. This
could break subclasses that rely on symmetric invocations of beginRead()/
endRead() and beginWrite()/endWrite() respective.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java?rev=1488575&r1=1488574&r2=1488575&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java
Sat Jun  1 19:56:19 2013
@@ -247,7 +247,7 @@ public class CombinedConfiguration exten
      */
     public NodeCombiner getNodeCombiner()
     {
-        readLock();
+        beginRead(true);
         try
         {
             return nodeCombiner;
@@ -275,7 +275,7 @@ public class CombinedConfiguration exten
                     "Node combiner must not be null!");
         }
 
-        writeLock();
+        beginWrite(true);
         try
         {
             this.nodeCombiner = nodeCombiner;
@@ -296,7 +296,7 @@ public class CombinedConfiguration exten
      */
     public ExpressionEngine getConversionExpressionEngine()
     {
-        readLock();
+        beginRead(true);
         try
         {
             return conversionExpressionEngine;
@@ -325,7 +325,7 @@ public class CombinedConfiguration exten
     public void setConversionExpressionEngine(
             ExpressionEngine conversionExpressionEngine)
     {
-        writeLock();
+        beginWrite(true);
         try
         {
             this.conversionExpressionEngine = conversionExpressionEngine;
@@ -361,7 +361,7 @@ public class CombinedConfiguration exten
                     "Added configuration must not be null!");
         }
 
-        writeLock();
+        beginWrite(true);
         try
         {
             if (name != null && namedConfigurations.containsKey(name))
@@ -427,7 +427,7 @@ public class CombinedConfiguration exten
      */
     public int getNumberOfConfigurations()
     {
-        readLock();
+        beginRead(true);
         try
         {
             return getNumberOfConfigurationsInternal();
@@ -448,7 +448,7 @@ public class CombinedConfiguration exten
      */
     public Configuration getConfiguration(int index)
     {
-        readLock();
+        beginRead(true);
         try
         {
             ConfigData cd = configurations.get(index);
@@ -469,7 +469,7 @@ public class CombinedConfiguration exten
      */
     public Configuration getConfiguration(String name)
     {
-        readLock();
+        beginRead(true);
         try
         {
             return namedConfigurations.get(name);
@@ -487,7 +487,7 @@ public class CombinedConfiguration exten
      */
     public List<Configuration> getConfigurations()
     {
-        readLock();
+        beginRead(true);
         try
         {
             List<Configuration> list =
@@ -513,7 +513,7 @@ public class CombinedConfiguration exten
      */
     public List<String> getConfigurationNameList()
     {
-        readLock();
+        beginRead(true);
         try
         {
             List<String> list = new ArrayList<String>(getNumberOfConfigurationsInternal());
@@ -594,7 +594,7 @@ public class CombinedConfiguration exten
      */
     public Set<String> getConfigurationNames()
     {
-        readLock();
+        beginRead(true);
         try
         {
             return namedConfigurations.keySet();
@@ -615,7 +615,7 @@ public class CombinedConfiguration exten
      */
     public void invalidate()
     {
-        writeLock();
+        beginWrite(true);
         try
         {
             invalidateInternal();
@@ -765,10 +765,17 @@ public class CombinedConfiguration exten
     @Override
     protected void beginRead(boolean optimize)
     {
+        if (optimize)
+        {
+            // just need a lock, don't construct configuration
+            super.beginRead(true);
+            return;
+        }
+
         boolean lockObtained = false;
         do
         {
-            readLock();
+            super.beginRead(optimize);
             if (combinedRoot != null)
             {
                 lockObtained = true;
@@ -790,7 +797,13 @@ public class CombinedConfiguration exten
     @Override
     protected void beginWrite(boolean optimize)
     {
-        writeLock();
+        super.beginWrite(true);
+        if(optimize)
+        {
+            // just need a lock, don't construct configuration
+            return;
+        }
+
         try
         {
             if (combinedRoot == null)
@@ -934,26 +947,6 @@ public class CombinedConfiguration exten
     }
 
     /**
-     * Obtains this configuration's read lock without performing additional
-     * initialization. This method is called by operations which do not require
-     * access to the root node (and thus do not have to re-construct it).
-     */
-    private void readLock()
-    {
-        super.beginRead(false);
-    }
-
-    /**
-     * Obtains this configuration's write lock without performing additional
-     * initialization. This method is called by operations which do not require
-     * access to the root node (and thus do not have to re-construct it).
-     */
-    private void writeLock()
-    {
-        super.beginWrite(false);
-    }
-
-    /**
      * An internal helper class for storing information about contained
      * configurations.
      */



Mime
View raw message