Author: remy.maucherat(a)jboss.com
Date: 2007-09-05 06:18:48 -0400 (Wed, 05 Sep 2007)
New Revision: 264
Modified:
trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
trunk/java/org/apache/catalina/realm/JNDIRealm.java
trunk/java/org/apache/catalina/startup/Embedded.java
Log:
- Logging cleanup.
- Port fix for recycling with cross context.
- Port fixes to JNDI realm.
Modified: trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2007-09-04 23:06:49 UTC
(rev 263)
+++ trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2007-09-05 10:18:48 UTC
(rev 264)
@@ -59,7 +59,7 @@
* <code>javax.servlet.ServletResponseWrapper</code>.
*
* @author Craig R. McClanahan
- * @version $Revision: 531415 $ $Date: 2007-04-23 12:30:02 +0200 (lun., 23 avr. 2007) $
+ * @version $Revision: 572856 $ $Date: 2007-09-05 04:01:02 +0200 (mer., 05 sept. 2007) $
*/
final class ApplicationDispatcher
@@ -341,10 +341,6 @@
wrequest.setQueryString(hrequest.getQueryString());
processRequest(request,response,state);
-
- wrequest.recycle();
- unwrapRequest(state);
-
}
// Handle an HTTP path-based forward
@@ -377,10 +373,6 @@
}
processRequest(request,response,state);
-
- wrequest.recycle();
- unwrapRequest(state);
-
}
// This is not a real close in order to support error processing
@@ -521,8 +513,6 @@
ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
servletPath);
invoke(state.outerRequest, state.outerResponse, state);
-
- wrequest.recycle();
}
// Handle an HTTP path based include
@@ -555,8 +545,6 @@
ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
servletPath);
invoke(state.outerRequest, state.outerResponse, state);
-
- wrequest.recycle();
}
}
@@ -731,7 +719,9 @@
// See Bugzilla 30949
unwrapRequest(state);
unwrapResponse(state);
-
+ // Recycle request if necessary (also BZ 30949)
+ recycleRequestWrapper(state);
+
// Rethrow an exception if one was thrown by the invoked servlet
if (ioException != null)
throw ioException;
@@ -986,4 +976,9 @@
"applicationDispatcher.specViolation.response"));
}
}
+
+ private void recycleRequestWrapper(State state) {
+ if (state.wrapRequest instanceof ApplicationHttpRequest) {
+ ((ApplicationHttpRequest) state.wrapRequest).recycle(); }
+ }
}
Modified: trunk/java/org/apache/catalina/realm/JNDIRealm.java
===================================================================
--- trunk/java/org/apache/catalina/realm/JNDIRealm.java 2007-09-04 23:06:49 UTC (rev 263)
+++ trunk/java/org/apache/catalina/realm/JNDIRealm.java 2007-09-05 10:18:48 UTC (rev 264)
@@ -35,6 +35,7 @@
import javax.naming.NameParser;
import javax.naming.Name;
import javax.naming.AuthenticationException;
+import javax.naming.ServiceUnavailableException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
@@ -150,7 +151,7 @@
*
* @author John Holman
* @author Craig R. McClanahan
- * @version $Revision: 539907 $ $Date: 2007-05-20 20:33:16 +0200 (dim., 20 mai 2007) $
+ * @version $Revision: 572859 $ $Date: 2007-09-05 04:14:45 +0200 (mer., 05 sept. 2007) $
*/
public class JNDIRealm extends RealmBase {
@@ -840,6 +841,21 @@
// Try the authentication again.
principal = authenticate(context, username, credentials);
+ } catch (ServiceUnavailableException e) {
+
+ // log the exception so we know it's there.
+ containerLog.warn(sm.getString("jndiRealm.exception"), e);
+
+ // close the connection so we know it will be reopened.
+ if (context != null)
+ close(context);
+
+ // open a new directory context.
+ context = open();
+
+ // Try the authentication again.
+ principal = authenticate(context, username, credentials);
+
}
@@ -903,7 +919,7 @@
// Check the user's credentials
if (checkCredentials(context, user, credentials)) {
// Search for additional roles
- List roles = getRoles(context, user);
+ List<String> roles = getRoles(context, user);
return (new GenericPrincipal(this,
username,
credentials,
@@ -931,7 +947,7 @@
return (null);
// Search for additional roles
- List roles = getRoles(context, user);
+ List<String> roles = getRoles(context, user);
// Create and return a suitable Principal for this user
return (new GenericPrincipal(this, username, credentials, roles));
@@ -961,7 +977,7 @@
User user = null;
// Get attributes to retrieve from user entry
- ArrayList list = new ArrayList();
+ ArrayList<String> list = new ArrayList<String>();
if (userPassword != null)
list.add(userPassword);
if (userRoleName != null)
@@ -1020,7 +1036,7 @@
password = getAttributeValue(userPassword, attrs);
// Retrieve values of userRoleName attribute
- ArrayList roles = null;
+ ArrayList<String> roles = null;
if (userRoleName != null)
roles = addAttributeValues(userRoleName, attrs, roles);
@@ -1110,7 +1126,7 @@
password = getAttributeValue(userPassword, attrs);
// Retrieve values of userRoleName attribute
- ArrayList roles = null;
+ ArrayList<String> roles = null;
if (userRoleName != null)
roles = addAttributeValues(userRoleName, attrs, roles);
@@ -1264,7 +1280,6 @@
User user,
String credentials)
throws NamingException {
- Attributes attr;
if (credentials == null || user == null)
return (false);
@@ -1288,7 +1303,7 @@
if (containerLog.isTraceEnabled()) {
containerLog.trace(" binding as " + dn);
}
- attr = context.getAttributes("", null);
+ context.getAttributes("", null);
validated = true;
}
catch (AuthenticationException e) {
@@ -1328,7 +1343,7 @@
*
* @exception NamingException if a directory server error occurs
*/
- protected List getRoles(DirContext context, User user)
+ protected List<String> getRoles(DirContext context, User user)
throws NamingException {
if (user == null)
@@ -1344,9 +1359,9 @@
containerLog.trace(" getRoles(" + dn + ")");
// Start with roles retrieved from the user entry
- ArrayList list = user.roles;
+ ArrayList<String> list = user.roles;
if (list == null) {
- list = new ArrayList();
+ list = new ArrayList<String>();
}
// Are we configured to do role searches?
@@ -1433,9 +1448,9 @@
*
* @exception NamingException if a directory server error occurs
*/
- private ArrayList addAttributeValues(String attrId,
+ private ArrayList<String> addAttributeValues(String attrId,
Attributes attrs,
- ArrayList values)
+ ArrayList<String> values)
throws NamingException{
if (containerLog.isTraceEnabled())
@@ -1443,7 +1458,7 @@
if (attrId == null || attrs == null)
return values;
if (values == null)
- values = new ArrayList();
+ values = new ArrayList<String>();
Attribute attr = attrs.get(attrId);
if (attr == null)
return (values);
@@ -1534,6 +1549,21 @@
// Try the authentication again.
principal = getPrincipal(context, username);
+ } catch (ServiceUnavailableException e) {
+
+ // log the exception so we know it's there.
+ containerLog.warn(sm.getString("jndiRealm.exception"), e);
+
+ // close the connection so we know it will be reopened.
+ if (context != null)
+ close(context);
+
+ // open a new directory context.
+ context = open();
+
+ // Try the authentication again.
+ principal = getPrincipal(context, username);
+
}
@@ -1620,7 +1650,7 @@
*/
protected Hashtable getDirectoryContextEnvironment() {
- Hashtable env = new Hashtable();
+ Hashtable<String,String> env = new Hashtable<String,String>();
// Configure our directory context environment.
if (containerLog.isDebugEnabled() && connectionAttempt == 0)
@@ -1714,7 +1744,7 @@
protected String[] parseUserPatternString(String userPatternString) {
if (userPatternString != null) {
- ArrayList pathList = new ArrayList();
+ ArrayList<String> pathList = new ArrayList<String>();
int startParenLoc = userPatternString.indexOf('(');
if (startParenLoc == -1) {
// no parens here; return whole thing
@@ -1802,10 +1832,11 @@
String username = null;
String dn = null;
String password = null;
- ArrayList roles = null;
+ ArrayList<String> roles = null;
- User(String username, String dn, String password, ArrayList roles) {
+ User(String username, String dn, String password,
+ ArrayList<String> roles) {
this.username = username;
this.dn = dn;
this.password = password;
Modified: trunk/java/org/apache/catalina/startup/Embedded.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Embedded.java 2007-09-04 23:06:49 UTC (rev
263)
+++ trunk/java/org/apache/catalina/startup/Embedded.java 2007-09-05 10:18:48 UTC (rev
264)
@@ -886,7 +886,7 @@
protected void initNaming() {
// Setting additional variables
if (!useNaming) {
- log.info( "Catalina naming disabled");
+ log.debug( "Catalina naming disabled");
System.setProperty("catalina.useNaming", "false");
} else {
System.setProperty("catalina.useNaming", "true");