[
https://issues.apache.org/activemq/browse/AMQ-2932?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Timothy Bish resolved AMQ-2932.
-------------------------------
Fix Version/s: 5.5.0
Resolution: Fixed
Applied your change to the trunk IdGenerator. Nice catch.
> A little optimization to IdGenerator and a potential issue with the counter
> ---------------------------------------------------------------------------
>
> Key: AMQ-2932
> URL: https://issues.apache.org/activemq/browse/AMQ-2932
> Project: ActiveMQ
> Issue Type: Improvement
> Components: Broker
> Affects Versions: 5.4.1
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 5.5.0
>
>
> At Apache Camel we have a copy of the ActiveMQ IdGenerator
> Camel generator is here
> https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
> ActiveMQ generator is here
> https://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IdGenerator.java
> During some work to introduce pluggable id generators in Camel I did look at
> the source a bit more.
> 1) sequence counter
> The sequence counter is a long primitive which uses ++ to increment. Its
> actually not guaranteed to be an atomic operation across all JVMs and OSs.
> Solution: Use a AtomicLong
> 2) Optimize generateUuid() method
> The generator method concat strings using +
> I did some testing on my laptop and by using StringBuilder I could get it to
> be slightly faster. And I computed the max size the generated id could be so
> the string builder has allocated the space on start.
> Solution: Use StringBuilder
> See the Camel source code for example.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.