Github user michaelandrepearce commented on the issue:
https://github.com/apache/activemq-artemis/pull/1263
this will only occur where the primitive:boxed value is cached, the jvm
will cache/inline upto only a certain amount. If you have a constantly
increasing number like in this case an ID it cannot do this magic.
If like in this case it is an ID rather than something used for arithmetic
then object reference can be as good as a primitive. It would agreed be
terrible if you did arithmetics on it.
The issue with as the code sits currently is that it is autoboxing multiple
times an primitive currently and the id is outside the caching ranges because
it seems ever increasing. As such multiple Long objects are being created. And
destroyed a while later.
After the nudge the Clebert gave with his id solution.
My thoughts are:
If we can either just make the object once and pass it around by reference
or we can use primitive will solve this.
First approach we have tried is primitive and is safe if we ever do
arithmetic on it. Though the complexity is higher (aka special collections).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---