You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by gl...@apache.org on 2003/02/04 14:22:46 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java

glenn       2003/02/04 05:22:46

  Modified:    catalina/src/share/org/apache/catalina/realm
                        DataSourceRealm.java
  Log:
  Port bug fix for 16316 from Tomcat 4.1, Realm start fails when DataSource not available yet.
  
  Revision  Changes    Path
  1.2       +8 -29     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/DataSourceRealm.java
  
  Index: DataSourceRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/DataSourceRealm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DataSourceRealm.java	8 Dec 2002 13:40:14 -0000	1.1
  +++ DataSourceRealm.java	4 Feb 2003 13:22:46 -0000	1.2
  @@ -313,6 +313,10 @@
   
               // Ensure that we have an open database connection
               dbConnection = open();
  +            if (dbConnection == null) {
  +                // If the db connection open fails, return "not authenticated"
  +                return null;
  +            }
   
               // Acquire a Principal object for this user
               Principal principal = authenticate(dbConnection,
  @@ -573,31 +577,6 @@
           preparedCredentials.append(" WHERE ");
           preparedCredentials.append(userNameCol);
           preparedCredentials.append(" = ?");
  -
  -        // Validate that we can open our connection
  -        Connection conn = null;
  -        PreparedStatement roles = null;
  -        PreparedStatement credentials = null;
  -        try {
  -            conn = open();
  -            if (conn != null) {
  -                roles = roles(conn,"");
  -                credentials = credentials(conn,"");
  -                if( !conn.getAutoCommit() ) {
  -                    conn.commit();             
  -                }
  -            }
  -        } catch (SQLException e) {
  -            throw new LifecycleException(sm.getString("dataSourceRealm.open"), e);
  -        } finally {
  -            try {
  -                if (conn != null) {
  -                   conn.close(); 
  -                }
  -            } catch (SQLException e) {
  -                throw new LifecycleException(sm.getString("dataSourceRealm.open"), e);
  -            }
  -        }
   
           // Perform normal superclass initialization
           super.start();
  
  
  

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