Skip to content

Apache Lucene open-source search software

SOLR-12728: RequestLoggingTest fails on occasion, not reproducible

Erick Erickson74b53b1a6756
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 74d73b68598..1ba77adb78f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -298,6 +298,8 @@ Bug Fixes
* SOLR-12704: Guard AddSchemaFieldsUpdateProcessorFactory against null field names and field values.
(Steve Rowe, Varun Thacker)
+* SOLR-12728: RequestLoggingTest fails on occasion, not reproducible (Erick Erickson)
+
Optimizations
----------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java b/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java
index 0e8a7a9b64c..ae08e9a09d9 100644
--- a/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/RequestLoggingTest.java
@@ -82,10 +82,23 @@ public class RequestLoggingTest extends SolrTestCaseJ4 {
try {
assertQ(req("q", "*:*"));
-
- String output = writer.toString();
- Matcher matcher = Pattern.compile("DEBUG.*q=\\*:\\*.*").matcher(output);
- assertTrue(matcher.find());
+ Matcher matcher = null;
+ boolean foundDebugMsg = false;
+ String output = "";
+ for (int msgIdx = 0; msgIdx < 100; ++msgIdx) {
+ output = writer.toString();
+ matcher = Pattern.compile("DEBUG.*q=\\*:\\*.*").matcher(output);
+ if (matcher.find()) {
+ foundDebugMsg = true;
+ break;
+ }
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException ie) {
+ ;
+ }
+ }
+ assertTrue("Should have found debug-level message. Found " + output, foundDebugMsg);
final String group = matcher.group();
final String msg = "Should not have post query information";
assertFalse(msg, group.contains("hits"));
diff --git a/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java b/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java
index 9548363c893..658bc34c31e 100644
--- a/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java
+++ b/solr/core/src/test/org/apache/solr/logging/TestLogWatcher.java
@@ -53,7 +53,6 @@ public class TestLogWatcher extends SolrTestCaseJ4 {
// Loop to give the logger time to process the async message and notify the new watcher.
boolean foundMsg = false;
- long last = -1;
// In local testing this loop usually succeeds 1-2 tries.
for (int msgIdx = 0; msgIdx < 100; ++msgIdx) {
// Returns an empty (but non-null) list even if there are no messages yet.