You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2013/03/20 15:17:38 UTC

svn commit: r1458846 - in /directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model: schemachecker/SchemaChecker.java schemamanager/SchemaEditorSchemaLoader.java

Author: pamarcelot
Date: Wed Mar 20 14:17:38 2013
New Revision: 1458846

URL: http://svn.apache.org/r1458846
Log:
Fix for DIRSTUDIO-893 (ConcurrentModificationException thrown while deleting multiple schema elements).

Modified:
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java?rev=1458846&r1=1458845&r2=1458846&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java (original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemachecker/SchemaChecker.java Wed Mar 20 14:17:38 2013
@@ -63,13 +63,16 @@ public class SchemaChecker
     private SchemaManager schemaManager;
 
     /** The errors map */
-    private MultiMap errorsMap = new MultiValueMap();;
+    private MultiMap errorsMap = new MultiValueMap();
 
     /** The warnings list */
     private List<SchemaWarning> warningsList = new ArrayList<SchemaWarning>();
 
     /** The warnings map */
-    private MultiMap warningsMap = new MultiValueMap();;
+    private MultiMap warningsMap = new MultiValueMap();
+
+    /** The lock object used to synchronize accesses to the errors and warnings maps*/
+    private static Object lock = new Object();
 
     /** The 'listening to modifications' flag*/
     private boolean listeningToModifications = false;
@@ -261,7 +264,7 @@ public class SchemaChecker
     /**
      * Checks the whole schema.
      */
-    private synchronized void recheckWholeSchema()
+    private void recheckWholeSchema()
     {
         Job job = new Job( "Checking Schema" )
         {
@@ -297,16 +300,19 @@ public class SchemaChecker
     /**
      * Updates the errors and warnings. 
      */
-    private void updateErrorsAndWarnings()
+    private synchronized void updateErrorsAndWarnings()
     {
-        // Errors
-        errorsMap.clear();
-        indexErrors();
-
-        // Warnings
-        createWarnings();
-        warningsMap.clear();
-        indexWarnings();
+        synchronized ( lock )
+        {
+            // Errors
+            errorsMap.clear();
+            indexErrors();
+
+            // Warnings
+            createWarnings();
+            warningsMap.clear();
+            indexWarnings();
+        }
     }
 
 
@@ -430,7 +436,10 @@ public class SchemaChecker
      */
     public List<SchemaWarning> getWarnings()
     {
-        return warningsList;
+        synchronized ( lock )
+        {
+            return warningsList;
+        }
     }
 
 
@@ -483,7 +492,10 @@ public class SchemaChecker
      */
     public List<?> getErrors( SchemaObject so )
     {
-        return ( List<?> ) errorsMap.get( so );
+        synchronized ( lock )
+        {
+            return ( List<?> ) errorsMap.get( so );
+        }
     }
 
 

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java?rev=1458846&r1=1458845&r2=1458846&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java (original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java Wed Mar 20 14:17:38 2013
@@ -115,11 +115,17 @@ public class SchemaEditorSchemaLoader ex
         {
             for ( Schema schema : schemas )
             {
-                List<MatchingRule> matchingRules = project.getSchemaHandler().getSchema( schema.getSchemaName() )
-                    .getMatchingRules();
-                for ( MatchingRule matchingRule : matchingRules )
+                org.apache.directory.studio.schemaeditor.model.Schema schemaHandlerSchema = project.getSchemaHandler()
+                    .getSchema( schema.getSchemaName() );
+
+                if ( schemaHandlerSchema != null )
                 {
-                    matchingRuleList.add( SchemaEditorSchemaLoaderUtils.toEntry( matchingRule ) );
+                    List<MatchingRule> matchingRules = schemaHandlerSchema.getMatchingRules();
+
+                    for ( MatchingRule matchingRule : matchingRules )
+                    {
+                        matchingRuleList.add( SchemaEditorSchemaLoaderUtils.toEntry( matchingRule ) );
+                    }
                 }
             }
         }
@@ -139,11 +145,17 @@ public class SchemaEditorSchemaLoader ex
         {
             for ( Schema schema : schemas )
             {
-                List<LdapSyntax> syntaxes = project.getSchemaHandler().getSchema( schema.getSchemaName() )
-                    .getSyntaxes();
-                for ( LdapSyntax syntax : syntaxes )
+                org.apache.directory.studio.schemaeditor.model.Schema schemaHandlerSchema = project.getSchemaHandler()
+                    .getSchema( schema.getSchemaName() );
+
+                if ( schemaHandlerSchema != null )
                 {
-                    syntaxList.add( SchemaEditorSchemaLoaderUtils.toEntry( syntax ) );
+                    List<LdapSyntax> syntaxes = schemaHandlerSchema.getSyntaxes();
+
+                    for ( LdapSyntax syntax : syntaxes )
+                    {
+                        syntaxList.add( SchemaEditorSchemaLoaderUtils.toEntry( syntax ) );
+                    }
                 }
             }
         }
@@ -163,11 +175,17 @@ public class SchemaEditorSchemaLoader ex
         {
             for ( Schema schema : schemas )
             {
-                List<AttributeType> attributeTypes = project.getSchemaHandler().getSchema( schema.getSchemaName() )
-                    .getAttributeTypes();
-                for ( AttributeType attributeType : attributeTypes )
+                org.apache.directory.studio.schemaeditor.model.Schema schemaHandlerSchema = project.getSchemaHandler()
+                    .getSchema( schema.getSchemaName() );
+
+                if ( schemaHandlerSchema != null )
                 {
-                    attributeTypeList.add( SchemaEditorSchemaLoaderUtils.toEntry( attributeType ) );
+                    List<AttributeType> attributeTypes = schemaHandlerSchema.getAttributeTypes();
+
+                    for ( AttributeType attributeType : attributeTypes )
+                    {
+                        attributeTypeList.add( SchemaEditorSchemaLoaderUtils.toEntry( attributeType ) );
+                    }
                 }
             }
         }
@@ -223,11 +241,17 @@ public class SchemaEditorSchemaLoader ex
         {
             for ( Schema schema : schemas )
             {
-                List<MutableObjectClass> objectClasses = project.getSchemaHandler().getSchema( schema.getSchemaName() )
-                    .getObjectClasses();
-                for ( ObjectClass objectClass : objectClasses )
+                org.apache.directory.studio.schemaeditor.model.Schema schemaHandlerSchema = project.getSchemaHandler()
+                    .getSchema( schema.getSchemaName() );
+
+                if ( schemaHandlerSchema != null )
                 {
-                    objectClassList.add( SchemaEditorSchemaLoaderUtils.toEntry( objectClass ) );
+                    List<MutableObjectClass> objectClasses = schemaHandlerSchema.getObjectClasses();
+
+                    for ( ObjectClass objectClass : objectClasses )
+                    {
+                        objectClassList.add( SchemaEditorSchemaLoaderUtils.toEntry( objectClass ) );
+                    }
                 }
             }
         }