isaric commented on code in PR #5417:
URL: https://github.com/apache/solr/pull/5417#discussion_r4765464656
##########
gradle/testing/randomization.gradle:
##########
@@ -132,6 +132,10 @@ configure(allprojects.findAll {project ->
project.path.startsWith(":solr")}) {
[propName: 'solr.tests.use.numeric.points', value: null,
description: "Point implementation to use (true=numerics, false=trie)."],
[propName: 'tests.ssl', value: null, description: "Control SSL:
true=force on, false=force off, unset=randomize (all respect @SuppressSSL)."],
[propName: 'tests.selenium', value: false, description: "Enables or
disables @SeleniumTest tests (browser-based, need a local Chrome)."],
+ [propName: 'solr.simpleOrderedMap.assertUniqueKeys',
Review Comment:
Removed. The flag now defaults to the `tests.nightly` system property, which
the test runner already passes to every test JVM, so no build change is needed;
it can still be forced with `-Dsolr.simpleOrderedMap.assertUniqueKeys=true` via
`tests.jvmargs`.
##########
solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java:
##########
@@ -89,6 +99,34 @@ public EntryWriter put(CharSequence k, Object v) throws
IOException {
}
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>Keys are expected to be unique; see {@link #ASSERT_UNIQUE_KEYS_PROP}.
To replace a value use
+ * {@link #put}; if repeated keys are intended, use a {@link NamedList}.
+ */
+ @Override
+ public void add(String name, T val) {
+ if (assertUniqueKeys && name != null && indexOf(name, 0) >= 0) {
Review Comment:
Done: `add` now uses `assert`, with the static final flag folded into the
condition, so the check disappears entirely without `-ea` and the JIT drops it
when the flag is false.
##########
solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java:
##########
@@ -47,6 +47,16 @@ public final class SimpleOrderedMap<T> extends NamedList<T>
implements Map<Strin
private static final long serialVersionUID = -8705511030983987520L;
+ /**
+ * System property (or env var {@code
SOLR_SIMPLEORDEREDMAP_ASSERTUNIQUEKEYS}) that makes {@link
+ * #add} and {@link #addAll(NamedList)} fail on a key that is already
present. Off by default; the
+ * Solr build turns it on for nightly test runs so that code relying on
repeated keys shows up.
+ */
+ public static final String ASSERT_UNIQUE_KEYS_PROP =
"solr.simpleOrderedMap.assertUniqueKeys";
+
+ // not final so that tests can toggle it
Review Comment:
Done: `private static final`, read once at class init; the tests that
toggled it are gone.
##########
solr/solrj/src/test/org/apache/solr/common/util/SimpleOrderedMapTest.java:
##########
Review Comment:
Dropped all three; the nightly run itself is the test. The two producers it
found are SOLR-18697 and SOLR-18698.
--
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]