Author: markt
Date: Thu Jun 20 21:34:09 2013
New Revision: 1495197
URL: http://svn.apache.org/r1495197
Log:
r1495154 incorrectly removed the commit
Restore the commit and clean the code up a little.
Modified:
tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java
Modified: tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java?rev=1495197&r1=1495196&r2=1495197&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/JDBCRealm.java Thu Jun 20
21:34:09 2013
@@ -527,47 +527,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"));
- }
- }
}
- } catch (SQLException e) {
+ return dbCredentials;
+ } catch (SQLException e) {
// Log the problem for posterity
containerLog.error(sm.getString("jdbcRealm.exception"), e);
+ } 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);
-
+ // Close the connection so that it gets reopened next time
+ if (dbConnection != null) {
+ close(dbConnection);
}
numberOfTries--;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]