Skip to content

Commit d294d50

Browse files
Polishing.
Update javadoc to reflect recent changes and split tests. Original Pull Request: #4666
1 parent 52ba939 commit d294d50

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOptions.java

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
* Holds a set of configurable aggregation options that can be used within an aggregation pipeline. A list of support
3434
* aggregation options can be found in the
3535
* <a href="https://docs.mongodb.org/manual/reference/command/aggregate/#aggregate">MongoDB reference documentation</a>.
36+
* <p>
37+
* As off 4.3 {@link #allowDiskUse} can be {@literal null}, indicating use of server default, and may only be applied if
38+
* {@link #isAllowDiskUseSet() explicitly set}. For compatibility reasons {@link #isAllowDiskUse()} will remain
39+
* returning {@literal false} if the no value has been set.
3640
*
3741
* @author Thomas Darimont
3842
* @author Oliver Gierke

Diff for: spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationOptionsTests.java

+17
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,30 @@ void omitsAllowDiskUseByDefault() {
8686
assertThat(aggregationOptions.isAllowDiskUseSet()).isFalse();
8787

8888
assertThat(aggregationOptions.toDocument()).doesNotContainKey("allowDiskUse");
89+
}
90+
91+
@Test // GH-4664
92+
void applyOptionsDoesNotChangeAllowDiskUseDefault() {
93+
94+
aggregationOptions = AggregationOptions.fromDocument(new Document());
8995

9096
Document empty = new Document();
9197
aggregationOptions.applyAndReturnPotentiallyChangedCommand(empty);
9298

9399
assertThat(empty).doesNotContainKey("allowDiskUse");
94100
}
95101

102+
@Test // GH-4664
103+
void applyOptionsDoesNotChangeExistingAllowDiskUse() {
104+
105+
aggregationOptions = AggregationOptions.fromDocument(new Document());
106+
107+
Document existing = new Document("allowDiskUse", true);
108+
aggregationOptions.applyAndReturnPotentiallyChangedCommand(existing);
109+
110+
assertThat(existing).containsEntry("allowDiskUse", true);
111+
}
112+
96113
@Test // DATAMONGO-960, DATAMONGO-2153, DATAMONGO-1836
97114
void aggregationOptionsToString() {
98115

0 commit comments

Comments
 (0)