From: Jihoon Song Date: Wed, 4 Dec 2013 01:54:16 +0000 (+0900) Subject: BUILD: fix the IOException when build projects using BuildProcess X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F69%2F13369%2F2;p=sdk%2Fide%2Fcommon-eplugin.git BUILD: fix the IOException when build projects using BuildProcess Sometimes, IOException with the 'a resource is not file' message is occurred. Dependency management bugs are fixed. Change-Id: Iecd0268520411a83faa990c60223ba9e34715c1a Signed-off-by: Jihoon Song --- diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java b/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java index ce12259..dedad2b 100755 --- a/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java @@ -426,11 +426,11 @@ public class BuildProcess for ( final Dependency dependency : this.dependencies.edgesOf( resource ) ) { - this.dependencies.removeEdge( dependency ); - Resource source = this.dependencies.getEdgeSource( dependency ); Resource target = this.dependencies.getEdgeTarget( dependency ); + this.dependencies.removeEdge( dependency ); + logger.debug( "Remove edge : {} / {}", source.getLayer(), source.getPath() ); logger.debug( " => {} / {}", target.getLayer(), target.getPath() ); diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/ResourceLayer.java b/org.tizen.common.builder/src/org/tizen/common/builder/ResourceLayer.java index 3476c94..1842b57 100755 --- a/org.tizen.common.builder/src/org/tizen/common/builder/ResourceLayer.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/ResourceLayer.java @@ -35,6 +35,7 @@ import java.util.HashSet; import org.tizen.common.file.FileHandler; import org.tizen.common.file.FileHandler.Attribute; +import org.tizen.common.util.Assert; public class ResourceLayer @@ -81,6 +82,8 @@ ResourceLayer final FileHandler fileHandler ) { + Assert.notNull( fileHandler ); + this.name = name; this.parent = parent; this.fileHandler = fileHandler; @@ -180,7 +183,11 @@ ResourceLayer ) throws IOException { - fileHandler.removeFile( path ); + // Bug fix : Solve 'a resource not found' problem + // Check the existence of resource + if ( fileHandler.is( path, Attribute.EXISTS ) ) { + fileHandler.removeFile( path ); + } } public void addFilterResource(Resource res) { 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 66ba761..659a7b8 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 @@ -330,13 +330,18 @@ public class DependencyInDB implements BuildDependency { Vertex vertex = getVertexFromDB( resource ); if ( vertex != null ) { - Iterator iterator = vertex.getEdges( Direction.BOTH ).iterator(); + // Bug fix : Solve 'incoming edges are not found' problem. + // The way to get edges with both direction by vertex cannot find incoming edges. + Iterator iterator = graph.getEdges().iterator(); while( iterator.hasNext() ) { Edge edge = iterator.next(); Vertex in = edge.getVertex( Direction.IN ); Vertex out = edge.getVertex( Direction.OUT ); - result.add( new OrientDBDependency( in, out, this.lastLayer ) ); + + if ( equals( in, vertex ) || equals( out, vertex ) ) { + result.add( new OrientDBDependency( in, out, this.lastLayer ) ); + } } } @@ -344,6 +349,18 @@ public class DependencyInDB implements BuildDependency { } } + protected boolean equals(Vertex v1, Vertex v2) { + String v1Layer = v1.getProperty( DependencyConstant.RESOURCE_KEY_LAYER ); + String v1Path = v1.getProperty( DependencyConstant.RESOURCE_KEY_PATH ); + String v1Project = v1.getProperty( DependencyConstant.RESOURCE_KEY_PROJECT ); + + String v2Layer = v2.getProperty( DependencyConstant.RESOURCE_KEY_LAYER ); + String v2Path = v2.getProperty( DependencyConstant.RESOURCE_KEY_PATH ); + String v2Project = v2.getProperty( DependencyConstant.RESOURCE_KEY_PROJECT ); + + return v1Layer.equals( v2Layer ) && v1Path.equals( v2Path ) && v1Project.equals( v2Project ); + } + @Override public Resource getEdgeSource(Dependency dependency) { return dependency.getSource(); @@ -353,4 +370,31 @@ public class DependencyInDB implements BuildDependency { public Resource getEdgeTarget(Dependency dependency) { return dependency.getTarget(); } + + public void printAllEdges(String msg) { + synchronized( syncObj ) { + logger.trace( "[ Edge list start - {} ]", msg ); + + Iterator iterator = graph.getEdges().iterator(); + while( iterator.hasNext() ) { + Edge edge = iterator.next(); + + Vertex in = edge.getVertex( Direction.IN ); + Vertex out = edge.getVertex( Direction.OUT ); + + Object[] msgs = { + in.getProperty( DependencyConstant.RESOURCE_KEY_PROJECT ), + in.getProperty( DependencyConstant.RESOURCE_KEY_PATH ), + in.getProperty( DependencyConstant.RESOURCE_KEY_LAYER ), + out.getProperty( DependencyConstant.RESOURCE_KEY_PROJECT ), + out.getProperty( DependencyConstant.RESOURCE_KEY_PATH ), + out.getProperty( DependencyConstant.RESOURCE_KEY_LAYER ) + }; + + logger.trace( "[{}] {} ( {} ) -> [{}] {} ( {} )", msgs ); + } + + logger.trace( "[ Edge list finish ]" ); + } + } } diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/dependency/OrientDBDependency.java b/org.tizen.common.builder/src/org/tizen/common/builder/dependency/OrientDBDependency.java index 3fdb3b7..105ab78 100644 --- a/org.tizen.common.builder/src/org/tizen/common/builder/dependency/OrientDBDependency.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/dependency/OrientDBDependency.java @@ -31,6 +31,7 @@ package org.tizen.common.builder.dependency; import org.tizen.common.builder.Dependency; import org.tizen.common.builder.Resource; import org.tizen.common.builder.ResourceLayer; +import org.tizen.common.file.VirtualFileHandler; import org.tizen.common.util.Assert; import com.tinkerpop.blueprints.Vertex; @@ -67,7 +68,9 @@ public class OrientDBDependency implements Dependency { resourceLayer = resourceLayer.getParent(); } - return null; + // Bug fix : Prevent NPE. + // In this case, a vertex was existed in DB but the matched resource layer is divided. + return new Resource( new ResourceLayer( layer, new VirtualFileHandler() ), path ); } public Vertex getSourceVertex() { diff --git a/org.tizen.common/src/org/tizen/common/file/StandardFileHandler.java b/org.tizen.common/src/org/tizen/common/file/StandardFileHandler.java index 646d68d..e975e06 100755 --- a/org.tizen.common/src/org/tizen/common/file/StandardFileHandler.java +++ b/org.tizen.common/src/org/tizen/common/file/StandardFileHandler.java @@ -30,6 +30,7 @@ import static org.tizen.common.util.IOUtil.tryClose; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -348,8 +349,15 @@ extends AbstractFileHandler throws IOException { final File file = getFile( path ); + if ( !file.isFile() ) { + // for details + if ( file.exists() == false ) { + logger.error( "{} is not exist.", path ); + throw new FileNotFoundException( path + " is not exist." ); + } + logger.error("{} is not a file", path); throw new IOException(path + " is not a file."); }