Skip to content

Commit 071f06c

Browse files
Merge pull request #6653 from microsoft/miller/endgame-fixes
#1952940: [Test]When deploying from Azure Explorer, recreating a new app, clicking the OK button becomes unresponsive and displays an error
2 parents 78dfdca + 9f8d209 commit 071f06c

File tree

1 file changed

+12
-8
lines changed
  • PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.core/src/com/microsoft/azure/toolkit/eclipse/common/launch

1 file changed

+12
-8
lines changed

PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.core/src/com/microsoft/azure/toolkit/eclipse/common/launch/LaunchConfigurationUtils.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515
import org.eclipse.debug.core.ILaunchConfiguration;
1616
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
1717

18-
import com.google.gson.Gson;
18+
import com.fasterxml.jackson.core.JsonProcessingException;
19+
import com.fasterxml.jackson.databind.DeserializationFeature;
20+
import com.fasterxml.jackson.databind.ObjectMapper;
1921
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
2022

2123
public class LaunchConfigurationUtils {
22-
private static final Gson gson = new Gson();
24+
private static final ObjectMapper mapper = new ObjectMapper();
25+
static{
26+
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
27+
}
2328

2429
public static <T> T getFromConfiguration(ILaunchConfiguration config, @Nonnull Class<T> classOfT) {
2530
try {
@@ -35,15 +40,15 @@ public static <T> T getFromConfiguration(ILaunchConfiguration config, @Nonnull C
3540
value = config.getAttribute(field.getName(), 0);
3641
} else {
3742
final String json = config.getAttribute(field.getName(), StringUtils.EMPTY);
38-
value = StringUtils.isEmpty(json) ? null : gson.fromJson(json, field.getType());
43+
value = StringUtils.isEmpty(json) ? null : mapper.readValue(json, field.getType());
3944
}
4045
if (value != null) {
4146
FieldUtils.writeField(field, obj, value, true);
4247
}
4348
}
4449
return obj;
4550
} catch (NoSuchMethodException | SecurityException | InvocationTargetException | InstantiationException
46-
| IllegalAccessException | CoreException ex) {
51+
| IllegalAccessException | CoreException | JsonProcessingException ex) {
4752
throw new AzureToolkitRuntimeException("Cannot use reflections on class:" + classOfT.getSimpleName(), ex);
4853
}
4954
}
@@ -57,12 +62,11 @@ public static <T> void saveToConfiguration(@Nonnull T obj, ILaunchConfigurationW
5762
} else if (value instanceof String || value instanceof Boolean || value instanceof Integer) {
5863
config.setAttribute(field.getName(), value);
5964
} else {
60-
config.setAttribute(field.getName(), gson.toJson(value));
65+
config.setAttribute(field.getName(), mapper.writeValueAsString(value));
6166
}
6267
}
63-
} catch (SecurityException | IllegalAccessException ex) {
64-
throw new AzureToolkitRuntimeException("Cannot use reflections on class:" + obj.getClass().getSimpleName(),
65-
ex);
68+
} catch (SecurityException | IllegalAccessException | JsonProcessingException ex) {
69+
throw new AzureToolkitRuntimeException("Cannot use reflections on class:" + obj.getClass().getSimpleName(), ex);
6670
}
6771
}
6872
}

0 commit comments

Comments
 (0)