Skip to content

Commit ef97023

Browse files
Merge pull request #6981 from microsoft/endgame-202209
Merge fixes in endgame to endgame next
2 parents 222a460 + d6fc5f2 commit ef97023

File tree

7 files changed

+38
-21
lines changed

7 files changed

+38
-21
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/core/FunctionUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ public static boolean isFunctionProject(Project project) {
193193
type = AzureOperation.Type.TASK
194194
)
195195
public static PsiMethod[] findFunctionsByAnnotation(Module module) {
196+
if (module == null) {
197+
return new PsiMethod[0];
198+
}
196199
final PsiClass functionNameClass = JavaPsiFacade.getInstance(module.getProject())
197200
.findClass(AZURE_FUNCTION_ANNOTATION_CLASS,
198201
GlobalSearchScope.moduleWithLibrariesScope(module));

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/ui/FunctionDeploymentPanel.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,18 @@ protected void resetFromConfig(@NotNull FunctionDeployConfiguration configuratio
142142
if (StringUtils.isNotEmpty(configuration.getAppSettingsKey())) {
143143
this.appSettingsKey = configuration.getAppSettingsKey();
144144
}
145-
Optional.ofNullable(configuration.getConfig()).ifPresent(config -> {
146-
this.functionAppComboBox.setValue(config);
147-
this.functionAppComboBox.setConfigModel(config);
148-
this.chkSlot.setSelected(config.getDeploymentSlot() != null);
149-
this.toggleDeploymentSlot(config.getDeploymentSlot() != null);
150-
this.appSettingsResourceId = StringUtils.isAllEmpty(config.getResourceId(), config.getName()) ? null :
151-
getResourceId(config, config.getDeploymentSlot());
152-
Optional.ofNullable(config.getDeploymentSlot()).ifPresent(cbDeploymentSlot::setValue);
153-
Optional.ofNullable(config.getAppSettings()).ifPresent(appSettingsTable::setAppSettings);
154-
});
145+
Optional.ofNullable(configuration.getConfig())
146+
.filter(config -> !StringUtils.isAllEmpty(config.getResourceId(), config.getName()))
147+
.ifPresent(config -> {
148+
this.functionAppComboBox.setValue(config);
149+
this.functionAppComboBox.setConfigModel(config);
150+
this.chkSlot.setSelected(config.getDeploymentSlot() != null);
151+
this.toggleDeploymentSlot(config.getDeploymentSlot() != null);
152+
this.appSettingsResourceId = StringUtils.isAllEmpty(config.getResourceId(), config.getName()) ? null :
153+
getResourceId(config, config.getDeploymentSlot());
154+
Optional.ofNullable(config.getDeploymentSlot()).ifPresent(cbDeploymentSlot::setValue);
155+
Optional.ofNullable(config.getAppSettings()).ifPresent(appSettingsTable::setAppSettings);
156+
});
155157
this.previousModule = configuration.getModule();
156158
selectModule(previousModule);
157159
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppRunState.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.microsoft.intellij.RunProcessHandler;
4242
import org.apache.commons.collections4.MapUtils;
4343
import org.apache.commons.compress.utils.FileNameUtils;
44+
import org.apache.commons.lang3.ObjectUtils;
4445
import org.apache.commons.lang3.StringUtils;
4546
import org.jetbrains.annotations.NotNull;
4647
import org.jetbrains.annotations.Nullable;
@@ -138,7 +139,8 @@ private void updateAppServiceVMOptions(AppServiceAppBase<?, ?, ?> deployTarget,
138139
final Map<String, String> applicationSettings = webAppConfiguration.getApplicationSettings();
139140
final WebContainer webContainer = Objects.requireNonNull(deployTarget.getRuntime()).getWebContainer();
140141
final String javaOptsParameter = (webContainer == WebContainer.JAVA_SE || webContainer == WebContainer.JBOSS_7) ? JAVA_OPTS : CATALINA_OPTS;
141-
final String javaOpts = applicationSettings.get(javaOptsParameter);
142+
final String javaOpts = Optional.ofNullable(webAppConfiguration.getApplicationSettings())
143+
.map(settings -> settings.get(javaOptsParameter)).orElse(StringUtils.EMPTY);
142144
final String javaAgentValue = String.format("-javaagent:%s", targetPath);
143145
if (StringUtils.contains(javaOpts, javaAgentValue)) {
144146
return;
@@ -148,7 +150,7 @@ private void updateAppServiceVMOptions(AppServiceAppBase<?, ?, ?> deployTarget,
148150
}
149151

150152
private void updateApplicationSettings(AppServiceAppBase<?, ?, ?> deployTarget, RunProcessHandler processHandler) {
151-
final Map<String, String> applicationSettings = new HashMap<>(webAppConfiguration.getApplicationSettings());
153+
final Map<String, String> applicationSettings = new HashMap<>(ObjectUtils.firstNonNull(webAppConfiguration.getApplicationSettings(), Collections.emptyMap()));
152154
final Set<String> appSettingsToRemove = webAppConfiguration.isCreatingNew() ? Collections.emptySet() : getAppSettingsToRemove(deployTarget, applicationSettings);
153155
applicationSettings.putAll(appSettingsForResourceConnection);
154156
if (MapUtils.isEmpty(applicationSettings)) {

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/lib/legacy/function/FunctionAppService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
import com.microsoft.azure.toolkit.lib.appservice.task.CreateOrUpdateFunctionAppTask;
1818
import com.microsoft.azure.toolkit.lib.appservice.task.DeployFunctionAppTask;
1919
import com.microsoft.azure.toolkit.lib.resource.ResourceGroupConfig;
20-
import org.apache.commons.lang3.ObjectUtils;
2120
import org.apache.commons.lang3.StringUtils;
22-
import org.gradle.internal.impldep.com.google.api.client.repackaged.com.google.common.base.Objects;
2321

2422
import javax.annotation.Nonnull;
2523
import java.io.File;
2624
import java.util.Collections;
2725
import java.util.Map;
26+
import java.util.Objects;
2827
import java.util.Optional;
2928
import java.util.Set;
3029
import java.util.stream.Collectors;
@@ -88,7 +87,7 @@ private Set<String> getAppSettingsToRemove(FunctionAppConfig config) {
8887
}
8988
final Map<String, String> applicationSettings = config.getAppSettings();
9089
final FunctionAppBase<?, ?, ?> target = config.getDeploymentSlot() == null ? Azure.az(AzureFunctions.class).functionApp(config.getResourceId())
91-
: Azure.az(AzureFunctions.class).functionApp(config.getResourceId()).slots().get(config.getDeploymentSlot().getName(), null);
90+
: Objects.requireNonNull(Azure.az(AzureFunctions.class).functionApp(config.getResourceId())).slots().get(config.getDeploymentSlot().getName(), null);
9291
return target == null || !target.exists() ? Collections.emptySet() : Optional.ofNullable(target.getAppSettings())
9392
.map(settings -> settings.keySet().stream().filter(key -> !applicationSettings.containsKey(key)).collect(Collectors.toSet()))
9493
.orElseGet(Collections::emptySet);

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-guidance/src/main/java/com/microsoft/azure/toolkit/ide/guidance/view/components/PhasePanel.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,14 @@ private void initOutputPanel() {
144144
class ConsoleTextMessager implements IAzureMessager {
145145
@Override
146146
public boolean show(IAzureMessage message) {
147-
final String content = message.getContent();
148-
PhasePanel.this.isOutputBlank = StringUtils.isBlank(content);
149-
PhasePanel.this.outputPanel.setText(content);
150-
PhasePanel.this.updateView(PhasePanel.this.phase.getStatus(), PhasePanel.this.detailsPanel.isVisible());
147+
try {
148+
final String content = message.getContent();
149+
PhasePanel.this.isOutputBlank = StringUtils.isBlank(content);
150+
PhasePanel.this.outputPanel.setText(content);
151+
PhasePanel.this.updateView(PhasePanel.this.phase.getStatus(), PhasePanel.this.detailsPanel.isVisible());
152+
} catch (RuntimeException e) {
153+
// swallow exception when update output panel
154+
}
151155
return true;
152156
}
153157
}

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-common-lib/src/main/java/com/microsoft/azure/toolkit/ide/common/component/AzureResourceLabelView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public void onEvent(AzureEvent event) {
7272
final String type = event.getType();
7373
final Object source = event.getSource();
7474
if (source instanceof AzResource &&
75-
((AzResource<?, ?, ?>) source).getId().equals(this.resource.getId()) &&
76-
((AzResource<?, ?, ?>) source).getName().equals(this.resource.getName())) {
75+
StringUtils.equals(((AzResource<?, ?, ?>) source).getId(), this.resource.getId()) &&
76+
StringUtils.equals(((AzResource<?, ?, ?>) source).getName(), this.resource.getName())) {
7777
final AzureTaskManager tm = AzureTaskManager.getInstance();
7878
if (StringUtils.equals(type, "resource.refreshed.resource")) {
7979
this.refreshViewInner.debounce();

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-common-lib/src/main/java/com/microsoft/azuretools/telemetrywrapper/EventUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
import com.azure.core.management.AzureEnvironment;
99
import com.microsoft.azure.toolkit.lib.Azure;
1010
import com.microsoft.azure.toolkit.lib.account.IAzureAccount;
11+
import org.apache.commons.lang3.StringUtils;
1112
import org.apache.commons.lang3.exception.ExceptionUtils;
1213

1314
import java.util.HashMap;
1415
import java.util.Map;
16+
import java.util.Optional;
1517
import java.util.UUID;
1618
import java.util.function.Consumer;
1719

1820
import static com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter.ERROR_CLASSNAME;
1921
import static com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter.ERROR_CODE;
2022
import static com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter.ERROR_MSG;
23+
import static com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter.ERROR_ROOT_CLASSNAME;
24+
import static com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter.ERROR_ROOT_MSG;
2125
import static com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter.ERROR_STACKTRACE;
2226
import static com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter.ERROR_TYPE;
2327
import static com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter.OPERATION_NAME;
@@ -213,14 +217,17 @@ public static boolean isAbleToCollectErrorStacks() {
213217
private static void logError(String serviceName, String operName, ErrorType errorType, Throwable e,
214218
Map<String, String> properties, Map<String, Double> metrics, boolean logErrorTraces) {
215219
try {
220+
final Throwable rootCause = Optional.ofNullable(e).map(ExceptionUtils::getRootCause).orElse(null);
216221
Map<String, String> mutableProps = properties == null ? new HashMap<>() : new HashMap<>(properties);
217222
mutableProps.put(OPERATION_NAME, operName);
218223
mutableProps.put(OPERATION_ID, UUID.randomUUID().toString());
219224
mutableProps.put(ERROR_CODE, "1");
220225
mutableProps.put(ERROR_CLASSNAME, e != null ? e.getClass().getName() : "");
221226
mutableProps.put(ERROR_TYPE, errorType.name());
227+
mutableProps.put(ERROR_ROOT_CLASSNAME, Optional.ofNullable(rootCause).map(Throwable::getClass).map(Class::getName).orElse(StringUtils.EMPTY));
222228
if (logErrorTraces && isAbleToCollectErrorStacks()) {
223229
mutableProps.put(ERROR_MSG, e != null ? e.getMessage() : "");
230+
mutableProps.put(ERROR_ROOT_MSG, Optional.ofNullable(rootCause).map(Throwable::getMessage).orElse(StringUtils.EMPTY));
224231
mutableProps.put(ERROR_STACKTRACE, ExceptionUtils.getStackTrace(e));
225232
}
226233
sendTelemetry(EventType.error, serviceName, mergeProperties(mutableProps), metrics);

0 commit comments

Comments
 (0)