List of usage examples for org.springframework.data.redis.serializer SerializationException SerializationException
public SerializationException(String msg, Throwable cause)
From source file:org.solq.dht.db.redis.service.ser.Jackson3JsonRedisSerializer.java
public static <T> T json2Object(byte[] json, Class<T> type) { if (json == null) { return null; }/*from w ww. j a va 2s .c o m*/ try { return (T) objectMapper.readValue(json, type); } catch (Exception ex) { throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); } }
From source file:org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer.java
public byte[] serialize(Object t) throws SerializationException { if (t == null) { return SerializationUtils.EMPTY_ARRAY; }//from w w w .j a va2 s. co m try { return this.objectMapper.writeValueAsBytes(t); } catch (Exception ex) { throw new SerializationException("Could not write JSON: " + ex.getMessage(), ex); } }
From source file:org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer.java
/** * @param source/*from w w w. ja v a 2 s.c om*/ * can be {@literal null}. * @param type * must not be {@literal null}. * @return {@literal null} for empty source. * @throws SerializationException */ public <T> T deserialize(byte[] source, Class<T> type) throws SerializationException { Assert.notNull(type, "Deserialization type must not be null! Pleaes provide Object.class to make use of Jackson2 default typing."); if (SerializationUtils.isEmpty(source)) { return null; } try { return mapper.readValue(source, type); } catch (final Exception ex) { throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); } }
From source file:org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer.java
@Override public byte[] serialize(Object source) throws SerializationException { if (source == null) { return SerializationUtils.EMPTY_ARRAY; }//from w ww .java2s . c o m try { return mapper.writeValueAsBytes(source); } catch (final JsonProcessingException e) { throw new SerializationException("Could not write JSON: " + e.getMessage(), e); } }