Skip to content

Commit

Permalink
Fix errors in quick fix of vulnerable Maven dependencies (#424)
Browse files Browse the repository at this point in the history
* Fix errors in quick fix of vulnerable Maven dependencies.
  • Loading branch information
asafgabai authored Sep 26, 2023
1 parent 8c1cd30 commit 5c23b6e
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
Expand Down Expand Up @@ -55,13 +56,17 @@ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descri
Task.Backgroundable scanAndUpdateTask = new Task.Backgroundable(project, "Upgrading dependency...") {
@Override
public void run(@NotNull com.intellij.openapi.progress.ProgressIndicator indicator) {
try {
upgradeComponentVersion(project, descriptor);
ApplicationManager.getApplication().invokeLater(() -> descriptor.getPsiElement().getContainingFile().getVirtualFile().refresh(false, false));
log.info("Upgraded " + componentName + " to version " + fixVersion + " successfully.");
} catch (Exception e) {
log.error("Failed while trying to upgrade component " + componentName + " to version " + fixVersion + ". Error: " + e);
}
ApplicationManager.getApplication().invokeAndWait(() -> {
WriteCommandAction.runWriteCommandAction(project, () -> {
try {
upgradeComponentVersion(project, descriptor);
log.info("Upgraded " + componentName + " to version " + fixVersion + " successfully.");
} catch (IOException e) {
log.error("Failed while trying to upgrade component " + componentName + " to version " + fixVersion + ". Error: " + e);
}
});
descriptor.getPsiElement().getContainingFile().getVirtualFile().refresh(false, false);
});
}
};
ProgressManager.getInstance().run(scanAndUpdateTask);
Expand Down

0 comments on commit 5c23b6e

Please sign in to comment.