Skip to content

Commit 3a72982

Browse files
active deployment may not be ready when opening properties editor, causing getting active deployment from UI thread, in which case, cache1 would return the last value(maybe null) instead.
1 parent 4a68213 commit 3a72982

File tree

1 file changed

+18
-11
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-springcloud/src/main/java/com/microsoft/azure/toolkit/intellij/springcloud/properties

1 file changed

+18
-11
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-springcloud/src/main/java/com/microsoft/azure/toolkit/intellij/springcloud/properties/SpringCloudAppPropertiesEditor.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class SpringCloudAppPropertiesEditor extends AzResourcePropertiesEditor<S
4949
private final SpringCloudApp app;
5050
@Nonnull
5151
private final SpringCloudAppDraft draft;
52+
private SpringCloudDeploymentDraft deploymentDraft;
5253

5354
public SpringCloudAppPropertiesEditor(@Nonnull Project project, @Nonnull SpringCloudApp app, @Nonnull final VirtualFile virtualFile) {
5455
super(virtualFile, app, project);
@@ -61,16 +62,22 @@ public SpringCloudAppPropertiesEditor(@Nonnull Project project, @Nonnull SpringC
6162

6263
@Override
6364
protected void rerender() {
64-
this.setEnabled(false);
65-
AzureTaskManager.getInstance().runLater(() -> {
66-
this.formConfig.updateForm(this.draft);
67-
this.panelInstances.setApp(this.draft);
68-
this.lblSubscription.setText(this.draft.getSubscription().getName());
69-
this.lblCluster.setText(this.draft.getParent().getName());
70-
this.lblApp.setText(this.draft.getName());
71-
this.refreshToolbar();
72-
this.formConfig.setValue(this.draft);
73-
this.setEnabled(true);
65+
final AzureTaskManager tm = AzureTaskManager.getInstance();
66+
tm.runLater(() -> {
67+
this.setEnabled(false);
68+
tm.runOnPooledThread(() -> {
69+
this.deploymentDraft = this.draft.updateOrCreateActiveDeployment();
70+
tm.runLater(() -> {
71+
this.formConfig.updateForm(this.draft);
72+
this.panelInstances.setApp(this.draft);
73+
this.lblSubscription.setText(this.draft.getSubscription().getName());
74+
this.lblCluster.setText(this.draft.getParent().getName());
75+
this.lblApp.setText(this.draft.getName());
76+
this.refreshToolbar();
77+
this.formConfig.setValue(this.draft);
78+
this.setEnabled(true);
79+
});
80+
});
7481
});
7582
}
7683

@@ -128,7 +135,7 @@ private void reset() {
128135

129136
@Override
130137
public boolean isModified() {
131-
return this.draft.isModified() || this.draft.updateOrCreateActiveDeployment().isModified();
138+
return this.draft.isModified() || this.deploymentDraft.isModified();
132139
}
133140

134141
protected void refresh() {

0 commit comments

Comments
 (0)