From 0285c1820882f80a69c064aed5f1386d14eae37d Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 4 Sep 2024 17:53:28 -0400 Subject: [PATCH] Avoid calling `Jenkins.setNoUsageStatistics` unless necessary --- src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java index 224fc8dd7..2640b50a5 100644 --- a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java +++ b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java @@ -1345,7 +1345,9 @@ public static final class CustomJenkinsRule extends JenkinsRule implements AutoC public CustomJenkinsRule(URL url) throws Exception { this.jenkins = Jenkins.get(); this.url = url; - jenkins.setNoUsageStatistics(true); // cannot use JenkinsRule._configureJenkinsForTest earlier because it tries to save config before loaded + if (jenkins.isUsageStatisticsCollected()) { + jenkins.setNoUsageStatistics(true); // cannot use JenkinsRule._configureJenkinsForTest earlier because it tries to save config before loaded + } if (JenkinsLocationConfiguration.get().getUrl() == null) { JenkinsLocationConfiguration.get().setUrl(url.toExternalForm()); }