Skip to content

Radis deserialise json on update InvalidTypeIdException [DATAREDIS-928] #1499

Open
@spring-projects-issues

Description

@spring-projects-issues

ergunp opened DATAREDIS-928 and commented

Hi,
I am using Redis with Spring boot 2 and Kotlin. I am having an issue updating an entry in Redis.
I am storing my object as json in redis cache using the

GenericJackson2JsonRedisSerializer()

But my issue is when I try to update the object within the cache I get the following error

 

Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class java.lang.Object]: missing type id property '@class'
 at [Source: (byte[])"{"id":"10.36.55.1","protocolRestriction":false}"; line: 1, column: 47]

I have already tried adding the following to my object.

@JsonTypeInfo(
 use = JsonTypeInfo.Id.MINIMAL_CLASS,
 include = JsonTypeInfo.As.PROPERTY,
 property = "@class")

but with no luck.

Here is my config,

 

@Bean
 fun redisCacheManager(objectMapper: ObjectMapper): CacheManager
{ val jsonSerializer = RedisSerializationContext.SerializationPair .fromSerializer(GenericJackson2JsonRedisSerializer()) return RedisCacheManager.RedisCacheManagerBuilder .fromConnectionFactory(jedisConnectionFactory()) .cacheDefaults( RedisCacheConfiguration.defaultCacheConfig() .entryTtl(Duration.ofMinutes(cacheTimeToLive!!)) .serializeValuesWith(jsonSerializer)) .build() }

 

 

this is my object

@RedisHash("sessionState", timeToLive = 900) //evict after 15min
 data class SessionState(@Id val id:String?,
 val protocolRestriction: Boolean?): Serializable

Here is how i am updating my object in the cache

@Caching(put = CachePut("sessionStateCache", key = "#sessionState.id", unless = "#result == null"),
 evict = [CacheEvict("allSessionStateCache", allEntries = true)])
 override fun updateSessionState(sessionState: SessionState): SessionState
{ return sessionStateRepo.save(sessionState) }

 

Any help would be much appreciated


No further details from DATAREDIS-928

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions