Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Possible NullPointerException in ReactiveMongoSessionRepository #220

@thko79

Description

@thko79

Hi,
we had recently some errors in our application after refactoring some package names. We ended up in our research in this code line:

There you apply a filter on a nullable object. Maybe you have to filter Objects::nonNull before apply other filters, see following line:
https://github.com/spring-projects/spring-session-data-mongodb/blob/60883711b2635335e4d74daa1f62e2c27a122ebf/src/main/java/org/springframework/session/data/mongo/ReactiveMongoSessionRepository.java#L115-L118

As you can see the result of convertToSession is nullable:
https://github.com/spring-projects/spring-session-data-mongodb/blob/60883711b2635335e4d74daa1f62e2c27a122ebf/src/main/java/org/springframework/session/data/mongo/MongoSessionUtils.java#L36-L41

You can reproduce it by placing an invalid Document, this'll cause the ObjectMapper to throw an IOException, which is caught and null value is returned:
https://github.com/spring-projects/spring-session-data-mongodb/blob/60883711b2635335e4d74daa1f62e2c27a122ebf/src/main/java/org/springframework/session/data/mongo/JacksonMongoSessionConverter.java#L134-L141

In our case the Documents gets invalid by refactoring of package names, so it does not match any more with the "@Class" attribute.

Greetings
Thomas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions