[Swift-commit] r4588 - trunk/src/org/griphyn/vdl/karajan/lib

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Wed Jun 8 21:14:52 CDT 2011


Author: hategan
Date: 2011-06-08 21:14:51 -0500 (Wed, 08 Jun 2011)
New Revision: 4588

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
Log:
1. wait for the destination variables to be initialized if they aren't; 2. fixed array copying (the code would just go into a loop copying the first element in the array over and over, and eventually leading to a stack overflow)

Modified: trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java	2011-06-09 02:13:07 UTC (rev 4587)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java	2011-06-09 02:14:51 UTC (rev 4588)
@@ -10,6 +10,7 @@
 import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
 import org.griphyn.vdl.karajan.Pair;
 import org.griphyn.vdl.karajan.PairIterator;
+import org.griphyn.vdl.karajan.VDL2FutureException;
 import org.griphyn.vdl.mapping.AbstractDataNode;
 import org.griphyn.vdl.mapping.DSHandle;
 import org.griphyn.vdl.mapping.InvalidPathException;
@@ -43,13 +44,17 @@
 					throw new FutureNotYetAvailable(addFutureListener(stack, value));
 				}
 			}
-			synchronized (var.getRoot()) {
-				deepCopy(leaf, value, stack);
-				
-				if (var.getParent() != null && var.getParent().getType().isArray()) {
-				    markAsAvailable(stack, leaf.getParent(), leaf.getPathFromRoot().getLast());
-				}
+			try {
+    			synchronized (var.getRoot()) {
+    				deepCopy(leaf, value, stack);
+    				if (var.getParent() != null && var.getParent().getType().isArray()) {
+    				    markAsAvailable(stack, leaf.getParent(), leaf.getPathFromRoot().getLast());
+    				}
+    			}
 			}
+			catch (VDL2FutureException e) {
+			    throw new FutureNotYetAvailable(addFutureListener(stack, e.getHandle()));
+			}
 			
 			return null;
 		}
@@ -85,7 +90,14 @@
 			dest.setValue(source.getValue());
 		}
 		else if (source.getType().isArray()) {
-			PairIterator it = new PairIterator(source.getArrayValue());
+			PairIterator it;
+			if (stack.isDefined("it")) {
+			    it = (PairIterator) stack.getVar("it");
+			}
+			else {
+			    it = new PairIterator(source.getArrayValue());
+			    stack.setVar("it", it);
+			}
 			while (it.hasNext()) {
 				Pair pair = (Pair) it.next();
 				Object lhs = pair.get(0);
@@ -100,7 +112,7 @@
 				DSHandle field;
 				try {
 					field = dest.getField(memberPath);
-				} 
+				}
 				catch (InvalidPathException ipe) {
 					throw new ExecutionException("Could not get destination field",ipe);
 				}
@@ -128,6 +140,7 @@
 		                    throw new ExecutionException("Failed to copy " + source + " to " + dest, fc.getException());
 		                }
 		            }
+		            dest.closeShallow();
 		        }
 		        else {
 		            FileCopier fc = new FileCopier(source.getMapper().map(source.getPathFromRoot()), 




More information about the Swift-commit mailing list