Skip to content

[CQ] stop storing property service instance #8118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions flutter-idea/src/io/flutter/survey/FlutterSurveyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ public class FlutterSurveyService {
private static final String FLUTTER_LAST_SURVEY_CONTENT_CHECK_KEY = "FLUTTER_LAST_SURVEY_CONTENT_CHECK_KEY";
private static final long CHECK_INTERVAL_IN_MS = TimeUnit.HOURS.toMillis(40);
private static final String CONTENT_URL = "https://storage.googleapis.com/flutter-uxr/surveys/flutter-survey-metadata.json";
private static final PropertiesComponent properties = PropertiesComponent.getInstance();
private static final Logger LOG = Logger.getInstance(FlutterSurveyService.class);
private static FlutterSurvey cachedSurvey;
private static @Nullable FlutterSurvey cachedSurvey;

private static boolean timeToUpdateCachedContent() {
// Don't check more often than daily.
final long currentTimeMillis = System.currentTimeMillis();
final long lastCheckedMillis = properties.getLong(FLUTTER_LAST_SURVEY_CONTENT_CHECK_KEY, 0);
final boolean timeToUpdateCache = currentTimeMillis - lastCheckedMillis >= CHECK_INTERVAL_IN_MS;
if (timeToUpdateCache) {
properties.setValue(FLUTTER_LAST_SURVEY_CONTENT_CHECK_KEY, String.valueOf(currentTimeMillis));
return true;
final PropertiesComponent properties = PropertiesComponent.getInstance();
if (properties != null) {
final long lastCheckedMillis = properties.getLong(FLUTTER_LAST_SURVEY_CONTENT_CHECK_KEY, 0);
final boolean timeToUpdateCache = currentTimeMillis - lastCheckedMillis >= CHECK_INTERVAL_IN_MS;
if (timeToUpdateCache) {
properties.setValue(FLUTTER_LAST_SURVEY_CONTENT_CHECK_KEY, String.valueOf(currentTimeMillis));
return true;
}
}
return false;
}
Expand Down