You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2021/10/29 08:46:48 UTC
[tomcat] branch 8.5.x updated: Improve robustness
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 240e93e Improve robustness
240e93e is described below
commit 240e93e59a4178af268468e78a7da0a493043788
Author: remm <re...@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 c16a444..498b4d2 100644
--- a/java/org/apache/catalina/realm/JNDIRealm.java
+++ b/java/org/apache/catalina/realm/JNDIRealm.java
@@ -1287,7 +1287,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);
@@ -2402,9 +2402,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;
}
}
@@ -2475,7 +2478,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);
@@ -2582,9 +2585,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 0205463..8ce7802 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 8.5.73 (schultz)">
+ <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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org