Skip to content
Permalink
Browse files
Merge pull request #1963 from andresrc/JENKINS-32190
[JENKINS-32190] Check init status in UsageStatistics
  • Loading branch information
daniel-beck committed Jan 11, 2016
2 parents aac48ad + d8a13ac commit f71725202159a7fd1ba588c30ee0602477533370
Showing with 7 additions and 3 deletions.
  1. +7 −3 core/src/main/java/hudson/model/UsageStatistics.java
@@ -31,6 +31,7 @@
import hudson.util.IOUtils;
import hudson.util.Secret;
import static hudson.util.TimeUnit2.DAYS;
import static hudson.init.InitMilestone.COMPLETED;

import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
@@ -95,9 +96,12 @@ public UsageStatistics(String keyImage) {
* Returns true if it's time for us to check for new version.
*/
public boolean isDue() {
// user opted out. no data collection.
if(!Jenkins.getInstance().isUsageStatisticsCollected() || DISABLED) return false;

final Jenkins j = Jenkins.getInstance();
// user opted out or Jenkins not fully initialized. no data collection.
if (j == null || j.isUsageStatisticsCollected() || DISABLED || COMPLETED.compareTo(j.getInitLevel()) > 0) {
return false;
}

long now = System.currentTimeMillis();
if(now - lastAttempt > DAY) {
lastAttempt = now;

0 comments on commit f717252

Please sign in to comment.