Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Fixed problem with parsing objects that contain potentially incorrect URLs as property names. #91

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ public ExtensibleObject deserialize(JsonElement jsonElement, Type type, JsonDese
JsonElement value = element.getValue();

try {
Class foundClass = Class.forName(key.replace('_', '.'));
Class<?> foundClass = Class.forName(key.replace('_', '.'));
if (foundClass != null) {
mo.set(key, jsonDeserializationContext.deserialize(value, foundClass));
continue;
}
} catch (ClassNotFoundException e) {
} catch (ClassNotFoundException | IllegalArgumentException e) {
// IllegalArgumentException migh happen here in case the code is executed with URLClassLoader
// for example Spring Boot application.
}

JsonPrimitive tmp;
Expand All @@ -105,7 +107,7 @@ public ExtensibleObject deserialize(JsonElement jsonElement, Type type, JsonDese
String tmpString = tmp.getAsString();
ZonedDateTime zonedDateTime = null;
// in the CoT plattform the stored date time objects has different formatted time zones
switch(tmpString.length()) {
switch (tmpString.length()) {
case 24:
// e.g. 2017-09-05T17:19:32.601Z
case 26:
Expand Down Expand Up @@ -137,7 +139,7 @@ public ExtensibleObject deserialize(JsonElement jsonElement, Type type, JsonDese
} else if (value.isJsonObject()) {
// Special case for User to avoid crappy nested ExtensibleObjects...
if (key.equals("devicePermissions")) {
mo.set(key, deserializeDevicePermissions((JsonObject)value));
mo.set(key, deserializeDevicePermissions((JsonObject) value));
} else {
mo.set(key, jsonDeserializationContext.deserialize(value, type));
}
Expand Down Expand Up @@ -174,4 +176,4 @@ private Map<String, List<DevicePermission>> deserializeDevicePermissions(JsonObj
}
return permissions;
}
}
}