-
Notifications
You must be signed in to change notification settings - Fork 344
Pass in project when querying flutter channel #8883
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ | |
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.HashMap; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
@@ -78,7 +79,7 @@ public class FlutterSdk { | |
|
|
||
| private final @NotNull VirtualFile myHome; | ||
| private final @NotNull FlutterSdkVersion myVersion; | ||
| private final @NotNull Map<String, String> cachedConfigValues = new HashMap<>(); | ||
| private final @NotNull Map<String, String> cachedConfigValues = new ConcurrentHashMap<>(); | ||
|
|
||
| private FlutterSdk(@NotNull final VirtualFile home, @NotNull final FlutterSdkVersion version) { | ||
| myHome = home; | ||
|
|
@@ -583,6 +584,12 @@ public String getDartSdkPath() { | |
| @Nullable | ||
| @NonNls | ||
| public FlutterSdkChannel queryFlutterChannel(boolean useCachedValue) { | ||
| return queryFlutterChannel(useCachedValue, null); | ||
| } | ||
|
|
||
| @Nullable | ||
| @NonNls | ||
| public FlutterSdkChannel queryFlutterChannel(boolean useCachedValue, @Nullable Project project) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [NIT]: According to the Repository Style Guide (Rule 65), References
|
||
| if (useCachedValue) { | ||
| final String channel = cachedConfigValues.get("channel"); | ||
|
helin24 marked this conversation as resolved.
|
||
| if (channel != null) { | ||
|
|
@@ -594,9 +601,9 @@ public FlutterSdkChannel queryFlutterChannel(boolean useCachedValue) { | |
| assert dir != null; | ||
| String branch; | ||
| try { | ||
| branch = git4idea.light.LightGitUtilKt.getLocation(dir, GitExecutableManager.getInstance().getExecutable((Project)null)); | ||
| branch = git4idea.light.LightGitUtilKt.getLocation(dir, GitExecutableManager.getInstance().getExecutable(project)); | ||
| } | ||
| catch (VcsException e) { | ||
| catch (VcsException | IllegalStateException e) { | ||
| final String stdout = returnOutputOfQuery(flutterChannel()); | ||
| if (stdout == null) { | ||
| branch = "unknown"; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[MUST-FIX]: The switch to
ConcurrentHashMapis a good improvement for thread safety. However, unlikeHashMap,ConcurrentHashMapdoes not allownullvalues. InqueryFlutterChannel(line 616), thebranchvariable (assigned fromgetLocationorparseChannel) could potentially benull, which would cause aNullPointerExceptionwhen callingcachedConfigValues.put("channel", branch). Please ensure that a non-null default value (e.g., "unknown") is used if the result is null.