[tomcat] branch master updated: Avoid NPE and keep original behaviour

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[tomcat] branch master updated: Avoid NPE and keep original behaviour

markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 8290514  Avoid NPE and keep original behaviour
8290514 is described below

commit 8290514200cdde3c996afbc097001c5aedc77c66
Author: Mark Thomas <[hidden email]>
AuthorDate: Tue Sep 15 17:04:43 2020 +0100

    Avoid NPE and keep original behaviour
---
 .../apache/catalina/valves/PersistentValve.java    | 29 +++++++++++++---------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/catalina/valves/PersistentValve.java b/java/org/apache/catalina/valves/PersistentValve.java
index 36afb94..a63794c 100644
--- a/java/org/apache/catalina/valves/PersistentValve.java
+++ b/java/org/apache/catalina/valves/PersistentValve.java
@@ -170,21 +170,26 @@ public class PersistentValve extends ValveBase {
                     if (manager instanceof StoreManager) {
                         Session session = manager.findSession(newsessionId);
                         Store store = ((StoreManager) manager).getStore();
-                        synchronized (session) {
-                            if (store != null && session != null && session.isValid()
-                                    && !isSessionStale(session, System.currentTimeMillis())) {
-                                store.save(session);
-                                ((StoreManager) manager).removeSuper(session);
-                                session.recycle();
-                            } else {
-                                if (container.getLogger().isDebugEnabled()) {
-                                    container.getLogger()
-                                            .debug("newsessionId store: " + store + " session: " + session + " valid: "
-                                                    + (session == null ? "N/A" : Boolean.toString(session.isValid()))
-                                                    + " stale: " + isSessionStale(session, System.currentTimeMillis()));
+                        boolean stored = false;
+                        if (session != null) {
+                            synchronized (session) {
+                                if (store != null && session.isValid() &&
+                                        !isSessionStale(session, System.currentTimeMillis())) {
+                                    store.save(session);
+                                    ((StoreManager) manager).removeSuper(session);
+                                    session.recycle();
+                                    stored = true;
                                 }
                             }
                         }
+                        if (!stored) {
+                            if (container.getLogger().isDebugEnabled()) {
+                                container.getLogger()
+                                        .debug("newsessionId store: " + store + " session: " + session + " valid: "
+                                                + (session == null ? "N/A" : Boolean.toString(session.isValid()))
+                                                + " stale: " + isSessionStale(session, System.currentTimeMillis()));
+                            }
+                        }
                     } else {
                         if (container.getLogger().isDebugEnabled()) {
                             container.getLogger().debug("newsessionId Manager: " +


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]