Skip to content

Commit ebc879f

Browse files
authored
Bug fix, the parameters, variables, resources may be null (#3176)
1 parent acbaa50 commit ebc879f

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/arm/deployments/DeploymentPropertyViewPresenter.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,26 @@ public void onLoadProperty(DeploymentNode node) {
4646
DeploymentExportResult template = deployment.exportTemplate();
4747
Map<String, Object> templateObj = (Map<String, Object>) template.template();
4848

49-
50-
Map<String, Map<String, String>> parametersTmp = (Map<String, Map<String, String>>) templateObj.get("parameters");
51-
for (String parameter : parametersTmp.keySet()) {
52-
parameters.add(String.format("%s(%s)", parameter, parametersTmp.get(parameter).get("type")));
49+
if (templateObj.get("parameters") != null) {
50+
Map<String, Map<String, String>> parametersTmp = (Map<String, Map<String, String>>) templateObj.get("parameters");
51+
for (String parameter : parametersTmp.keySet()) {
52+
parameters.add(String.format("%s(%s)", parameter, parametersTmp.get(parameter).get("type")));
53+
}
5354
}
5455

55-
Map<String, Map<String, String>> variablesTmp = (Map<String, Map<String, String>>) templateObj.get("variables");
56-
for (String variable : variablesTmp.keySet()) {
57-
variables.add(variable);
58-
}
59-
List<Map<String, String>> resourcesTmp = (List<Map<String, String>>) templateObj.get("resources");
60-
for (Map<String, String> resource : resourcesTmp) {
61-
resources.add(String.format("%s(%s)", resource.get("name"), resource.get("type")));
56+
if (templateObj.get("variables") != null) {
57+
Map<String, Map<String, String>> variablesTmp = (Map<String, Map<String, String>>) templateObj.get("variables");
58+
for (String variable : variablesTmp.keySet()) {
59+
variables.add(variable);
60+
}
6261
}
6362

63+
if (templateObj.get("resources") != null) {
64+
List<Map<String, String>> resourcesTmp = (List<Map<String, String>>) templateObj.get("resources");
65+
for (Map<String, String> resource : resourcesTmp) {
66+
resources.add(String.format("%s(%s)", resource.get("name"), resource.get("type")));
67+
}
68+
}
6469
return new DeploymentProperty(deployment, parameters, variables, resources, template.templateAsJson());
6570
}).subscribeOn(this.getSchedulerProvider().io()).subscribe((property) -> {
6671
DefaultLoader.getIdeHelper().invokeLater(() -> {

0 commit comments

Comments
 (0)