tabish121 commented on code in PR #6207:
URL: https://github.com/apache/artemis/pull/6207#discussion_r2754851169
##########
artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java:
##########
@@ -81,12 +82,10 @@ public final class StompConnection extends
AbstractRemotingConnection {
//this means login is valid. (stomp connection ok)
private boolean valid;
- private boolean destroyed = false;
+ private AtomicBoolean destroyed = new AtomicBoolean(false);
Review Comment:
For objects like this where there could be many in existence at the same
time or in some use cases can be created and destroyed quickly I tend to prefer
an AtomicIntegerFieldUpdater and a volatile int so that each StompConnection
object doesn't need to create a new AtomicBoolean. Just a minor thing and up
to you if you see value in it for this case.
```
private static final AtomicIntegerFieldUpdater<StompConnection>
DESTROYED_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(StompConnection.class,
"destroyed");
private volatile int destroyed;
...
if (DESTROYED_UPDATER.compareAndSet(this, 0, 1)) {
....
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]