Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Possible NullPointerException in ReactiveMongoSessionRepository #220

Open
@thko79

Description

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:

return findSession(id) //
.map(document -> convertToSession(this.mongoSessionConverter, document)) //
.filter(mongoSession -> !mongoSession.isExpired()) //
.switchIfEmpty(Mono.defer(() -> this.deleteById(id).then(Mono.empty())));

As you can see the result of convertToSession is nullable:

@Nullable
static MongoSession convertToSession(AbstractMongoSessionConverter mongoSessionConverter, Document session) {
return (MongoSession) mongoSessionConverter.convert(session, TypeDescriptor.valueOf(Document.class),
TypeDescriptor.valueOf(MongoSession.class));
}

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:

try {
MongoSession mongoSession = this.objectMapper.readValue(json, MongoSession.class);
mongoSession.setExpireAt(expireAt);
return mongoSession;
} catch (IOException e) {
LOG.error("Error during Mongo Session deserialization", e);
return null;
}

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

        AltStyle によって変換されたページ (->オリジナル) /