Polishing.

This commit is contained in:
Greg Turnquist
2019-03-15 11:19:33 -05:00
parent 82cf365ba7
commit 54fa3f9d58
2 changed files with 9 additions and 5 deletions

View File

@@ -111,8 +111,10 @@ public class JacksonMongoSessionConverter extends AbstractMongoSessionConverter
try {
DBObject dbSession = (DBObject) JSON.parse(this.objectMapper.writeValueAsString(source));
dbSession.put(EXPIRE_AT_FIELD_NAME, source.getExpireAt());
// Override default serialization with proper values.
dbSession.put(PRINCIPAL_FIELD_NAME, extractPrincipal(source));
dbSession.put(EXPIRE_AT_FIELD_NAME, source.getExpireAt());
return dbSession;
} catch (JsonProcessingException e) {
throw new IllegalStateException("Cannot convert MongoExpiringSession", e);
@@ -123,8 +125,7 @@ public class JacksonMongoSessionConverter extends AbstractMongoSessionConverter
@Nullable
protected MongoSession convert(Document source) {
Date expireAt = source.getDate(EXPIRE_AT_FIELD_NAME);
source.remove(EXPIRE_AT_FIELD_NAME);
Date expireAt = (Date) source.remove(EXPIRE_AT_FIELD_NAME);
String json = source.toJson(JsonWriterSettings.builder().outputMode(JsonMode.RELAXED).build());
try {