aboutsummaryrefslogtreecommitdiffstats
path: root/gui-pdp-monitoring
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2021-09-24 14:25:17 +0100
committerDaniel Hanrahan <daniel.hanrahan@est.tech>2021-09-28 09:48:40 +0000
commit4788613c81036e98ac24e9af1efef968fb22af0b (patch)
tree5b7af9de691053044fda4d51a3d8e34fbbdc44cb /gui-pdp-monitoring
parent9fd5ad2dc79c416f5e277f5b233f90ace5191cd8 (diff)
Fix JSON parse error in PDP Monitoring GUI
Add Gson type adapter to parse Instant Issue-ID: POLICY-3680 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: Ibcd7878f5c7ab9e2d4d7ffc337b9cc440caf19c3
Diffstat (limited to 'gui-pdp-monitoring')
-rw-r--r--gui-pdp-monitoring/src/main/java/org/onap/policy/gui/pdp/monitoring/rest/PdpMonitoringRestResource.java8
1 files changed, 7 insertions, 1 deletions
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<Instant>) (jsonElement, type, jsonDeserializationContext)
+ -> Instant.parse(jsonElement.getAsJsonPrimitive().getAsString()))
+ .create();
/**
* Query Pdps.