This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push: new 0781316 Improve robustness 0781316 is described below commit 0781316ed206b9814aea0e38e0f124f72a500d73 Author: remm <r...@apache.org> AuthorDate: Fri Oct 29 10:38:13 2021 +0200 Improve robustness Make sure the connection is always unlocked. --- java/org/apache/catalina/realm/JNDIRealm.java | 17 +++++++++++------ webapps/docs/changelog.xml | 9 +++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java index 55f9f16..bbd1f59 100644 --- a/java/org/apache/catalina/realm/JNDIRealm.java +++ b/java/org/apache/catalina/realm/JNDIRealm.java @@ -1279,7 +1279,7 @@ public class JNDIRealm extends RealmBase { // Return the authenticated Principal (if any) return principal; - } catch (NamingException e) { + } catch (Exception e) { // Log the problem for posterity containerLog.error(sm.getString("jndiRealm.exception"), e); @@ -2387,9 +2387,12 @@ public class JNDIRealm extends RealmBase { // ... and have a password return user.getPassword(); } - } catch (NamingException e) { + } catch (Exception e) { // Log the problem for posterity containerLog.error(sm.getString("jndiRealm.exception"), e); + // close the connection so we know it will be reopened. + close(connection); + closePooledConnections(); return null; } } @@ -2459,7 +2462,7 @@ public class JNDIRealm extends RealmBase { // Return the authenticated Principal (if any) return principal; - } catch (NamingException e) { + } catch (Exception e) { // Log the problem for posterity containerLog.error(sm.getString("jndiRealm.exception"), e); @@ -2566,9 +2569,11 @@ public class JNDIRealm extends RealmBase { */ protected void release(JNDIConnection connection) { if (connectionPool != null) { - if (!connectionPool.push(connection)) { - // Any connection that doesn't end back to the pool must be closed - close(connection); + if (connection != null) { + if (!connectionPool.push(connection)) { + // Any connection that doesn't end back to the pool must be closed + close(connection); + } } } else { singleConnectionLock.unlock(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index e22f5af..627a17b 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -105,6 +105,15 @@ issues do not "pop up" wrt. others). --> <section name="Tomcat 10.0.13 (markt)" rtext="in development"> + <subsection name="Catalina"> + <changelog> + <fix> + Improve robustness of JNDIRealm for exceptions occurring when getting + the connection. Also add missing close when running into issues + getting the passord of a user. (remm) + </fix> + </changelog> + </subsection> <subsection name="Coyote"> <changelog> <scode> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org