BUILDER: fixed a concurrency exception problem about DependencyInDB 17/11617/1
authorJihoon Song <jihoon80.song@samsung.com>
Thu, 31 Oct 2013 08:43:41 +0000 (17:43 +0900)
committerJihoon Song <jihoon80.song@samsung.com>
Thu, 31 Oct 2013 08:48:52 +0000 (17:48 +0900)
Sometimes, OConcurrentModificationException is occurred while building using DependencyInDB.
This patch fix it.

Change-Id: Ibdc5ff71df8e92cd3181bbad7cf73659e2e55615
Signed-off-by: Jihoon Song <jihoon80.song@samsung.com>
org.tizen.common.builder/src/org/tizen/common/builder/dependency/DependencyInDB.java
org.tizen.common.externals/META-INF/MANIFEST.MF

index e58cffc..66ba761 100755 (executable)
 package org.tizen.common.builder.dependency;
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.slf4j.LoggerFactory.*;
 import org.tizen.common.builder.BuildDependency;
 import org.tizen.common.builder.BuildProcess;
 import org.tizen.common.builder.Dependency;
@@ -45,6 +43,7 @@ import org.tizen.common.builder.ResourceLayer;
 import org.tizen.common.util.Assert;
 import org.tizen.common.util.StringUtil;
 
+import com.orientechnologies.orient.core.config.OGlobalConfiguration;
 import com.tinkerpop.blueprints.Direction;
 import com.tinkerpop.blueprints.Edge;
 import com.tinkerpop.blueprints.Vertex;
@@ -54,7 +53,7 @@ import com.tinkerpop.blueprints.impls.orient.OrientVertex;
 
 public class DependencyInDB implements BuildDependency {
     
-    protected static final Logger logger = LoggerFactory.getLogger( DependencyInDB.class );
+    protected static final Logger logger = getLogger( DependencyInDB.class );
     
     public static final String DB_NAME = "Dependency";
     
@@ -125,6 +124,11 @@ public class DependencyInDB implements BuildDependency {
                 bCreateIndex = true;
             }
             
+            // Bug fixed:
+            //  this is a solution of OConcurrentModificationException problem.
+            //  but, this patch affects a performance.
+            OGlobalConfiguration.CACHE_LEVEL1_ENABLED.setValue( false );
+            
             // create or open DB
             graph = new OrientGraphNoTx( url );
             graph.setUseLightweightEdges( false );
@@ -179,12 +183,8 @@ public class DependencyInDB implements BuildDependency {
             // remove database from local storage.
             // INFO: Gremlin actually deletes all the edges for you if you delete the vertex.
             Iterator<Vertex> vIter = graph.getVertices( DependencyConstant.RESOURCE_KEY_PROJECT, this.projectName ).iterator();
-            List<Vertex> list = new ArrayList<Vertex>();
             while ( vIter.hasNext() ) {
-                list.add( vIter.next() );
-            }
-            for ( Vertex v : list ) {
-                v.remove();
+                vIter.next().remove();
             }
             
             logger.trace( "Remove all resources" );
@@ -276,7 +276,6 @@ public class DependencyInDB implements BuildDependency {
             Assert.notNull( outVertex );
             
             OrientEdge edge = graph.addEdge( null, outVertex, inVertex, DependencyConstant.EDGE_LABEL );
-            edge.save();
             
             logger.trace( "an added edge : {}", edge );
         }
@@ -314,13 +313,10 @@ public class DependencyInDB implements BuildDependency {
             
             // remove edges
             Iterator<Edge> iterator = inVertex.getEdges( outVertex, Direction.IN ).iterator();
-            List<Edge> edges = new ArrayList<Edge>();
             while( iterator.hasNext() ) {
-                edges.add( iterator.next() );
-            }
-            for ( Edge edge : edges ) {
-                logger.trace( "an removed edge : {}", edge );
+                Edge edge = iterator.next();
                 edge.remove();
+                logger.trace( "an removed edge : {}", edge );
             }
         }
     }
index a160dc8..532da09 100644 (file)
@@ -10,7 +10,8 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.ide
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
-Export-Package: com.tinkerpop.blueprints,
+Export-Package: com.orientechnologies.orient.core.config,
+ com.tinkerpop.blueprints,
  com.tinkerpop.blueprints.impls.orient,
  org.mihalis.opal,
  org.mihalis.opal.angles,