From: Jihoon Song Date: Thu, 31 Oct 2013 08:43:41 +0000 (+0900) Subject: BUILDER: fixed a concurrency exception problem about DependencyInDB X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f310f02e75af66d5371ed8274068e789e749fb7e;p=sdk%2Fide%2Fcommon-eplugin.git BUILDER: fixed a concurrency exception problem about DependencyInDB Sometimes, OConcurrentModificationException is occurred while building using DependencyInDB. This patch fix it. Change-Id: Ibdc5ff71df8e92cd3181bbad7cf73659e2e55615 Signed-off-by: Jihoon Song --- diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/dependency/DependencyInDB.java b/org.tizen.common.builder/src/org/tizen/common/builder/dependency/DependencyInDB.java index e58cffc..66ba761 100755 --- a/org.tizen.common.builder/src/org/tizen/common/builder/dependency/DependencyInDB.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/dependency/DependencyInDB.java @@ -29,14 +29,12 @@ 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 vIter = graph.getVertices( DependencyConstant.RESOURCE_KEY_PROJECT, this.projectName ).iterator(); - List list = new ArrayList(); 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 iterator = inVertex.getEdges( outVertex, Direction.IN ).iterator(); - List edges = new ArrayList(); 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 ); } } } diff --git a/org.tizen.common.externals/META-INF/MANIFEST.MF b/org.tizen.common.externals/META-INF/MANIFEST.MF index a160dc8..532da09 100644 --- a/org.tizen.common.externals/META-INF/MANIFEST.MF +++ b/org.tizen.common.externals/META-INF/MANIFEST.MF @@ -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,