Unnecesary JAXBContext creation during request processing
---------------------------------------------------------
Key: AXIS2-4974
URL: https://issues.apache.org/jira/browse/AXIS2-4974
Project: Axis2
Issue Type: Bug
Components: jaxws
Affects Versions: 1.5.2
Environment: Axis2-jaxws
Reporter: Victor Downs
Here at my job we've been using Axis2 since version 1.4.1
During the design phase of our last project we decided to try JAXWS. The
project is now in production, but users reported slower performance overall
compared to previous versions of the same service. Another colleage
reengineered the project to use ADB and tested it, obtaining a performance
increase of 10x (!!). Unfortunately we cannot revert to ADB since both ADB and
JAXWS generate the WSDL with slight (but incompatible) differences, which would
require a code re-write on the clients' side.
Long story short, I profiled the application and noticed that a new JAXBContext
was instantiated about 4 times per client request, consuming about 60% of CPU
time, so I downloaded and debugged the axis2-jaxws module, finding what I think
is a bug on the JAXBContext cache handling code.
Around linke 272 of JAXBUtils class we find this (comments are mine):
/*272*/ softRef2 = jaxbMap.get(validPackagesKey); // Get
validPackagesKey from cache
/*273*/ if (softRef2 != null) { // Key found?
/*274*/ map2 = softRef.get();
/*275*/ }
/*276*/ if (map2 == null) { // Map not found?
/*277*/ map2 = new ConcurrentHashMap<ClassLoader,
JAXBContextValue>();
/*278*/ softRef2 =
/*279*/ new
SoftReference<ConcurrentHashMap<ClassLoader, JAXBContextValue>>(map2);
/*280*/ jaxbMap.put(key, softRef2); // ERROR (I
think) => New map inserted with key instead of validPackagesKey!!
/*281*/ }
I recompiled the jar changing 'key' for 'validPackagesKey' on line 280,
replaced the original JAR and re-tested. New JAXBContext's are only created
during the first invocation and performance is now comparable to the ADB
version (10 times better). We still have to make regression tests on QA to
ensure that this change doesn't affect anything else, but I though I should let
you know about this.
The fully qualified name of the affected class is
org.apache.axis2.jaxws.message.databinding.JAXBUtils, and the version we're
currently using is Axis2-1.5.2
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]