You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2020/12/11 11:43:50 UTC

[tomee] branch master updated (c50373a -> fe43475)

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

jlmonteiro pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git.


    from c50373a  Merge pull request #730 from jgallimore/taglib-shade
     new 00482a8  Fix full build by generating the XML reports so Jenkins can find them
     new f9dc86f  Fix async servlet when HTTP request is wrapped (TCK weird usage)
     new fe43475  Make sure we are consistent and also override other methods from the context wrapper

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/openejb/cdi/CdiAppContextsService.java  | 26 +++++++++++++++++++
 .../org/apache/openejb/server/httpd/EEFilter.java  | 29 +++++++++++++++++++---
 tck/bval-signature-test/pom.xml                    |  2 +-
 tck/bval-tomee/pom.xml                             |  2 +-
 tck/cdi-embedded/pom.xml                           |  2 +-
 tck/cdi-tomee/pom.xml                              |  2 +-
 tck/tck-common/pom.xml                             |  2 +-
 7 files changed, 57 insertions(+), 8 deletions(-)


[tomee] 01/03: Fix full build by generating the XML reports so Jenkins can find them

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 00482a875edb3a6b4740cabe6e64e0e056320f0c
Author: Jean-Louis Monteiro <jl...@tomitribe.com>
AuthorDate: Fri Dec 11 12:42:08 2020 +0100

    Fix full build by generating the XML reports so Jenkins can find them
---
 tck/bval-signature-test/pom.xml | 2 +-
 tck/bval-tomee/pom.xml          | 2 +-
 tck/cdi-embedded/pom.xml        | 2 +-
 tck/cdi-tomee/pom.xml           | 2 +-
 tck/tck-common/pom.xml          | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tck/bval-signature-test/pom.xml b/tck/bval-signature-test/pom.xml
index 9009991..3038bab 100644
--- a/tck/bval-signature-test/pom.xml
+++ b/tck/bval-signature-test/pom.xml
@@ -76,7 +76,7 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <useFile>false</useFile>
-          <disableXmlReport>true</disableXmlReport>
+          <disableXmlReport>false</disableXmlReport>
           <skip>true</skip>
         </configuration>
       </plugin>
diff --git a/tck/bval-tomee/pom.xml b/tck/bval-tomee/pom.xml
index 7a56c66..901cac5 100644
--- a/tck/bval-tomee/pom.xml
+++ b/tck/bval-tomee/pom.xml
@@ -113,7 +113,7 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <useFile>false</useFile>
-          <disableXmlReport>true</disableXmlReport>
+          <disableXmlReport>false</disableXmlReport>
           <skip>true</skip>
         </configuration>
       </plugin>
diff --git a/tck/cdi-embedded/pom.xml b/tck/cdi-embedded/pom.xml
index a50e2fa..b7252a9 100644
--- a/tck/cdi-embedded/pom.xml
+++ b/tck/cdi-embedded/pom.xml
@@ -204,7 +204,7 @@
           <forkCount>1</forkCount>
           <argLine>${surefire.argline}</argLine>
           <useFile>false</useFile>
-          <disableXmlReport>true</disableXmlReport>
+          <disableXmlReport>false</disableXmlReport>
           <suiteXmlFiles>
             <suiteXmlFile>${testngSuiteXml}</suiteXmlFile>
           </suiteXmlFiles>
diff --git a/tck/cdi-tomee/pom.xml b/tck/cdi-tomee/pom.xml
index 804d3d4..e725c17 100644
--- a/tck/cdi-tomee/pom.xml
+++ b/tck/cdi-tomee/pom.xml
@@ -225,7 +225,7 @@
           <reuseForks>true</reuseForks>
           <forkCount>1</forkCount>
           <useFile>false</useFile>
-          <disableXmlReport>true</disableXmlReport>
+          <disableXmlReport>false</disableXmlReport>
           <suiteXmlFiles>
             <suiteXmlFile>src/test/resources/${suite.name}.xml</suiteXmlFile>
           </suiteXmlFiles>
diff --git a/tck/tck-common/pom.xml b/tck/tck-common/pom.xml
index 95b4d24..c0ac022 100644
--- a/tck/tck-common/pom.xml
+++ b/tck/tck-common/pom.xml
@@ -79,7 +79,7 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <useFile>false</useFile>
-          <disableXmlReport>true</disableXmlReport>
+          <disableXmlReport>false</disableXmlReport>
         </configuration>
       </plugin>
     </plugins>


[tomee] 02/03: Fix async servlet when HTTP request is wrapped (TCK weird usage)

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f9dc86fc69692f456bde32b3cc3fd6724ba79bfc
Author: Jean-Louis Monteiro <jl...@tomitribe.com>
AuthorDate: Fri Dec 11 12:42:46 2020 +0100

    Fix async servlet when HTTP request is wrapped (TCK weird usage)
---
 .../apache/openejb/cdi/CdiAppContextsService.java  | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
index c5f69eb..ea0d8ca 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
@@ -32,6 +32,10 @@ import java.util.ArrayList;
 import java.util.Collection;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestWrapper;
+import javax.servlet.http.HttpServletRequest;
 
 
 public class CdiAppContextsService extends WebContextsService implements ContextsService {
@@ -114,4 +118,26 @@ public class CdiAppContextsService extends WebContextsService implements Context
     }
 
     public interface FiredManually {}
+
+    @Override
+    protected void initRequestContext(final Object startupObject) {
+        if(startupObject instanceof ServletRequestEvent) {
+
+            // OWB gets the ServletContextWrapper from the event and attempts to cast it to an HttpServletRequest
+            // in TCK, some tests are actually downgrading the HttpServletRequest to a regular ServletRequest
+            // See com.sun.ts.tests.servlet.api.jakarta_servlet.asynccontext
+            // In the look bellow, we try to check if we can find an HttpServletRequest in the hierarchy.
+            // otherwise, we let the call being delegated to OWB
+
+            ServletRequest current = ((ServletRequestEvent) startupObject).getServletRequest();
+            while (!HttpServletRequest.class.isInstance(current) && ServletRequestWrapper.class.isInstance(current)) {
+                current = ServletRequestWrapper.class.cast(current).getRequest();
+            }
+            super.initRequestContext(new ServletRequestEvent(((ServletRequestEvent) startupObject).getServletContext(), current));
+
+        } else {
+            super.initRequestContext(startupObject);
+
+        }
+    }
 }


[tomee] 03/03: Make sure we are consistent and also override other methods from the context wrapper

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fe434759320cae925b93f39a7909d84fb8030080
Author: Jean-Louis Monteiro <jl...@tomitribe.com>
AuthorDate: Fri Dec 11 12:43:28 2020 +0100

    Make sure we are consistent and also override other methods from the context wrapper
---
 .../org/apache/openejb/server/httpd/EEFilter.java  | 29 +++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EEFilter.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EEFilter.java
index 18050c7..045eb43 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EEFilter.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EEFilter.java
@@ -38,6 +38,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
 import java.io.IOException;
 import java.util.Properties;
+import java.util.concurrent.atomic.AtomicReference;
 
 // its pupose is to start/stop request scope in async tasks
 // and ensure logout is propagated to security service
@@ -98,6 +99,9 @@ public class EEFilter implements Filter {
     public static class CdiRequest extends NoCdiRequest {
         private final WebBeansContext webBeansContext;
 
+        // it's a request so not multi-threaded
+        private final AtomicReference<AsynContextWrapper> asyncContextWrapperReference = new AtomicReference<>();
+
         public CdiRequest(final HttpServletRequest cast, final WebBeansContext webBeansContext, final EEFilter filter) {
             super(cast, filter);
             this.webBeansContext = webBeansContext;
@@ -105,12 +109,22 @@ public class EEFilter implements Filter {
 
         @Override
         public AsyncContext startAsync() throws IllegalStateException {
-            return new AsynContextWrapper(super.startAsync(), this, webBeansContext);
+            asyncContextWrapperReference.compareAndSet(null,
+                                                       new AsynContextWrapper(super.startAsync(), this, webBeansContext));
+            return asyncContextWrapperReference.get();
         }
 
         @Override
         public AsyncContext startAsync(final ServletRequest servletRequest, final ServletResponse servletResponse) throws IllegalStateException {
-            return new AsynContextWrapper(super.startAsync(servletRequest, servletResponse), servletRequest, webBeansContext);
+            asyncContextWrapperReference.compareAndSet(null,
+                                                       new AsynContextWrapper(super.startAsync(servletRequest, servletResponse), servletRequest, webBeansContext));
+            return asyncContextWrapperReference.get();
+        }
+
+        @Override
+        public AsyncContext getAsyncContext() {
+            // tomcat won't return our wrapper
+            return asyncContextWrapperReference.get();
         }
     }
 
@@ -163,7 +177,16 @@ public class EEFilter implements Filter {
 
         @Override
         public boolean hasOriginalRequestAndResponse() {
-            return delegate.hasOriginalRequestAndResponse();
+            final boolean tomcatHasOriginalRequestAndResponse = delegate.hasOriginalRequestAndResponse();
+            if (!tomcatHasOriginalRequestAndResponse) {
+                // unfortunately in the startAsync() Tomcat computes the hasOriginalRequestAndResponse flag
+                // Unfortunately we pass in the wrapped request so the flag is false
+                // we need to override the value returned by Tomcat in case we are wrapping the request
+                if (request instanceof NoCdiRequest) { // and CdiRequest
+                    return request == delegate.getRequest(); // Tomcat should have this as the request and not the RequestFacade
+                }
+            }
+            return tomcatHasOriginalRequestAndResponse;
         }
 
         @Override