Author: markt
Date: Thu Jun 20 21:38:59 2013
New Revision: 1495202

URL: http://svn.apache.org/r1495202
Log:
r1495155 incorrectly removed the commit
Restore the commit and clean the code up a little.

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/JDBCRealm.java

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/JDBCRealm.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/JDBCRealm.java?rev=1495202&r1=1495201&r2=1495202&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/JDBCRealm.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/JDBCRealm.java Thu Jun 
20 21:38:59 2013
@@ -546,47 +546,42 @@ public class JDBCRealm
         // connection may try to be opened again. On normal conditions 
(including
         // invalid login - the above is only used once.
         int numberOfTries = 2;
-        while (numberOfTries>0) {
+        while (numberOfTries > 0) {
             try {
-                
                 // Ensure that we have an open database connection
                 open();
                 
-                try {
-                    stmt = credentials(dbConnection, username);
-                    rs = stmt.executeQuery();
+                stmt = credentials(dbConnection, username);
+                rs = stmt.executeQuery();
+                dbConnection.commit();
                     
-                    if (rs.next()) {
-                        dbCredentials = rs.getString(1);
-                    }
-                    rs.close();
-                    rs = null;
-                    if (dbCredentials == null) {
-                        return (null);
-                    }
+                if (rs.next()) {
+                    dbCredentials = rs.getString(1);
+                }
                     
+                if (dbCredentials != null) {
                     dbCredentials = dbCredentials.trim();
-                    return dbCredentials;
-                    
-                } finally {
-                    if (rs!=null) {
-                        try {
-                            rs.close();
-                        } catch(SQLException e) {
-                            
containerLog.warn(sm.getString("jdbcRealm.abnormalCloseResultSet"));
-                        }
-                    }
                 }
                 
+                return dbCredentials;
+
             } catch (SQLException e) {
-                
                 // Log the problem for posterity
                 containerLog.error(sm.getString("jdbcRealm.exception"), e);
-                
-                // Close the connection so that it gets reopened next time
-                if (dbConnection != null)
-                    close(dbConnection);
-                
+            } finally {
+                if (rs != null) {
+                    try {
+                        rs.close();
+                    } catch(SQLException e) {
+                        containerLog.warn(sm.getString(
+                                "jdbcRealm.abnormalCloseResultSet"));
+                    }
+                }
+            }
+
+            // Close the connection so that it gets reopened next time
+            if (dbConnection != null) {
+                close(dbConnection);
             }
             
             numberOfTries--;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to