From 4788613c81036e98ac24e9af1efef968fb22af0b Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Fri, 24 Sep 2021 14:25:17 +0100 Subject: Fix JSON parse error in PDP Monitoring GUI Add Gson type adapter to parse Instant Issue-ID: POLICY-3680 Signed-off-by: danielhanrahan Change-Id: Ibcd7878f5c7ab9e2d4d7ffc337b9cc440caf19c3 --- .../policy/gui/pdp/monitoring/rest/PdpMonitoringRestResource.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gui-pdp-monitoring/src/main') diff --git a/gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/rest/PdpMonitoringRestResource.java b/gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/rest/PdpMonitoringRestResource.java index 6075049..60dfc81 100644 --- a/gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/rest/PdpMonitoringRestResource.java +++ b/gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/rest/PdpMonitoringRestResource.java @@ -23,7 +23,10 @@ package org.onap.policy.gui.pdp.monitoring.rest; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializer; import com.google.gson.reflect.TypeToken; +import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -76,7 +79,10 @@ public class PdpMonitoringRestResource { // Set the maximum number of stored data entries to be stored for each engine private static final int MAX_CACHED_ENTITIES = 50; - private static Gson gson = new Gson(); + private static Gson gson = new GsonBuilder() + .registerTypeAdapter(Instant.class, (JsonDeserializer) (jsonElement, type, jsonDeserializationContext) + -> Instant.parse(jsonElement.getAsJsonPrimitive().getAsString())) + .create(); /** * Query Pdps. -- cgit 1.2.3-korg