Skip to content

Commit 7838611

Browse files
authored
Merge pull request #5276 from microsoft/bugfix-preload-bug
Fix bug of sp login:java.lang.IllegalStateException: Attempt to mutate in notification
2 parents 1214cbf + fc5c15e commit 7838611

File tree

2 files changed

+30
-32
lines changed

2 files changed

+30
-32
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/ui/ServicePrincipalLoginDialog.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -276,39 +276,38 @@ private void uiTextComponents2Json() {
276276
}
277277

278278
private void json2UIComponents(String json) {
279-
intermediateState = true;
280279
try {
281-
if (StringUtils.isNotBlank(json)) {
282-
try {
283-
Map<String, String> map = JsonUtils.fromJson(json, HashMap.class);
284-
if (map != null) {
285-
ApplicationManager.getApplication().invokeAndWait(() -> {
286-
if (map.containsKey("appId")) {
287-
this.clientIdTextField.setText(StringUtils.defaultString(map.get("appId")));
288-
}
289-
290-
if (map.containsKey("tenant")) {
291-
this.tenantIdTextField.setText(StringUtils.defaultString(map.get("tenant")));
292-
}
293-
294-
if (map.containsKey("password") && !isPlaceHolder(map.get("password"))) {
295-
this.passwordRadioButton.setSelected(true);
296-
this.keyPasswordField.setText(StringUtils.defaultString(map.get("password")));
297-
}
298-
299-
if (map.containsKey("fileWithCertAndPrivateKey")) {
300-
this.certificateRadioButton.setSelected(true);
301-
this.certFileTextField.setText(StringUtils.defaultString(map.get("fileWithCertAndPrivateKey")));
302-
}
303-
});
280+
Map<String, String> map = JsonUtils.fromJson(json, HashMap.class);
281+
if (map != null) {
282+
ApplicationManager.getApplication().invokeLater(() -> {
283+
intermediateState = true;
284+
try {
285+
if (map.containsKey("appId")) {
286+
this.clientIdTextField.setText(StringUtils.defaultString(map.get("appId")));
287+
}
288+
289+
if (map.containsKey("tenant")) {
290+
this.tenantIdTextField.setText(StringUtils.defaultString(map.get("tenant")));
291+
}
292+
293+
if (map.containsKey("password") && !isPlaceHolder(map.get("password"))) {
294+
this.passwordRadioButton.setSelected(true);
295+
this.keyPasswordField.setText(StringUtils.defaultString(map.get("password")));
296+
}
297+
298+
if (map.containsKey("fileWithCertAndPrivateKey")) {
299+
this.certificateRadioButton.setSelected(true);
300+
this.certFileTextField.setText(StringUtils.defaultString(map.get("fileWithCertAndPrivateKey")));
301+
}
302+
} finally {
303+
intermediateState = false;
304304
}
305305

306-
} catch (JsonSyntaxException ex) {
307-
// ignore all json errors
308-
}
306+
});
309307
}
310-
} finally {
311-
intermediateState = false;
308+
309+
} catch (JsonSyntaxException ex) {
310+
// ignore all json errors
312311
}
313312
}
314313

Utils/azuretools-core/src/com/microsoft/azuretools/authmanage/AuthMethodManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ private void initAuthMethodManagerFromSettings() {
296296
List<String> savedSubscriptionList = persistSubscriptions.stream().filter(SubscriptionDetail::isSelected).map(SubscriptionDetail::getSubscriptionId).distinct().collect(Collectors.toList());
297297
identityAzureManager.selectSubscriptionByIds(savedSubscriptionList);
298298
}
299-
299+
initFuture.complete(true);
300300
// pre-load regions
301301
AzureAccount az = com.microsoft.azure.toolkit.lib.Azure.az(AzureAccount.class);
302-
Optional.of(identityAzureManager.getSelectedSubscriptionIds()).ifPresent(sids -> sids.forEach(az::listRegions));
302+
Optional.of(identityAzureManager.getSelectedSubscriptionIds()).ifPresent(sids -> sids.stream().limit(5).forEach(az::listRegions));
303303

304304
final String authMethod = authMethodDetails.getAuthMethod() == null ? "Empty" : authMethodDetails.getAuthMethod().name();
305305
final Map<String, String> telemetryProperties = new HashMap<String, String>() {
@@ -308,7 +308,6 @@ private void initAuthMethodManagerFromSettings() {
308308
put(AZURE_ENVIRONMENT, CommonSettings.getEnvironment().getName());
309309
}
310310
};
311-
initFuture.complete(true);
312311
EventUtil.logEvent(EventType.info, operation, telemetryProperties);
313312
} catch (RuntimeException exception) {
314313
initFuture.complete(true);

0 commit comments

Comments
 (0)