Skip to content

Commit 13b4427

Browse files
fix context issue about getting started.
1 parent e64d4a8 commit 13b4427

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-applicationinsights/src/main/java/com/microsoft/azure/toolkit/intellij/applicationinsights/task/CreateApplicationInsightsResourceConnectionTask.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,19 @@ public void execute() {
4141
final Module module = getModule();
4242
final Resource consumer = getModuleConsumer(module);
4343
final AzureModule azureModule = AzureModule.from(module);
44-
AzureTaskManager.getInstance().runAndWait(() -> {
44+
final AzureTaskManager tm = AzureTaskManager.getInstance();
45+
tm.runAndWait(() -> tm.write(() -> {
4546
final Profile profile = azureModule.initializeWithDefaultProfileIfNot();
46-
if (Objects.isNull(profile)) {
47-
return;
48-
}
4947
final Connection<?, ?> connection = ConnectionManager.getDefinitionOrDefault(resource.getDefinition(),
50-
consumer.getDefinition()).define(resource, consumer);
48+
consumer.getDefinition()).define(resource, consumer);
5149
if (connection.validate(this.project)) {
5250
profile.createOrUpdateConnection(connection);
5351
profile.save();
5452
final String message = String.format("The connection between %s and %s has been successfully created.",
55-
resource.getName(), consumer.getName());
53+
resource.getName(), consumer.getName());
5654
AzureMessager.getMessager().success(message);
5755
}
58-
});
56+
}));
5957
}
6058

6159
@Nonnull
@@ -66,7 +64,7 @@ public String getName() {
6664

6765
private Resource<ApplicationInsight> getResource() {
6866
final String applicationInsightsId = (String) Objects.requireNonNull(context.getParameter("applicationInsightsId"),
69-
"`applicationInsightsId` should not be null to create a resource connection");
67+
"`applicationInsightsId` should not be null to create a resource connection");
7068
final ApplicationInsight applicationInsight = Azure.az(AzureApplicationInsights.class).getById(applicationInsightsId);
7169
return ApplicationInsightsResourceDefinition.INSTANCE.define(applicationInsight);
7270
}

0 commit comments

Comments
 (0)