Port fix for 33774. Retry on ServiceUnavailableException
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 2 Jun 2007 01:42:17 +0000 (01:42 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 2 Jun 2007 01:42:17 +0000 (01:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@543693 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/realm/JNDIRealm.java
webapps/docs/changelog.xml

index e9ec25b..a465277 100644 (file)
@@ -35,6 +35,7 @@ import javax.naming.NamingException;
 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;
@@ -840,6 +841,21 @@ public class JNDIRealm extends RealmBase {
                 // 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);
+
             }
 
 
index 24d1710..74fffdf 100644 (file)
   <subsection name="Catalina">
     <changelog>
       <fix>
+        <bug>33774</bug> Retry JNDI authentiction on ServiceUnavailableException
+        as at least one provider throws this after an idle connection has been
+        closed. (markt)
+      </fix>
+      <fix>
          <bug>39875</bug>: Fix BPE in RealmBase.init(). Port of yoavs's fix from
          Tomcat 5. (markt)
       </fix>