Skip to content

Commit 7fc0ae4

Browse files
committed
Switch back to unicode for the DOT substitute character.
MongoDB doesn't support "." in field names, so a Private Use Area character was used. This was originally stored in unicode format, but delomboking the code caused it to get transformed into another encoding. This causes issues on certain systems when building the software, so we are converting it back to its unicode representation. The character has been the same throughout, ensuring binary compatilibity. See: https://www.compart.com/en/unicode/U+F607 Related: spring-projects/spring-session-data-mongodb@d601e27#diff-57190a47726099e31fdf86b12b80206e2ae24feb28aacaf494b99557583df150L47 Closes #2053.
1 parent ce2e644 commit 7fc0ae4

File tree

1 file changed

+13
-14
lines changed
  • spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo

1 file changed

+13
-14
lines changed

spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo/MongoSession.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,14 @@
1616

1717
package org.springframework.session.data.mongo;
1818

19+
import org.springframework.lang.Nullable;
20+
import org.springframework.session.Session;
21+
1922
import java.time.Duration;
2023
import java.time.Instant;
21-
import java.util.Date;
22-
import java.util.HashMap;
23-
import java.util.Map;
24-
import java.util.Objects;
25-
import java.util.Set;
26-
import java.util.UUID;
24+
import java.util.*;
2725
import java.util.stream.Collectors;
2826

29-
import org.springframework.lang.Nullable;
30-
import org.springframework.session.Session;
31-
3227
/**
3328
* Session object providing additional information about the datetime of expiration.
3429
*
@@ -39,10 +34,15 @@
3934
public class MongoSession implements Session {
4035

4136
/**
42-
* Mongo doesn't support {@literal dot} in field names. We replace it with a very
43-
* rarely used character
37+
* Mongo doesn't support {@literal dot} in field names. We replace it with a unicode character from the Private Use Area.
38+
* <p>
39+
* NOTE: This was originally stored in unicode format. Delomboking the code caused it to get converted to another encoding,
40+
* which isn't supported on all systems, so we migrated back to unicode. The same character is being represented ensuring
41+
* binary compatibility.
42+
*
43+
* @see https://www.compart.com/en/unicode/U+F607
4444
*/
45-
private static final char DOT_COVER_CHAR = '';
45+
private static final char DOT_COVER_CHAR = '\uF607';
4646

4747
private String id;
4848

@@ -106,8 +106,7 @@ public void setAttribute(String attributeName, Object attributeValue) {
106106

107107
if (attributeValue == null) {
108108
removeAttribute(coverDot(attributeName));
109-
}
110-
else {
109+
} else {
111110
this.attrs.put(coverDot(attributeName), attributeValue);
112111
}
113112
}

0 commit comments

Comments
 (0)