From fe2eba06a70737528daea372a26283ded5ae654e Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Feb 2019 21:14:17 -0500 Subject: [PATCH] http service: use gson instead of jackson for json serialization This fixes deserailization of the loot timestamps for the loot tracker, and maybe other things. Note this does not use the same Gson instance as http-api as Spring creates its own Gson, however they are both default Gson instances. --- ...gurer.java => SpringWebMvcConfigurer.java} | 21 +++++++++++++++---- .../src/test/resources/application.properties | 3 +-- 2 files changed, 18 insertions(+), 6 deletions(-) rename http-service/src/main/java/net/runelite/http/service/{SpringContentNegotiationConfigurer.java => SpringWebMvcConfigurer.java} (77%) diff --git a/http-service/src/main/java/net/runelite/http/service/SpringContentNegotiationConfigurer.java b/http-service/src/main/java/net/runelite/http/service/SpringWebMvcConfigurer.java similarity index 77% rename from http-service/src/main/java/net/runelite/http/service/SpringContentNegotiationConfigurer.java rename to http-service/src/main/java/net/runelite/http/service/SpringWebMvcConfigurer.java index ed055d0bdf..4402ea6e89 100644 --- a/http-service/src/main/java/net/runelite/http/service/SpringContentNegotiationConfigurer.java +++ b/http-service/src/main/java/net/runelite/http/service/SpringWebMvcConfigurer.java @@ -24,22 +24,35 @@ */ package net.runelite.http.service; +import java.util.List; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -/** - * Configure .js as application/json to trick Cloudflare into caching json responses - */ @Configuration @EnableWebMvc -public class SpringContentNegotiationConfigurer extends WebMvcConfigurerAdapter +public class SpringWebMvcConfigurer extends WebMvcConfigurerAdapter { + /** + * Configure .js as application/json to trick Cloudflare into caching json responses + */ @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.mediaType("js", MediaType.APPLICATION_JSON); } + + /** + * Use GSON instead of Jackson for JSON serialization + * @param converters + */ + @Override + public void configureMessageConverters(List> converters) + { + converters.add(new GsonHttpMessageConverter()); + } } diff --git a/http-service/src/test/resources/application.properties b/http-service/src/test/resources/application.properties index cb3dcc0507..ded3472a5c 100644 --- a/http-service/src/test/resources/application.properties +++ b/http-service/src/test/resources/application.properties @@ -7,5 +7,4 @@ minio.bucket=runelite runelite.twitter.consumerkey=moo runelite.twitter.secretkey=cow runelite.twitter.listid=968949795153948673 -logging.level.net.runelite=DEBUG -spring.jackson.serialization.indent_output=true \ No newline at end of file +logging.level.net.runelite=DEBUG \ No newline at end of file