Upgrade jackson to 2.9.9, fix tests by removing custom module

This commit is contained in:
Travis Burtrum 2019-06-26 23:21:22 -04:00
parent 798fcd2107
commit ab766425c2
3 changed files with 4 additions and 42 deletions

View File

@ -41,7 +41,7 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.4.0</version> <version>2.9.9</version>
</dependency> </dependency>
</dependencies> </dependencies>
<profiles> <profiles>

View File

@ -39,8 +39,6 @@ public class RedisScheduler extends AbstractScheduler {
public static final String defaultQueuePrefix; public static final String defaultQueuePrefix;
public static final SimpleModule redisModule;
static { static {
String prefix = System.getProperty("redis.queuePrefix"); String prefix = System.getProperty("redis.queuePrefix");
if (isEmpty(prefix)) if (isEmpty(prefix))
@ -49,47 +47,11 @@ public class RedisScheduler extends AbstractScheduler {
} catch (Throwable e) { } catch (Throwable e) {
} }
defaultQueuePrefix = defaultIfEmpty(prefix, ""); defaultQueuePrefix = defaultIfEmpty(prefix, "");
@SuppressWarnings({"unchecked"})
final Class<Set> singleton = (Class<Set>) Collections.singleton(5L).getClass();
@SuppressWarnings({"unchecked"})
final Class<Map> singletonMap = (Class<Map>) Collections.singletonMap(5L, 5L).getClass();
@SuppressWarnings({"unchecked"})
final Class<List> singletonList = (Class<List>) Collections.singletonList(5L).getClass();
@SuppressWarnings({"unchecked"})
final Class<List> asList = (Class<List>) Arrays.asList(5L).getClass();
redisModule = new SimpleModule("OrderedMap", new Version(1, 0, 0, null, null, null)).addDeserializer(
singleton, new JsonDeserializer<Set>() {
@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<Map>() {
@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<List>() {
@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<List>() {
@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 String queuePrefix;
protected final ObjectMapper om = new ObjectMapper().enableDefaultTyping().registerModule(redisModule); protected final ObjectMapper om = new ObjectMapper().enableDefaultTyping();
protected final JedisPool pool; protected final JedisPool pool;
public RedisScheduler() { public RedisScheduler() {

View File

@ -38,9 +38,9 @@ public class RedisSchedulerTest extends AbstractSchedulerTests {
bg.testSerialization(new JacksonTest(Arrays.asList(new InList(1L)))); bg.testSerialization(new JacksonTest(Arrays.asList(new InList(1L))));
bg.testSerialization(new JacksonTest(Collections.singletonList(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))));
} }