Skip to content

Commit d8d2495

Browse files
fix flaky test writesAndReadsCustomFieldsConvertedClass (#1264)
1 parent 9f2d7ee commit d8d2495

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
import com.couchbase.client.java.json.JsonObject;
2020

21-
import java.util.HashMap;
21+
import java.util.TreeMap;
2222
import java.util.Map;
2323

2424
/**
2525
* A {@link CouchbaseDocument} is an abstract representation of a document stored inside Couchbase Server.
2626
* <p/>
2727
* <p>
28-
* It acts like a {@link HashMap}, but only allows those types to be written that are supported by the underlying
28+
* It acts like a {@link TreeMap}, but only allows those types to be written that are supported by the underlying
2929
* storage format, which is currently JSON. Note that JSON conversion is not happening here, but performed at a
3030
* different stage based on the payload stored in the {@link CouchbaseDocument}.
3131
* </p>
@@ -85,7 +85,7 @@ public CouchbaseDocument(final String id) {
8585
public CouchbaseDocument(final String id, final int expiration) {
8686
this.id = id;
8787
this.expiration = expiration;
88-
content = new HashMap<>();
88+
content = new TreeMap<>();
8989
}
9090

9191
/**
@@ -119,8 +119,8 @@ public final Object get(final String key) {
119119
*
120120
* @return
121121
*/
122-
public final HashMap<String, Object> export() {
123-
HashMap<String, Object> toExport = new HashMap<String, Object>(content);
122+
public final TreeMap<String, Object> export() {
123+
TreeMap<String, Object> toExport = new TreeMap<String, Object>(content);
124124
for (Map.Entry<String, Object> entry : content.entrySet()) {
125125
if (entry.getValue() instanceof CouchbaseDocument) {
126126
toExport.put(entry.getKey(), ((CouchbaseDocument) entry.getValue()).export());

src/test/java/org/springframework/data/couchbase/core/mapping/MappingCouchbaseConverterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ void writesAndReadsCustomConvertedClass() {
455455
List<BigDecimal> listOfValues = new ArrayList<>();
456456
listOfValues.add(value);
457457
listOfValues.add(value2);
458-
Map<String, BigDecimal> mapOfValues = new HashMap<>();
458+
Map<String, BigDecimal> mapOfValues = new TreeMap<>();
459459
mapOfValues.put("val1", value);
460460
mapOfValues.put("val2", value2);
461461

0 commit comments

Comments
 (0)