You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2014/08/01 19:10:44 UTC

[05/11] git commit: CLEREZZA-932: Add null check + initialize map

CLEREZZA-932: Add null check + initialize map


Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/981bfd20
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/981bfd20
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/981bfd20

Branch: refs/heads/release-201407
Commit: 981bfd20c96d51c59810d5fe28f59e98221185db
Parents: 0864432
Author: Minto van der Sluis <mi...@apache.org>
Authored: Wed Jul 30 11:36:27 2014 +0200
Committer: Minto van der Sluis <mi...@apache.org>
Committed: Wed Jul 30 11:36:27 2014 +0200

----------------------------------------------------------------------
 .../rdf/virtuoso/storage/access/DataAccess.java | 32 +++++++++++---------
 1 file changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/981bfd20/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/DataAccess.java
----------------------------------------------------------------------
diff --git a/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/DataAccess.java b/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/DataAccess.java
index b1c441c..e0c891d 100644
--- a/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/DataAccess.java
+++ b/rdf.virtuoso.storage/src/main/java/org/apache/clerezza/rdf/virtuoso/storage/access/DataAccess.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -166,18 +167,20 @@ public class DataAccess {
 
 	private void close(Object... resources) {
 		for (Object o : resources) {
-			try {
-				if (o instanceof ResultSet ) {
-					((ResultSet) o).close();
-				} else if (o instanceof Statement) {
-					((Statement) o).close();
-				}else if (o instanceof Connection) {
-					((Connection) o).close();
-				}else{
-					throw new SQLException("XXX Unsupported resource: " + o.toString());
+			if ( o != null ) {
+				try {
+					if (o instanceof ResultSet ) {
+						((ResultSet) o).close();
+					} else if (o instanceof Statement) {
+						((Statement) o).close();
+					}else if (o instanceof Connection) {
+						((Connection) o).close();
+					}else{
+						throw new SQLException("XXX Unsupported resource: " + o.toString());
+					}
+				} catch (SQLException e) {
+					logger.error("Cannot close resource of type {}", o.getClass());
 				}
-			} catch (SQLException e) {
-				logger.error("Cannot close resource of type {}", o.getClass());
 			}
 		}
 	}
@@ -1046,7 +1049,7 @@ public class DataAccess {
 	 */
 	private class RSSolutionMapping implements SolutionMapping {
 
-    	private Map<Variable, Resource> map;
+		private Map<Variable, Resource> map = new HashMap<Variable, Resource>();
     	
 		@Override
 		public int size() {
@@ -1075,8 +1078,7 @@ public class DataAccess {
 
 		@Override
 		public Resource put(Variable key, Resource value) {
-			// TODO Auto-generated method stub
-			return null;
+			return map.put( key, value );
 		}
 
 		@Override
@@ -1113,6 +1115,6 @@ public class DataAccess {
 		public Resource get(String name) {
 			return map.get(new Variable(name));
 		}
-    }
+	}
 
 }