jbertram commented on code in PR #6029:
URL: https://github.com/apache/activemq-artemis/pull/6029#discussion_r2511077523
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java:
##########
@@ -102,6 +102,17 @@ public void setSwept(boolean swept) {
private AddressInfo() {
}
+ /**
+ * Constructs a new {@code AddressInfo} object by copying the name and
routing types
+ * from another {@code AddressInfo} instance.
+ *
+ * @param other the {@code AddressInfo} instance to copy from. The name and
routing types
+ * from this instance will be used to initialize the new
{@code AddressInfo}.
+ */
+ public AddressInfo(AddressInfo other) {
+ this(other.getName(), EnumSet.copyOf(other.getRoutingTypes()));
+ }
Review Comment:
It's certainly possible that a partial copy constructor could cause
confusion. I added JavaDoc to help mitigate that risk.
I was actually using `AddressInfo(SimpleString name, EnumSet<RoutingType>
routingTypes)` directly at one point, but I wasn't using `EnumSet.copyOf` so it
was causing other issues. Once I realized I needed `EnumSet.copyOf` I thought
it would be helpful to codify its use in a copy constructor to prevent other
such errors in the future.
Generally speaking, the `AddressInfo` class is kind of confusing since it
acts as a container for configuration information that is passed around a lot
simply to represent a name + routing-types, but it is also used for runtime
info (e.g. various counts and statuses). We should probably eventually split
these two concerns apart like we have with the queue (i.e. using
`QueueConfiguration` and `QueueImpl`).
In any event, I can remove the copy constructor and use the other
constructor directly if that's ultimately desired.
--
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