[Swift-commit] r4789 - in trunk/src/org/griphyn/vdl: karajan/lib/swiftscript mapping

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Wed Jul 6 20:36:12 CDT 2011


Author: hategan
Date: 2011-07-06 20:36:11 -0500 (Wed, 06 Jul 2011)
New Revision: 4789

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
   trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
   trunk/src/org/griphyn/vdl/mapping/RootArrayDataNode.java
   trunk/src/org/griphyn/vdl/mapping/RootDataNode.java
Log:
fix NPE when provenance logging is requested (i.e. there are cases when data is not initialized properly leading to a state in getMapper() which triggers the NPE), and replace use of RootDataNode.newNode with a RootDataNode constructor

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java	2011-07-07 01:33:24 UTC (rev 4788)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java	2011-07-07 01:36:11 UTC (rev 4789)
@@ -32,7 +32,7 @@
 			String str = breader.readLine();
 			freader.close();
 			Double i = new Double(str);
-			DSHandle result = RootDataNode.newNode(Types.FLOAT, i);
+			DSHandle result = new RootDataNode(Types.FLOAT, i);
 			int provid = VDLFunction.nextProvenanceID();
 			VDLFunction.logProvenanceResult(provid, result, "extractint");
 			VDLFunction.logProvenanceParameter(provid, handle, "filename");

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java	2011-07-07 01:33:24 UTC (rev 4788)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java	2011-07-07 01:36:11 UTC (rev 4789)
@@ -15,7 +15,7 @@
 
 	public Object function(VariableStack stack) throws ExecutionException {
 		String s = argList(filename(stack), true);
-		DSHandle result = RootDataNode.newNode(Types.STRING, s);
+		DSHandle result = new RootDataNode(Types.STRING, s);
 		int provid = VDLFunction.nextProvenanceID();
 		//VDLFunction.logProvenanceParameter(provid, (DSHandle) PA_VAR.getValue(stack), "input");
 		//VDLFunction.logProvenanceResult(provid, result, "filename");

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java	2011-07-07 01:33:24 UTC (rev 4788)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java	2011-07-07 01:36:11 UTC (rev 4789)
@@ -68,7 +68,7 @@
 			throw new ExecutionException("Missing command line argument: " + name);
 		}
 		else {
-			DSHandle result = RootDataNode.newNode(Types.STRING, value);	
+			DSHandle result = new RootDataNode(Types.STRING, value);	
 			int provid=VDLFunction.nextProvenanceID();
 			VDLFunction.logProvenanceResult(provid, result, "arg");
 			VDLFunction.logProvenanceParameter(provid, P_NAME.getRawValue(stack), "name");

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2011-07-07 01:33:24 UTC (rev 4788)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2011-07-07 01:36:11 UTC (rev 4789)
@@ -15,7 +15,6 @@
 import org.griphyn.vdl.karajan.lib.VDLFunction;
 import org.griphyn.vdl.mapping.AbsFile;
 import org.griphyn.vdl.mapping.AbstractDataNode;
-import org.griphyn.vdl.mapping.ArrayDataNode;
 import org.griphyn.vdl.mapping.DSHandle;
 import org.griphyn.vdl.mapping.InvalidPathException;
 import org.griphyn.vdl.mapping.Path;
@@ -108,7 +107,7 @@
 		
 		DSHandle handle = new RootDataNode(Types.STRING);
 		handle.setValue(buf.toString());
-		handle.closeShallow();
+
 		try {
 			if(VDL2Config.getConfig().getProvenanceLog()) {
 				DSHandle[] provArgs = SwiftArg.VARGS.asDSHandleArray(stack);
@@ -381,7 +380,7 @@
 	    n.waitFor();
         String name = VDLFunction.filename(n)[0];
         String result = new AbsFile(name).getDir();
-        return RootDataNode.newNode(Types.STRING, result);
+        return new RootDataNode(Types.STRING, result);
 	}
 
 	/*
@@ -394,7 +393,7 @@
 	public DSHandle swiftscript_length(VariableStack stack)
 	throws ExecutionException {
 	    Map<?, ?> n = (Map<?, ?>) PA_ARRAY.getValue(stack);
-	    return RootDataNode.newNode(Types.INT, Integer.valueOf(n.size()));
+	    return new RootDataNode(Types.INT, Integer.valueOf(n.size()));
 	}
 
 	public DSHandle swiftscript_existsfile(VariableStack stack)

Modified: trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2011-07-07 01:33:24 UTC (rev 4788)
+++ trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2011-07-07 01:36:11 UTC (rev 4789)
@@ -462,6 +462,7 @@
             catch (FutureFault fe) {
                 m = null; // no mapping info if mapper isn't initialised yet
             }
+
             if (m != null) {
                 // TODO proper type here
                 // Not sure catching exception here is really the right thing to

Modified: trunk/src/org/griphyn/vdl/mapping/RootArrayDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/RootArrayDataNode.java	2011-07-07 01:33:24 UTC (rev 4788)
+++ trunk/src/org/griphyn/vdl/mapping/RootArrayDataNode.java	2011-07-07 01:36:11 UTC (rev 4789)
@@ -99,8 +99,12 @@
 		if (initialized) {
 			return mapper;
 		}
-        assert(waitingMapperParam != null);
-        throw new FutureNotYetAvailable(waitingMapperParam.getFutureWrapper());
+        if (waitingMapperParam == null) {
+            return null;
+        }
+        else {
+            throw new FutureNotYetAvailable(waitingMapperParam.getFutureWrapper());
+        }
 	}
 
 	public boolean isArray() {

Modified: trunk/src/org/griphyn/vdl/mapping/RootDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/RootDataNode.java	2011-07-07 01:33:24 UTC (rev 4788)
+++ trunk/src/org/griphyn/vdl/mapping/RootDataNode.java	2011-07-07 01:36:11 UTC (rev 4789)
@@ -22,20 +22,13 @@
 	private Map<String, Object> params;
 	private AbstractDataNode waitingMapperParam;
 
-	public static DSHandle newNode(Type type, Object value) {
-		DSHandle handle = new RootDataNode(type);
-		handle.setValue(value);
-		handle.closeShallow();
-		logger.debug("newNode");
-		return handle;
-	}
-
 	public RootDataNode(Type type) {
 		super(Field.Factory.createField(null, type));
 	}
 	
 	public RootDataNode(Type type, Object value) {
 	    this(type);
+	    initialized();
 	    setValue(value);
 	}
 
@@ -214,8 +207,12 @@
 		if (initialized) {
 			return mapper;
 		}
-        assert (waitingMapperParam != null);
-        throw new FutureNotYetAvailable(waitingMapperParam.getFutureWrapper());
+        if (waitingMapperParam == null) {
+            return null;
+        }
+        else {
+            throw new FutureNotYetAvailable(waitingMapperParam.getFutureWrapper());
+        }
 	}
 
 	public boolean isArray() {
@@ -230,5 +227,5 @@
 	private synchronized void initialized() {
 		initialized = true;
 		waitingMapperParam = null;
-	}    
+	}
 }




More information about the Swift-commit mailing list