0

I just updated from version 2.0.X of Spring Boot to version 2.1.X. I use Spring Redis for in memory storage, and one of the objects that I store in memory has a java.util.concurrent.locks.ReentrantLock. In version 2.0.X of Spring Boot, the object deserializes successfully. In version 2.1.X, the object fails to deserialize with the exception:

org.springframework.data.keyvalue.core.UncategorizedKeyValueException: Cannot set immutable property java.util.concurrent.locks.ReentrantLock.sync!; nested exception is java.lang.UnsupportedOperationException: Cannot set immutable property java.util.concurrent.locks.ReentrantLock.sync

The problem occurs at org.springframework.data.mapping.model.BeanWrapper:85.

As this is a serializable object, I should be able to store it in Redis as is. Is this a bug in Spring? Is there a workaround?

Until this is resolved, I cannot update my Spring Boot version, and therefore my Java version. Any help would be appreciated.

Raythien
  • 1
  • 1
  • Do not serialize objects that can't be deserialized. Why do you serialize `ReentrantLock`? – mp911de Dec 05 '18 at 13:51
  • It's part of an object that's not mine that I'm saving to Redis. However, since it implements Serializable, it should be possible to save it to Redis. It worked in the previous version of Spring Boot. – Raythien Dec 05 '18 at 14:41
  • Redis Repositories do not use JDK serialization but flatten objects to a hash. Spring Data 2.1 introduced support for immutable objects and no longer updates final fields. – mp911de Dec 05 '18 at 17:08

0 Answers0