You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2008/04/17 18:00:13 UTC

svn commit: r649158 - /incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java

Author: rfeng
Date: Thu Apr 17 09:00:09 2008
New Revision: 649158

URL: http://svn.apache.org/viewvc?rev=649158&view=rev
Log:
Fix for TUSCANY-2069 with the null check

Modified:
    incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java

Modified: incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java?rev=649158&r1=649157&r2=649158&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java (original)
+++ incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java Thu Apr 17 09:00:09 2008
@@ -75,6 +75,7 @@
 
     // Fix for TUSCANY-2069, making the map concurrent
     private final Map<VertexPair, Path> paths = new ConcurrentHashMap<VertexPair, Path>();
+    private final Path NULL_PATH = new Path();
 
     /**
      * Vertex of a graph
@@ -287,13 +288,15 @@
         }
 
         VertexPair pair = new VertexPair(source, target);
+        Path path = null;
         if (paths.containsKey(pair)) {
-            return paths.get(pair);
+            path = paths.get(pair);
+            return path == NULL_PATH? null: path;
         }
 
         // Check if there is a direct link, if yes, use it instead
         Edge direct = getEdge(source, target);
-        Path path = new Path();
+        path = new Path();
         if (direct != null) {
             path.addEdge(direct);
             paths.put(pair, path);
@@ -316,10 +319,8 @@
             nextNode = extractMin(otherNodes);
             if (nextNode.vertex == target) {
                 path = getPath(nextNode);
-                if (path != null) {
-                    paths.put(pair, path); // Cache it
-                }
-                return path;
+                paths.put(pair, path); // Cache it
+                return path == NULL_PATH? null: path;
             }
             nodesOnPath.add(nextNode);
             for (Edge edge : nextNode.vertex.outEdges.values()) {
@@ -333,7 +334,7 @@
                 }
             }
         }
-        paths.put(pair, null); // Cache it
+        paths.put(pair, NULL_PATH); // Cache it
         return null;
     }
 
@@ -379,7 +380,7 @@
 
     private Path getPath(Node t) {
         if (t.distance == Integer.MAX_VALUE) {
-            return null;
+            return NULL_PATH;
         }
         Path path = new Path();
         Node u = t;



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org