Skip to content

Commit d732700

Browse files
christophstroblschauder
authored andcommitted
Deprecate background flag for creating indexes.
And fix type name in tests. See #5074 Original pull request #5085
1 parent 38dcb1a commit d732700

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndex.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,15 @@
152152

153153
/**
154154
* If {@literal true} the index will be created in the background.
155+
* <p>
156+
* <strong>NOTE:</strong> Since MongoDB 4.2 the background flag is ignored by the server if set.
155157
*
156158
* @return {@literal false} by default.
157159
* @see <a href=
158160
* "https://docs.mongodb.org/manual/core/indexes/#background-construction">https://docs.mongodb.org/manual/core/indexes/#background-construction</a>
161+
* @deprecated since 5.0 for removal without replacement.
159162
*/
163+
@Deprecated(since = "5.0", forRemoval = true)
160164
boolean background() default false;
161165

162166
/**

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Index.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,15 @@ public Index sparse() {
9494

9595
/**
9696
* Build the index in background (non blocking).
97+
* <p>
98+
* <strong>NOTE:</strong> Since MongoDB 4.2 the background flag is ignored by the server if set.
9799
*
98100
* @return this.
99101
* @since 1.5
100-
*/@Contract("-> this")
102+
* @deprecated since 5.0 for removal without replacement.
103+
*/
104+
@Deprecated(since = "5.0", forRemoval = true)
105+
@Contract("-> this")
101106
public Index background() {
102107

103108
this.background = true;

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/Indexed.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@
123123

124124
/**
125125
* If {@literal true} the index will be created in the background.
126+
* <p>
127+
* <strong>NOTE:</strong> Since MongoDB 4.2 the background flag is ignored by the server if set.
126128
*
127129
* @return {@literal false} by default.
130+
* @deprecated since 5.0 for removal without replacement.
128131
* @see <a href=
129132
* "https://docs.mongodb.org/manual/core/indexes/#background-construction">https://docs.mongodb.org/manual/core/indexes/#background-construction</a>
130133
*/
134+
@Deprecated(since = "5.0", forRemoval = true)
131135
boolean background() default false;
132136

133137
/**

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ public void compoundIndexOnSuperClassResolvedCorrectly() {
670670
public void compoundIndexDoesNotSpecifyNameWhenUsingGenerateName() {
671671

672672
List<IndexDefinitionHolder> indexDefinitions = prepareMappingContextAndResolveIndexForType(
673-
ComountIndexWithAutogeneratedName.class);
673+
CompoundIndexWithAutogeneratedName.class);
674674

675675
IndexDefinition indexDefinition = indexDefinitions.get(0).getIndexDefinition();
676676
assertThat(indexDefinition.getIndexOptions())
@@ -835,10 +835,10 @@ class SingleCompoundIndex {}
835835

836836
class IndexDefinedOnSuperClass extends CompoundIndexOnLevelZero {}
837837

838-
@Document("ComountIndexWithAutogeneratedName")
838+
@Document("CompoundIndexWithAutogeneratedName")
839839
@CompoundIndexes({ @CompoundIndex(useGeneratedName = true, def = "{'foo': 1, 'bar': -1}", background = true,
840840
sparse = true, unique = true) })
841-
class ComountIndexWithAutogeneratedName {}
841+
class CompoundIndexWithAutogeneratedName {}
842842

843843
@Document("WithComposedAnnotation")
844844
@ComposedCompoundIndex

0 commit comments

Comments
 (0)