[
https://issues.apache.org/jira/browse/VYSPER-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13685488#comment-13685488
]
Emmanuel Lecharny commented on VYSPER-342:
------------------------------------------
When you have a synchronized block, one single thread can access it. Assuming
that the code is CPU intensive, you can quickly make it a bottleneck in your
application (This is in theory, it's not necessarily the case here).
Using a ThreadLocal just remove this constraint : you will have one instance in
each thread, with no sync at all (ThreadLocal storage is done in a Map, not
synchronized).
This is a really good pattern to use in most of the case, especially when the
operation is costly. If it's about incrementing a counter, of course, that
would be dumb...
Makes me think that most of the SimpleDateFormat instances should also be
stored in ThreadLocal...
> Access to UTF-8 encoding and decoding is not thread safe
> --------------------------------------------------------
>
> Key: VYSPER-342
> URL: https://issues.apache.org/jira/browse/VYSPER-342
> Project: VYSPER
> Issue Type: Bug
> Components: core protocol
> Affects Versions: 0.8
> Reporter: Mikko Multanen
> Attachments: fix_charset_util.patch
>
>
> Bug was found when testing server with several simultaneous clients
> connecting at the same time. CharsetDecoder would throw IllegalStateException
> and Stanza XML parsing would fail.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira