From fc19da9346f5a9e20d16d572cbc94902d7bc1c51 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 22 Sep 2017 17:41:21 +0300 Subject: crosspost: inject correct json mapper --- .../src/main/java/com/juick/components/Crosspost.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'juick-crosspost') diff --git a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java index f481c348..58e3c410 100644 --- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java +++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java @@ -60,7 +60,8 @@ public class Crosspost extends TextWebSocketHandler { private final String twitter_consumer_key; private final String twitter_consumer_secret; - private ObjectMapper ms; + @Inject + private ObjectMapper jsonMapper; @Inject MessagesService messagesService; @@ -72,16 +73,11 @@ public class Crosspost extends TextWebSocketHandler { twitter_consumer_key = env.getProperty("twitter_consumer_key", StringUtils.EMPTY); twitter_consumer_secret = env.getProperty("twitter_consumer_secret", StringUtils.EMPTY); - - ms = new ObjectMapper(); - ms.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); - ms.setSerializationInclusion(JsonInclude.Include.NON_NULL); - ms.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); } @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { - Message msg = ms.readValue(message.asBytes(), Message.class); + Message msg = jsonMapper.readValue(message.asBytes(), Message.class); if (msg.getMid() > 0 && msg.getRid() == 0) { Message jmsg = messagesService.getMessage(msg.getMid()); if (StringUtils.isNotEmpty(crosspostService.getTwitterName(msg.getUser().getUid()))) { -- cgit v1.2.3