This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 0df6494 Improve robustness 0df6494 is described below commit 0df64948f249e18d01ec2ba69c74e87c70bc363c 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 6312b1f..80c829f 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; } } @@ -2460,7 +2463,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); @@ -2567,9 +2570,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 eaf0e22..24fa7b0 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 9.0.55 (remm)" 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