be more careful about closing ResultSets in Graylist
authoradam <adam@megacz.com>
Mon, 22 Jun 2009 00:11:07 +0000 (00:11 +0000)
committeradam <adam@megacz.com>
Mon, 22 Jun 2009 00:11:07 +0000 (00:11 +0000)
darcs-hash:20090622001107-5007d-1a40a7d97a74966401da2c1b6e5ea988eb0786b8.gz

src/org/ibex/mail/Graylist.java

index 1f65dd4..d31ae00 100644 (file)
@@ -28,8 +28,13 @@ public class Graylist extends SqliteDB {
         try {
             PreparedStatement check = conn.prepareStatement("select * from 'whitelist' where ip=?");
             check.setString(1, ip.getHostAddress());
-            ResultSet rs = check.executeQuery();
-            return !rs.isAfterLast();
+            ResultSet rs = null;
+            boolean ret;
+            try {
+                rs = check.executeQuery();
+                ret = !rs.isAfterLast();
+            } finally { close(rs); }
+            return ret;
         } catch (SQLException e) { throw new RuntimeException(e); }
     }
 
@@ -40,9 +45,12 @@ public class Graylist extends SqliteDB {
             check.setString(1, graylistAddress(ip));
             check.setString(2, from);
             check.setString(3, to);
-            ResultSet rs = check.executeQuery();
-            if (rs.isAfterLast()) return 0;
-            return rs.getTimestamp(1).getTime();
+            ResultSet rs = null;
+            try {
+                rs = check.executeQuery();
+                if (rs.isAfterLast()) return 0;
+                return rs.getTimestamp(1).getTime();
+            } finally { close(rs); }
         } catch (SQLException e) { throw new RuntimeException(e); }
     }