package com.s24.redjob.worker.json;

import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;

import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.s24.redjob.worker.Execution;
import com.s24.redjob.worker.NoResult;

/**
 * {@link RedisSerializer} for {@link Execution}s.
 */
public class ExecutionRedisSerializer extends Jackson2JsonRedisSerializer<Execution> {
   /**
    * Object mapper.
    */
   private ObjectMapper objectMapper = new ObjectMapper();

   /**
    * Constructor.
    */
   public ExecutionRedisSerializer() {
      super(Execution.class);
      setObjectMapper(objectMapper);
   }

   /**
    * Object mapper.
    */
   public ObjectMapper getObjectMapper() {
      return objectMapper;
   }

   @Override
   public void setObjectMapper(ObjectMapper objectMapper) {
      objectMapper.registerSubtypes(NoResult.class);
      super.setObjectMapper(objectMapper);
      this.objectMapper = objectMapper;
   }

   /**
    * Add additional sub types to the object mapper.
    */
   public void setTypes(Class... types) {
      objectMapper.registerSubtypes(types);
   }

   /**
    * Add additional modules to the object mapper.
    */
   public void setModules(Module... modules) {
      objectMapper.registerModules(modules);
   }
}

@@ -30,16 +30,73 @@
 .json;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import o
@@ -230,16 +230,89 @@
 ializer;
+%0Aimport org.springframework.data.redis.serializer.SerializationException;
 %0A%0Aimport
@@ -646,228 +646,835 @@
   * 
-Object mapper.%0A    */%0A   private ObjectMapper objectMapper = new ObjectMapper();%0A%0A   /**%0A    * Constructor.%0A    */%0A   public ExecutionRedisSerializer() %7B%0A      super(Execution.class);%0A      setObjectMapper(objectMapper);
+Logger.%0A    */%0A   private static final Logger log = LoggerFactory.getLogger(ExecutionRedisSerializer.class);%0A%0A   /**%0A    * Object mapper.%0A    */%0A   private ObjectMapper objectMapper = new ObjectMapper();%0A%0A   /**%0A    * Ignore deserialization failures?.%0A    */%0A   private boolean ignoreDeserializationFailures = false;%0A%0A   /**%0A    * Constructor.%0A    */%0A   public ExecutionRedisSerializer() %7B%0A      super(Execution.class);%0A      setObjectMapper(objectMapper);%0A   %7D%0A%0A   @Override%0A   public Execution deserialize(byte%5B%5D bytes) throws SerializationException %7B%0A      try %7B%0A         return super.deserialize(bytes);%0A      %7D catch (SerializationException e) %7B%0A         if (ignoreDeserializationFailures) %7B%0A            log.warn(%22Ignoring invalid JSON: %7B%7D.%22, e.getMessage());%0A            return null;%0A         %7D%0A%0A         throw e;%0A      %7D
 %0A   
@@ -2122,11 +2122,234 @@
 s);%0A   %7D
+%0A%0A   /**%0A    * Ignore deserialization failures?.%0A    */%0A   public void setIgnoreDeserializationFailures(boolean ignoreDeserializationFailures) %7B%0A      this.ignoreDeserializationFailures = ignoreDeserializationFailures;%0A   %7D
 %0A%7D%0A

Add option to ignore deserialization failures of executions