cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <>
Subject Re: Performance issue in StaxInInterceptor
Date Wed, 15 Jul 2009 14:44:08 GMT
On Wed July 15 2009 10:24:01 am Kevin Conaway wrote:
> In cxf-2.2.2, StaxInInterceptor#handleMessage() synchronizes on the
> XMLInputFactory before calling
> XMLInputFactory#createXMLStreamReader(InputStream, String).
> Is this synchronization necessary?  Profiling our application reveals this
> to be a pain point in high volume situations

Well, kind of depends on which Stax implementation.   With woodstox, no.  It 
wasn't necessary.   But if you use the Stax implementation built into JDK6, it 
IS necessary.   Per spec, the XMLInputFactory implementations are not 
guaranteed to be thread safe and the Sun versions are not.   Thus, we need to 
sync on it to create the reader.   Otherwise, we ended up with multiple 
threads using the same XMLStreamReader (and writer) and thus having improper 
results and such.

Not sure what the options are.   I suppose one option could be to use a pool 
of XMLInputFactory objects.   That would avoid the sync on the 
XMLInputFactory, but would introduce a sync on the pool, although that sync 
should be much shorter lived/cheaper.  Obviously slightly higher memory usage 
as well to have multiple factories around.   Probably worth it though.

Daniel Kulp

View raw message