[Dive4elements-commits] [PATCH] Simplified code

Wald Commits scm-commit at wald.intevation.org
Sat Jan 5 12:13:30 CET 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1357384396 -3600
# Node ID e21acb4f5c623d302df8b87fc156c541146d3ad0
# Parent  28fa48986ae9c6a70cec15a55d78151f45475968
Simplified code.

diff -r 28fa48986ae9 -r e21acb4f5c62 flys-aft/src/main/java/de/intevation/aft/SyncContext.java
--- a/flys-aft/src/main/java/de/intevation/aft/SyncContext.java	Fri Jan 04 15:55:45 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/SyncContext.java	Sat Jan 05 12:13:16 2013 +0100
@@ -120,13 +120,11 @@
         Map<TimeInterval, TimeInterval> intervals =
             new TreeMap<TimeInterval, TimeInterval>();
 
-        ResultSet rs = null;
+        ResultSet rs = flysStatements
+            .getStatement("select.timeintervals")
+            .executeQuery();
 
         try {
-            rs = flysStatements
-                .getStatement("select.timeintervals")
-                .executeQuery();
-
             while (rs.next()) {
                 int  id    = rs.getInt("id");
                 Date start = rs.getDate("start_time");
@@ -143,9 +141,7 @@
             }
         }
         finally {
-            if (rs != null) {
-                rs.close();
-            }
+            rs.close();
         }
 
         if (debug) {
@@ -163,37 +159,34 @@
             return old;
         }
 
-        ResultSet rs = null;
+        ResultSet rs = flysStatements
+            .getStatement("next.timeinterval.id")
+            .executeQuery();
+
         try {
-            rs = flysStatements.getStatement("next.timeinterval.id")
-                .executeQuery();
             rs.next();
             key.setId(rs.getInt("time_interval_id"));
-            rs.close(); rs = null;
-
-            if (log.isDebugEnabled()) {
-                log.debug("FLYS: Created time interval id: " + key.getId());
-                log.debug("FLYS: " + key);
-            }
-
-            flysStatements.getStatement("insert.timeinterval")
-                .clearParameters()
-                .setInt("id", key.getId())
-                .setObject("start_time", key.getStart())
-                .setObject("stop_time", key.getStop())
-                .execute();
         }
         finally {
-            if (rs != null) {
-                rs.close();
-            }
+            rs.close();
         }
 
+        if (log.isDebugEnabled()) {
+            log.debug("FLYS: Created time interval id: " + key.getId());
+            log.debug("FLYS: " + key);
+        }
+
+        flysStatements.getStatement("insert.timeinterval")
+            .clearParameters()
+            .setInt("id", key.getId())
+            .setObject("start_time", key.getStart())
+            .setObject("stop_time", key.getStop())
+            .execute();
+
         flysTimeIntervals.put(key, key);
 
         return key;
     }
-
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
 


More information about the Dive4elements-commits mailing list