You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2022/02/11 15:44:36 UTC

[felix-dev] branch master updated: FELIX-6504 : HttpSessionWrapper getId() throws unexpected IllegalStateException

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

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new a0f781d  FELIX-6504 : HttpSessionWrapper getId() throws unexpected IllegalStateException
a0f781d is described below

commit a0f781dda4281bf656e8acb70154b1d123353cd5
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Feb 11 16:44:29 2022 +0100

    FELIX-6504 : HttpSessionWrapper getId() throws unexpected IllegalStateException
---
 .../http/base/internal/handler/HttpSessionWrapper.java      | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpSessionWrapper.java b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpSessionWrapper.java
index d048ece..1b963d6 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpSessionWrapper.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpSessionWrapper.java
@@ -272,7 +272,7 @@ public class HttpSessionWrapper implements HttpSession
     @Override
     public String getId()
     {
-        this.checkInvalid();
+        // no validity check conforming to the javadocs
         if ( this.config.isUniqueSessionId() )
         {
             return this.delegate.getId().concat("-").concat(this.sessionId);
@@ -304,12 +304,14 @@ public class HttpSessionWrapper implements HttpSession
     @Override
     public Object getValue(String name)
     {
+        this.checkInvalid();
         return this.getAttribute(name);
     }
 
     @Override
     public String[] getValueNames()
     {
+        this.checkInvalid();
         final List<String> names = new ArrayList<>();
         final Enumeration<String> e = this.getAttributeNames();
         while ( e.hasMoreElements() )
@@ -381,6 +383,7 @@ public class HttpSessionWrapper implements HttpSession
     @Override
     public void putValue(final String name, final Object value)
     {
+        this.checkInvalid();
         this.setAttribute(name, value);
     }
 
@@ -406,6 +409,7 @@ public class HttpSessionWrapper implements HttpSession
     @Override
     public void removeValue(final String name)
     {
+        this.checkInvalid();
         this.removeAttribute(name);
     }
 
@@ -451,12 +455,17 @@ public class HttpSessionWrapper implements HttpSession
     @Override
     public void setMaxInactiveInterval(final int interval)
     {
+        // no validity check conforming to the javadocs
         if ( this.delegate.getMaxInactiveInterval() < interval )
         {
             this.delegate.setMaxInactiveInterval(interval);
         }
         this.maxTimeout = interval;
-        this.delegate.setAttribute(ATTR_MAX_INACTIVE + this.sessionId, interval);
+        try {
+            this.delegate.setAttribute(ATTR_MAX_INACTIVE + this.sessionId, interval);
+        } catch ( final IllegalStateException iae) {
+            // this might throw if delegate is invalid
+        }
     }
 
     @Override