Add finalize to clean up file handles to Titan
diff --git a/src/main/java/net/floodlightcontroller/core/INetMapStorage.java b/src/main/java/net/floodlightcontroller/core/INetMapStorage.java
index 642bf4d..67c6631 100644
--- a/src/main/java/net/floodlightcontroller/core/INetMapStorage.java
+++ b/src/main/java/net/floodlightcontroller/core/INetMapStorage.java
@@ -15,4 +15,5 @@
 		UPDATE  // Update the object if exists or CREATE/INSERT if does not exist
 	}
 	public void init(String conf);
+	public void close();
 }
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
index 1e14b05..72c6b50 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
@@ -262,5 +262,16 @@
 		return inactiveSwitches;
 	}
 
+	public void finalize() {
+		close();
+	}
+	
+	@Override
+	public void close() {
+		// TODO Auto-generated method stub
+		graph.shutdown();
+		
+	}
+
 	
 }
diff --git a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
index 0edc35e..cb2eb46 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
@@ -27,7 +27,7 @@
 
 	@Override
 	public Iterable<ISwitchObject> GetAllSwitches() {
-		// TODO Auto-generated method stub
+		// TODO Auto-generated method stub		
 		return swStore.getAllSwitches();
 	}
 
@@ -41,6 +41,5 @@
 	public List<String> GetPortsOnSwitch(String dpid) {
 		// TODO Auto-generated method stub
 		return null;
-	}
-    
+	}	
 }
diff --git a/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java b/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
index 11dbcb1..e75d26a 100644
--- a/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
@@ -21,8 +21,9 @@
 		}
 		if (filter.equals("inactive")) {
 			return (Iterator<ISwitchObject>) impl.GetInactiveSwitches().iterator();
+		} else {
+		    return (Iterator<ISwitchObject>) impl.GetAllSwitches().iterator();
 		}
-		return (Iterator<ISwitchObject>) impl.GetAllSwitches().iterator();				
 	}
 
 }
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
index d0f0b9e..3aa1fc0 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
@@ -248,7 +248,7 @@
 	
 		@Override
 		public Link compute(PathPipe<Vertex> pipe ) {
-
+			// TODO Auto-generated method stub
 			long s_dpid = 0;
 			long d_dpid = 0;
 			short s_port = 0;
@@ -269,6 +269,16 @@
 			return l;
 		}
 	}
+	
+	public void finalize() {
+		close();
+	}
+
+	@Override
+	public void close() {
+		// TODO Auto-generated method stub
+		graph.shutdown();		
+	}
 
 
 }
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
index b73224e..2dbb338 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
@@ -21,7 +21,8 @@
 	@Override
 	public List<Link> GetActiveLinks() {
 		// TODO Auto-generated method stub
-		return linkStore.getActiveLinks();
+		List<Link> retval = linkStore.getActiveLinks();
+		return retval;
 	}
 
 	@Override
@@ -29,5 +30,4 @@
 		// TODO Auto-generated method stub
 		return linkStore.getLinks(dpid);
 	}
-
 }
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/web/TopoLinksResource.java b/src/main/java/net/floodlightcontroller/linkdiscovery/web/TopoLinksResource.java
index 323708e..a0770cb 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/web/TopoLinksResource.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/web/TopoLinksResource.java
@@ -13,8 +13,8 @@
     public List<Link> retrieve() {
 		TopoLinkServiceImpl impl = new TopoLinkServiceImpl();
 		
-		return impl.GetActiveLinks();
-		
+		List<Link> retval = impl.GetActiveLinks();
+		return retval;
 	}
 
 }