Disable HTML escaping in gson coders 77/97677/2
authorJim Hahn <jrh3@att.com>
Tue, 29 Oct 2019 13:47:44 +0000 (09:47 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 29 Oct 2019 14:18:54 +0000 (10:18 -0400)
Issue-ID: POLICY-1869
Signed-off-by: Jim Hahn <jrh3@att.com>
Change-Id: Ic757d3a8e7e0e3537ecba979a919b9ea3c1aa797
Signed-off-by: Jim Hahn <jrh3@att.com>
gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java
gson/src/main/java/org/onap/policy/common/gson/JacksonHandler.java
utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java

index 37d2417..75d58f2 100644 (file)
@@ -85,7 +85,7 @@ public class GsonMessageBodyHandler implements MessageBodyReader<Object>, Messag
      * @return the configured builder
      */
     public static GsonBuilder configBuilder(GsonBuilder builder) {
-        return builder.registerTypeAdapterFactory(new MapDoubleAdapterFactory());
+        return builder.disableHtmlEscaping().registerTypeAdapterFactory(new MapDoubleAdapterFactory());
     }
 
     @Override
index 6df5ad2..420fbdb 100644 (file)
@@ -61,6 +61,7 @@ public class JacksonHandler extends GsonMessageBodyHandler {
         return builder.registerTypeAdapterFactory(new JacksonFieldAdapterFactory())
                         .registerTypeAdapterFactory(new JacksonMethodAdapterFactory())
                         .registerTypeAdapterFactory(new MapDoubleAdapterFactory())
-                        .setExclusionStrategies(new JacksonExclusionStrategy());
+                        .setExclusionStrategies(new JacksonExclusionStrategy())
+                        .disableHtmlEscaping();
     }
 }
index c3f2d99..e84a92f 100644 (file)
@@ -41,7 +41,7 @@ import java.nio.charset.StandardCharsets;
 import lombok.AccessLevel;
 import lombok.Getter;
 import org.onap.policy.common.gson.DoubleConverter;
-import org.onap.policy.common.gson.MapDoubleAdapterFactory;
+import org.onap.policy.common.gson.GsonMessageBodyHandler;
 
 /**
  * JSON encoder and decoder using the "standard" mechanism, which is currently gson.
@@ -52,9 +52,9 @@ public class StandardCoder implements Coder {
      * Gson object used to encode and decode messages.
      */
     @Getter(AccessLevel.PROTECTED)
-    private static final Gson GSON =
-                    new GsonBuilder().registerTypeAdapter(StandardCoderObject.class, new StandardTypeAdapter())
-                                    .registerTypeAdapterFactory(new MapDoubleAdapterFactory()).create();
+    private static final Gson GSON = GsonMessageBodyHandler.configBuilder(
+                    new GsonBuilder().registerTypeAdapter(StandardCoderObject.class, new StandardTypeAdapter()))
+                    .create();
 
     /**
      * Constructs the object.