Skip to content

Apache Lucene open-source search software

LUCENE-6760: if the list of whitspace characters changes again in a future JVM, fail fast with a clear error that the test needs corrected -- even if jvm assertions are disabled OR we get really lucky with the chars radnomly selected

Chris M. Hostetterbb32ecb0fd9d
diff --git a/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java b/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
index 30862d8391e..fc5fece7be1 100644
--- a/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
+++ b/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
@@ -385,6 +385,19 @@ public class ReturnFieldsTest extends SolrTestCaseJ4 {
'\u205F',
'\u3000',
};
+
+ static {
+ // if the JVM/unicode can redefine whitespace once (LUCENE-6760), it might happen again
+ // in the future. if that happens, fail early with a clera msg, even if java asserts
+ // (used in randomWhitespace) are disbled
+
+ for (int offset = 0; offset < WHITESPACE_CHARACTERS.length; offset++) {
+ char c = WHITESPACE_CHARACTERS[offset];
+ if (! Character.isWhitespace(c) ) {
+ fail(String.format(Locale.ENGLISH, "Not really whitespace? New JVM/Unicode definitions? WHITESPACE_CHARACTERS[%d] is '\\u%04X'", offset, (int) c));
+ }
+ }
+ }
/**
* Returns a random string in the specified length range consisting