cshannon commented on PR #2401: URL: https://github.com/apache/activemq/pull/2401#issuecomment-5185177781
Does anything actually change the listener after bridge creation? I know there is a setter but I did a quick search and I didn't see anything using it after construction. If there's nothing that will change the listener later then there is no need to make it volatile because during construction it's set and then [added](https://github.com/apache/activemq/blob/c8b20b9feb70b161f2410d23f861924fafe3d6c0/activemq-broker/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java#L165) to the map under lock before start is called. If it's already set at that point then the lock creates a happens before (for anything using the same lock). Also when it's used by other threads, i think we use an executor and passing to an executor should also establish a happens-before. So TLDR is unless something changes it after start is called (ie dynamically switching it out) I don't think it needs to be volatile. This might be a case where the listener should really just be part of the constructor if it's immutable anyways. -- 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] For further information, visit: https://activemq.apache.org/contact
