Skip to content

Commit 53c8884

Browse files
Deprecate background flag for creating indexes.
And fix type in tests.
1 parent 1ac6c48 commit 53c8884

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
@@ -613,7 +613,7 @@ public void compoundIndexOnSuperClassResolvedCorrectly() {
613613
public void compoundIndexDoesNotSpecifyNameWhenUsingGenerateName() {
614614

615615
List<IndexDefinitionHolder> indexDefinitions = prepareMappingContextAndResolveIndexForType(
616-
ComountIndexWithAutogeneratedName.class);
616+
CompoundIndexWithAutogeneratedName.class);
617617

618618
IndexDefinition indexDefinition = indexDefinitions.get(0).getIndexDefinition();
619619
assertThat(indexDefinition.getIndexOptions())
@@ -778,10 +778,10 @@ class SingleCompoundIndex {}
778778

779779
class IndexDefinedOnSuperClass extends CompoundIndexOnLevelZero {}
780780

781-
@Document("ComountIndexWithAutogeneratedName")
781+
@Document("CompoundIndexWithAutogeneratedName")
782782
@CompoundIndexes({ @CompoundIndex(useGeneratedName = true, def = "{'foo': 1, 'bar': -1}", background = true,
783783
sparse = true, unique = true) })
784-
class ComountIndexWithAutogeneratedName {}
784+
class CompoundIndexWithAutogeneratedName {}
785785

786786
@Document("WithComposedAnnotation")
787787
@ComposedCompoundIndex

0 commit comments

Comments
 (0)