Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17014: Ensure that injecting random recording flag only happens under randomized context SOLR-16960 (#1983)

Kevin Risden9fde70b9e7ff
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
index 75113bc5b66..3b8d4e1c774 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
@@ -1318,8 +1318,13 @@ public class MiniSolrCloudCluster {
* mechanics.
*/
private static void injectRandomRecordingFlag() {
- boolean isRecording = LuceneTestCase.rarely();
- TraceUtils.IS_RECORDING = (ignored) -> isRecording;
+ try {
+ boolean isRecording = LuceneTestCase.rarely();
+ TraceUtils.IS_RECORDING = (ignored) -> isRecording;
+ } catch (IllegalStateException e) {
+ // This can happen in benchmarks or other places that aren't in a randomized test
+ log.warn("Unable to inject random recording flag due to outside randomized context", e);
+ }
}
private static void resetRecordingFlag() {