Skip to content

Upgraded spring boot to 2.3.2 #2498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2020

Conversation

hirokiterashima
Copy link
Member

@hirokiterashima hirokiterashima commented Jul 31, 2020

Clear the Redis database by running
$ redis-cli

flushall

and test that WISE starts up and works as before.

Resolves #2453

@hirokiterashima hirokiterashima added the 1 point can be completed in 1 hour or less label Jul 31, 2020
Copy link
Member

@geoffreykwan geoffreykwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I started up the server and tried to access the home page it failed to load and this error was shown on the server.

org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: org.springframework.security.core.context.SecurityContextImpl; local class incompatible: stream classdesc serialVersionUID = 520, local class serialVersionUID = 530
        at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize(JdkSerializationRedisSerializer.java:84) ~[spring-data-redis-2.3.2.RELEASE.jar:2.3.2.RELEASE]
        at org.springframework.data.redis.core.AbstractOperations.deserializeHashValue(AbstractOperations.java:355) ~[spring-data-redis-2.3.2.RELEASE.jar:2.3.2.RELEASE]
        at org.springframework.data.redis.core.AbstractOperations.deserializeHashMap(AbstractOperations.java:299) ~[spring-data-redis-2.3.2.RELEASE.jar:2.3.2.RELEASE]
        at org.springframework.data.redis.core.DefaultHashOperations.entries(DefaultHashOperations.java:247) ~[spring-data-redis-2.3.2.RELEASE.jar:2.3.2.RELEASE]
        at org.springframework.data.redis.core.DefaultBoundHashOperations.entries(DefaultBoundHashOperations.java:183) ~[spring-data-redis-2.3.2.RELEASE.jar:2.3.2.RELEASE]
        at org.springframework.session.data.redis.RedisIndexedSessionRepository.getSession(RedisIndexedSessionRepository.java:440) ~[spring-session-data-redis-2.3.0.RELEASE.jar:2.3.0.RELEASE]
        at org.springframework.session.data.redis.RedisIndexedSessionRepository.findById(RedisIndexedSessionRepository.java:412) ~[spring-session-data-redis-2.3.0.RELEASE.jar:2.3.0.RELEASE]
        at org.springframework.session.data.redis.RedisIndexedSessionRepository.findById(RedisIndexedSessionRepository.java:249) ~[spring-session-data-redis-2.3.0.RELEASE.jar:2.3.0.RELEASE]

I was able to fix the problem by clearing the Redis database by running
$ redis-cli
> flushall

This might not be a good solution on production because logged in users at the time would possibly lose their sessions. I found an alternative solution which was to modify

RedisConfig.java on line 53 I changed

redisTemplate.setValueSerializer(new GenericToStringSerializer<Object>(Object.class));

to

redisTemplate.setValueSerializer(new StringRedisSerializer());

I tested this by reverting back to Spring Boot 2.2.0 and using the GenericToStringSerializer. Then logging in as a teacher to generate values in the Redis database. Then I updated to Spring Boot 2.3.2 and changed to StringRedisSerializer. When I accessed the home page I no longer received the error and I could log in. Perhaps @breity should also test this out.

@hirokiterashima
Copy link
Member Author

Thanks for catching this. It looks like the issue with serialization (non) compatibility across different versions is not a bug, but a deliberate policy spring-projects/spring-security#1945

The StringRedisSerializer fix does not work for me. I still get a 500 page with the error

Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: org.springframework.security.core.context.SecurityContextImpl; local class incompatible: stream classdesc serialVersionUID = 520, local class serialVersionUID = 530

There is a work-around that is mentioned in the blog https://sadique.io/blog/2016/11/02/handling-deserialization-errors-in-spring-redis-sessions/, which deletes old sessions. So the solutions are either to flush all sessions, or implementing the work-around. We discussed and agreed on flushing the sessions.

@hirokiterashima hirokiterashima requested a review from breity August 3, 2020 19:20
@hirokiterashima hirokiterashima dismissed geoffreykwan’s stale review August 3, 2020 19:21

We agreed to flush sessions. See details in my comment.

@geoffreykwan geoffreykwan self-requested a review August 4, 2020 16:32
Copy link
Member

@geoffreykwan geoffreykwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Member

@breity breity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@breity breity merged commit e6e6b64 into develop Aug 5, 2020
@breity breity deleted the issue-2453-upgrade-to-spring-boot-2.3.2 branch August 5, 2020 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 point can be completed in 1 hour or less
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Spring-Boot 2.3.2
3 participants