Skip to content

Commit 8cf9ee5

Browse files
Merge pull request #5425 from microsoft/bugfix-npe-message
fix npe & nodes show twice in explorer.
2 parents f236a58 + b765f26 commit 8cf9ee5

File tree

3 files changed

+16
-6
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij
  • Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/springcloud

3 files changed

+16
-6
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/messager/IntellijAzureMessage.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import com.microsoft.azure.toolkit.lib.common.task.AzureTask;
1919
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskContext;
2020
import lombok.Getter;
21-
import lombok.RequiredArgsConstructor;
2221
import lombok.Setter;
22+
import lombok.extern.java.Log;
2323
import org.apache.commons.lang3.ObjectUtils;
2424
import org.apache.commons.lang3.StringUtils;
2525
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -35,12 +35,13 @@
3535
import java.util.Map;
3636
import java.util.Objects;
3737
import java.util.Optional;
38+
import java.util.logging.Level;
3839
import java.util.regex.Matcher;
3940
import java.util.regex.Pattern;
4041
import java.util.stream.Collectors;
4142

4243
@Setter
43-
@RequiredArgsConstructor
44+
@Log
4445
public class IntellijAzureMessage implements IAzureMessage {
4546
static final Pattern URL_PATTERN = Pattern.compile("\\s+(https?|ftp)://(www\\d?|[a-zA-Z0-9]+)?.[a-zA-Z0-9-]+(:|.)([a-zA-Z0-9.]+|(\\d+)?)([/?:].*)?");
4647
static final String DEFAULT_MESSAGE_TITLE = "Azure";
@@ -59,6 +60,13 @@ public class IntellijAzureMessage implements IAzureMessage {
5960
@Getter
6061
private final IAzureMessage original;
6162

63+
public IntellijAzureMessage(@Nonnull IAzureMessage original) {
64+
this.original = original;
65+
if (original.getPayload() instanceof Throwable) {
66+
log.log(Level.WARNING, "caught error in IntellijAzureMessager", ((Throwable) original.getPayload()));
67+
}
68+
}
69+
6270
public IntellijAzureMessage(@Nonnull Type type, @Nonnull String message) {
6371
this(new SimpleMessage(type, message));
6472
}
@@ -143,7 +151,7 @@ public Boolean getBackgrounded() {
143151
private static String getCause(@Nonnull Throwable throwable) {
144152
final Throwable root = getRecognizableCause(throwable);
145153
if (Objects.isNull(root)) {
146-
return null;
154+
return ExceptionUtils.getRootCause(throwable).toString();
147155
}
148156
String cause = null;
149157
if (root instanceof ManagementException) {
@@ -163,7 +171,7 @@ private static Throwable getRecognizableCause(@Nonnull Throwable throwable) {
163171
continue;
164172
}
165173
final String rootClassName = t.getClass().getName();
166-
if (rootClassName.startsWith("com.microsoft.azure") || rootClassName.startsWith("com.azure")) {
174+
if (rootClassName.startsWith("com.microsoft") || rootClassName.startsWith("com.azure")) {
167175
return t;
168176
}
169177
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/springcloud/properties/SpringCloudAppPanel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ private void setApp(@Nonnull SpringCloudApp app) {
173173
private void updateForm() {
174174
assert Objects.nonNull(app): "app is not specified";
175175
final String testUrl = app.entity().getTestUrl();
176-
this.txtTestEndpoint.setHyperlinkText(testUrl.length() > 60 ? testUrl.substring(0, 60) + "..." : testUrl);
176+
if (testUrl != null) {
177+
this.txtTestEndpoint.setHyperlinkText(testUrl.length() > 60 ? testUrl.substring(0, 60) + "..." : testUrl);
178+
}
177179
this.txtTestEndpoint.setHyperlinkTarget(testUrl);
178180

179181
final SpringCloudSku sku = app.getCluster().entity().getSku();

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/springcloud/SpringCloudNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public SpringCloudNode(AzureRefreshableNode parent, SpringCloudCluster cluster)
4242

4343
public void onAppCreatedOrRemoved(SpringCloudApp app) {
4444
if (this.cluster.name().equals(app.getCluster().name())) {
45-
refreshItems();
45+
this.load(true);
4646
}
4747
}
4848

0 commit comments

Comments
 (0)