Skip to content

Commit

Permalink
Preload SideEffectingActionTrackingService.SideEffectiveActionId cl…
Browse files Browse the repository at this point in the history
…ass so that it does not end up loaded from action update()
  • Loading branch information
PawelLipski committed Aug 21, 2023
1 parent 06e6d16 commit ae3ab06
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,14 @@ jobs:
labels: intellij-support

- run:
# These updates don't seem to be supported by dependabot as of August 2023.
# These updates don't seem to be supported by dependabot as of August 2023,
# see https://github.com/dependabot/dependabot-core/issues/2223
name: Check for updates of Gradle
# language=sh
command: |
latest_gradle_version=$(curl -fsSL https://services.gradle.org/versions/current | jq -r .version)
./gradlew wrapper --gradle-version=$latest_gradle_version # this only updates gradle-wrapper.properties
./gradlew # to actually pull the new wrapper script/jar
./gradlew dependencies # to actually pull the new wrapper script/jar
echo "$latest_gradle_version" > /tmp/gradle-version
- create_pull_request_if_files_changed:
branch_name_prefix: update-gradle
Expand Down
1 change: 1 addition & 0 deletions CHANGE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## v4.0.2
- Fixed: more `com.intellij.diagnostic.PluginException: ... ms to call on EDT ...#update@...` errors (reported by @itxshakil)

## v4.0.1
- Fixed: `com.intellij.diagnostic.PluginException: ... ms to call on EDT ...#update@...` errors due to loading of classes from action update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@

@ExtensionMethod({GitMacheteBundle.class})
public abstract class BaseProjectDependentAction extends DumbAwareAction implements IWithLogger {

// Let's eagerly load these classes so that they do NOT end up loaded from an action `update` method.
// See issues #1692, #1694, #1713.
static {
@SuppressWarnings("nullness:argument") val dummyService = new SideEffectingActionTrackingService(null);

@SuppressWarnings("nullness:argument") val dummyId = new SideEffectingActionTrackingService.SideEffectiveActionId(null);
}

@Override
public final ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.EDT;
Expand All @@ -38,12 +47,6 @@ public boolean isLoggingAcceptable() {

protected abstract boolean isSideEffecting();

// Let's eagerly load the service *class* so that it does NOT end up loaded from an action `update` method.
// See https://github.com/VirtusLab/git-machete-intellij-plugin/issues/1692
// and https://github.com/VirtusLab/git-machete-intellij-plugin/issues/1694.
@SuppressWarnings("nullness:argument")
private static SideEffectingActionTrackingService DUMMY_SERVICE = new SideEffectingActionTrackingService(null);

@SuppressWarnings("tainting:return")
protected static @Nullable @Untainted String getOngoingSideEffectingActions(Project project) {
val actions = project.getService(SideEffectingActionTrackingService.class).getOngoingActions();
Expand All @@ -53,7 +56,7 @@ public boolean isLoggingAcceptable() {
if (actions.size() == 1) {
return actions.head();
}
val sorted = actions.toList();
val sorted = actions.toList().sorted();
return sorted.init().mkString(", ") + " and " + sorted.last();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.intellij.openapi.project.Project;
import io.vavr.collection.HashSet;
import io.vavr.collection.Set;
import io.vavr.collection.SortedSet;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.val;
Expand All @@ -15,7 +14,8 @@ public final class SideEffectingActionTrackingService {
// Let's compare action ids by reference, in case there are multiple actions with the same name going on.
// We don't want that finishing one of these actions gives an impression as if all of them completed.
@RequiredArgsConstructor
static class SideEffectiveActionId {
public static class SideEffectiveActionId {

@Getter
private final @Untainted String name;

Expand All @@ -35,8 +35,8 @@ public synchronized SideEffectingActionClosable register(@Untainted String id) {
return new SideEffectingActionClosable(actionId);
}

public synchronized SortedSet<String> getOngoingActions() {
return ongoingActions.map(a -> a.toString()).toSortedSet();
public synchronized Set<String> getOngoingActions() {
return ongoingActions.map(a -> a.toString());
}

@RequiredArgsConstructor
Expand Down

0 comments on commit ae3ab06

Please sign in to comment.