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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 59a01ea18b Review "Avoid NullPointerException releasing a PageContext 
..."
59a01ea18b is described below

commit 59a01ea18b33ec60ae9cebbffd3fdcec3a2e518f
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Nov 6 08:56:43 2026 +0000

    Review "Avoid NullPointerException releasing a PageContext ..."
    
    Fix a concurrency issue reading the pool size
---
 java/org/apache/jasper/runtime/JspFactoryImpl.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/jasper/runtime/JspFactoryImpl.java 
b/java/org/apache/jasper/runtime/JspFactoryImpl.java
index c45b007614..af6f022d63 100644
--- a/java/org/apache/jasper/runtime/JspFactoryImpl.java
+++ b/java/org/apache/jasper/runtime/JspFactoryImpl.java
@@ -48,11 +48,15 @@ public class JspFactoryImpl extends JspFactory {
     public PageContext getPageContext(Servlet servlet, ServletRequest request, 
ServletResponse response,
             String errorPageURL, boolean needsSession, int bufferSize, boolean 
autoflush) {
 
+        // Read the volatile field once. It may be changed concurrently by the
+        // start of another web application.
+        int currentPoolSize = poolSize;
+
         PageContext pc;
-        if (poolSize > 0) {
+        if (currentPoolSize > 0) {
             PageContextPool pool = localPool.get();
             if (pool == null) {
-                pool = new PageContextPool(poolSize);
+                pool = new PageContextPool(currentPoolSize);
                 localPool.set(pool);
             }
             pc = pool.get();


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

Reply via email to