You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2018/10/17 12:58:29 UTC
[cxf] branch master updated: Only check for servlet 3.1 once.
Class.forName is a synchonized (and expensive) call. Don't do it
per-request.
This is an automated email from the ASF dual-hosted git repository.
dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new 07a61c5 Only check for servlet 3.1 once. Class.forName is a synchonized (and expensive) call. Don't do it per-request.
07a61c5 is described below
commit 07a61c5c6d52eb242414ea39b20ed3abd5dd99dd
Author: Daniel Kulp <dk...@apache.org>
AuthorDate: Wed Oct 17 07:31:31 2018 -0400
Only check for servlet 3.1 once. Class.forName is a synchonized (and expensive) call. Don't do it per-request.
---
.../http/Servlet3ContinuationProvider.java | 23 ++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
index 364364b..9492489 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
@@ -41,11 +41,22 @@ import org.apache.cxf.phase.PhaseInterceptorChain;
*
*/
public class Servlet3ContinuationProvider implements ContinuationProvider {
+ static final boolean IS_31;
+ static {
+ boolean is31 = false;
+ try {
+ ClassLoaderUtils.loadClass("javax.servlet.WriteListener", HttpServletRequest.class);
+ is31 = true;
+ } catch (Throwable t) {
+ is31 = false;
+ }
+ IS_31 = is31;
+ }
+
HttpServletRequest req;
HttpServletResponse resp;
Message inMessage;
Servlet3Continuation continuation;
- boolean is31;
public Servlet3ContinuationProvider(HttpServletRequest req,
HttpServletResponse resp,
@@ -53,14 +64,6 @@ public class Servlet3ContinuationProvider implements ContinuationProvider {
this.inMessage = inMessage;
this.req = req;
this.resp = resp;
-
-
- try {
- ClassLoaderUtils.loadClass("javax.servlet.WriteListener", HttpServletRequest.class);
- is31 = true;
- } catch (Throwable t) {
- is31 = false;
- }
}
public void complete() {
@@ -78,7 +81,7 @@ public class Servlet3ContinuationProvider implements ContinuationProvider {
}
if (continuation == null) {
- continuation = is31 ? new Servlet31Continuation() : new Servlet3Continuation();
+ continuation = IS_31 ? new Servlet31Continuation() : new Servlet3Continuation();
} else {
continuation.startAsyncAgain();
}