dsmiley commented on code in PR #4538: URL: https://github.com/apache/solr/pull/4538#discussion_r4734903371
########## solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java: ########## @@ -23,20 +23,22 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiConsumer; +import java.util.function.Function; import java.util.function.Supplier; +import java.util.stream.Collectors; +import net.jcip.annotations.Immutable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * Models a Collection in zookeeper (but that Java name is obviously taken, hence "DocCollection") - */ +/** A Solr Collection; it's state/metadata. */ +@Immutable Review Comment: 🤖 Good point. Added a javadoc caveat: immutable except that with PRS the replica states are refreshed in place. Fully removing that is out of scope here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ########## solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java: ########## @@ -268,6 +272,11 @@ public DocCollection copyWithSlices(Map<String, Slice> slices) { return result; } + @Override + public Map<String, Object> getProperties() { + return Collections.unmodifiableMap(super.getProperties()); Review Comment: 🤖 Making `ZkNodeProps` immutable would affect `Replica` and `Slice` too, and some code legitimately mutates their props (see below), so I'd rather keep that as a separate effort. The override here is local to `DocCollection`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ########## solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java: ########## @@ -268,6 +272,11 @@ public DocCollection copyWithSlices(Map<String, Slice> slices) { return result; } + @Override + public Map<String, Object> getProperties() { + return Collections.unmodifiableMap(super.getProperties()); Review Comment: 🤖 Right, but `ExclusiveSliceProperty` mutates `Replica.getProperties()` (on a copied `Slice`), not `DocCollection`'s props, so it doesn't conflict with the `DocCollection` override. It does show why the base class can't simply become immutable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
