cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r591580 - /cocoon/trunk/blocks/cocoon-databases/cocoon-databases-impl/src/main/java/org/apache/cocoon/acting/OraAddAction.java
Date Sat, 03 Nov 2007 10:47:49 GMT
Author: felixk
Date: Sat Nov  3 03:47:48 2007
New Revision: 591580

URL: http://svn.apache.org/viewvc?rev=591580&view=rev
Log:
The method creates a database resource (such as a database connection or row set), does not
assign it to any fields, pass it to other methods, or return it, and does not appear to close
the object on all paths out of the method.  Failure to close database resources on all paths
out of a method may result in poor performance, and could cause the application to have problems
communicating with the database.

Modified:
    cocoon/trunk/blocks/cocoon-databases/cocoon-databases-impl/src/main/java/org/apache/cocoon/acting/OraAddAction.java

Modified: cocoon/trunk/blocks/cocoon-databases/cocoon-databases-impl/src/main/java/org/apache/cocoon/acting/OraAddAction.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-databases/cocoon-databases-impl/src/main/java/org/apache/cocoon/acting/OraAddAction.java?rev=591580&r1=591579&r2=591580&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-databases/cocoon-databases-impl/src/main/java/org/apache/cocoon/acting/OraAddAction.java
(original)
+++ cocoon/trunk/blocks/cocoon-databases/cocoon-databases-impl/src/main/java/org/apache/cocoon/acting/OraAddAction.java
Sat Nov  3 03:47:48 2007
@@ -27,6 +27,7 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
@@ -92,17 +93,22 @@
                 if ("manual".equals(mode)) {
                     String selectQuery = this.getSelectQuery(keys[i]);
 
-                    ResultSet set = conn.createStatement().executeQuery(selectQuery);
-                    set.next();
-                    int value = set.getInt("maxid") + 1;
-
-                    statement.setInt(currentIndex, value);
-
-                    request.setAttribute(keys[i].getAttribute("param"), String.valueOf(value));
-
-                    set.close();
-                    set.getStatement().close();
-                    currentIndex++;
+                    final Statement stmnt = conn.createStatement(); 
+                    final ResultSet set = stmnt.executeQuery(selectQuery);
+                    try {
+                        set.next();
+                        int value = set.getInt("maxid") + 1;
+
+                        statement.setInt(currentIndex, value);
+
+                        request.setAttribute(keys[i].getAttribute("param"), String.valueOf(value));
+
+                        set.getStatement().close();
+                        set.close();
+                        currentIndex++;
+                    } finally {
+                        stmnt.close();
+                    }
                 } else if ("form".equals(mode)) {
                     String parameter = keys[i].getAttribute("param");
                     request.setAttribute(parameter, request.getParameter(parameter));



Mime
View raw message