diff --git a/redisscheduler/pom.xml b/redisscheduler/pom.xml index 1dd244f..7b15687 100755 --- a/redisscheduler/pom.xml +++ b/redisscheduler/pom.xml @@ -41,7 +41,7 @@ com.fasterxml.jackson.core jackson-databind - 2.4.0 + 2.9.9 diff --git a/redisscheduler/src/main/java/com/moparisthebest/jbgjob/RedisScheduler.java b/redisscheduler/src/main/java/com/moparisthebest/jbgjob/RedisScheduler.java index ac12334..eb84c34 100644 --- a/redisscheduler/src/main/java/com/moparisthebest/jbgjob/RedisScheduler.java +++ b/redisscheduler/src/main/java/com/moparisthebest/jbgjob/RedisScheduler.java @@ -39,8 +39,6 @@ public class RedisScheduler extends AbstractScheduler { public static final String defaultQueuePrefix; - public static final SimpleModule redisModule; - static { String prefix = System.getProperty("redis.queuePrefix"); if (isEmpty(prefix)) @@ -49,47 +47,11 @@ public class RedisScheduler extends AbstractScheduler { } catch (Throwable e) { } defaultQueuePrefix = defaultIfEmpty(prefix, ""); - - @SuppressWarnings({"unchecked"}) - final Class singleton = (Class) Collections.singleton(5L).getClass(); - @SuppressWarnings({"unchecked"}) - final Class singletonMap = (Class) Collections.singletonMap(5L, 5L).getClass(); - @SuppressWarnings({"unchecked"}) - final Class singletonList = (Class) Collections.singletonList(5L).getClass(); - @SuppressWarnings({"unchecked"}) - final Class asList = (Class) Arrays.asList(5L).getClass(); - - redisModule = new SimpleModule("OrderedMap", new Version(1, 0, 0, null, null, null)).addDeserializer( - singleton, new JsonDeserializer() { - @Override - public Set deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - return Collections.singleton(jp.getCodec().readValue(jp, Object[].class)[0]); - } - }).addDeserializer( - singletonMap, new JsonDeserializer() { - @Override - public Map deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - final Map.Entry entry = (Map.Entry) jp.getCodec().readValue(jp, HashMap.class).entrySet().iterator().next(); - return Collections.singletonMap(entry.getKey(), entry.getValue()); - } - }).addDeserializer( - singletonList, new JsonDeserializer() { - @Override - public List deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - return Collections.singletonList(jp.getCodec().readValue(jp, Object[].class)[0]); - } - }).addDeserializer( - asList, new JsonDeserializer() { - @Override - public List deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - return Arrays.asList(jp.getCodec().readValue(jp, Object[].class)); - } - }); } protected final String queuePrefix; - protected final ObjectMapper om = new ObjectMapper().enableDefaultTyping().registerModule(redisModule); + protected final ObjectMapper om = new ObjectMapper().enableDefaultTyping(); protected final JedisPool pool; public RedisScheduler() { diff --git a/redisscheduler/src/test/java/com/moparisthebest/jbgjob/RedisSchedulerTest.java b/redisscheduler/src/test/java/com/moparisthebest/jbgjob/RedisSchedulerTest.java index d998c21..504fd22 100644 --- a/redisscheduler/src/test/java/com/moparisthebest/jbgjob/RedisSchedulerTest.java +++ b/redisscheduler/src/test/java/com/moparisthebest/jbgjob/RedisSchedulerTest.java @@ -38,9 +38,9 @@ public class RedisSchedulerTest extends AbstractSchedulerTests { bg.testSerialization(new JacksonTest(Arrays.asList(new InList(1L)))); bg.testSerialization(new JacksonTest(Collections.singletonList(new InList(1L)))); - //bg.testSerialization(new JacksonTest(Collections.singleton(new InList(1L)))); + bg.testSerialization(new JacksonTest(Collections.singleton(new InList(1L)))); - //bg.testSerialization(new JacksonTestMap(Collections.singletonMap(1L, new InList(1L)))); + bg.testSerialization(new JacksonTestMap(Collections.singletonMap(1L, new InList(1L)))); }