Browse Source

DATAMONGO-2572 - Remove usage of Oppressive Language.

Replaced blacklist with denylist and introduce meta keyword SECONDARY_READS as we no longer use MongoDB API with the initial replication concept.

Original Pull Request: #870
issue/DATAMONGO-2574
Mark Paluch 6 years ago committed by Christoph Strobl
parent
commit
61a228f8ac
  1. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java
  2. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java
  3. 18
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/PrefixingDelegatingAggregationOperationContext.java
  4. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/messaging/ChangeStreamTask.java
  5. 14
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Meta.java
  6. 17
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java
  7. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.0.xsd
  8. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.1.xsd
  9. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.10.2.xsd
  10. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.10.xsd
  11. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.2.xsd
  12. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.3.xsd
  13. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.4.xsd
  14. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.5.xsd
  15. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.7.xsd
  16. 2
      spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.8.xsd
  17. 8
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java
  18. 24
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateUnitTests.java
  19. 18
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/ReactiveMongoTemplateUnitTests.java
  20. 4
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/QueryTests.java
  21. 6
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/MongoQueryMethodUnitTests.java

8
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

@ -1172,7 +1172,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, @@ -1172,7 +1172,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
/**
* Prepare the collection before any processing is done using it. This allows a convenient way to apply settings like
* slaveOk() etc. Can be overridden in sub-classes.
* withCodecRegistry() etc. Can be overridden in sub-classes.
*
* @param collection
*/
@ -3274,6 +3274,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, @@ -3274,6 +3274,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
case PARTIAL:
cursorToUse = cursorToUse.partial(true);
break;
case SECONDARY_READS:
case SLAVE_OK:
break;
default:
@ -3291,7 +3292,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, @@ -3291,7 +3292,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
@Override
public ReadPreference getReadPreference() {
return query.getMeta().getFlags().contains(CursorOption.SLAVE_OK) ? ReadPreference.primaryPreferred() : null;
return (query.getMeta().getFlags().contains(CursorOption.SECONDARY_READS)
|| query.getMeta().getFlags().contains(CursorOption.SLAVE_OK)) ? ReadPreference.primaryPreferred() : null;
}
}
@ -3368,7 +3370,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware, @@ -3368,7 +3370,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
CloseableIterableCursorAdapter(MongoCursor<Document> cursor, PersistenceExceptionTranslator exceptionTranslator,
DocumentCallback<T> objectReadCallback) {
this.cursor = cursor;
this.exceptionTranslator = exceptionTranslator;
this.objectReadCallback = objectReadCallback;

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java

@ -2679,7 +2679,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati @@ -2679,7 +2679,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
/**
* Prepare the collection before any processing is done using it. This allows a convenient way to apply settings like
* slaveOk() etc. Can be overridden in sub-classes.
* withCodecRegistry() etc. Can be overridden in sub-classes.
*
* @param collection
*/
@ -3324,7 +3324,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati @@ -3324,7 +3324,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override
public ReadPreference getReadPreference() {
return query.getMeta().getFlags().contains(CursorOption.SLAVE_OK) ? ReadPreference.primaryPreferred() : null;
return (query.getMeta().getFlags().contains(CursorOption.SECONDARY_READS)
|| query.getMeta().getFlags().contains(CursorOption.SLAVE_OK)) ? ReadPreference.primaryPreferred() : null;
}
}

18
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/PrefixingDelegatingAggregationOperationContext.java

@ -31,7 +31,7 @@ import org.springframework.lang.Nullable; @@ -31,7 +31,7 @@ import org.springframework.lang.Nullable;
* {@link AggregationOperationContext} implementation prefixing non-command keys on root level with the given prefix.
* Useful when mapping fields to domain specific types while having to prefix keys for query purpose.
* <p />
* Fields to be excluded from prefixing my be added to a {@literal blacklist}.
* Fields to be excluded from prefixing my be added to a {@literal denylist}.
*
* @author Christoph Strobl
* @author Mark Paluch
@ -41,18 +41,18 @@ public class PrefixingDelegatingAggregationOperationContext implements Aggregati @@ -41,18 +41,18 @@ public class PrefixingDelegatingAggregationOperationContext implements Aggregati
private final AggregationOperationContext delegate;
private final String prefix;
private final Set<String> blacklist;
private final Set<String> denylist;
public PrefixingDelegatingAggregationOperationContext(AggregationOperationContext delegate, String prefix) {
this(delegate, prefix, Collections.emptySet());
}
public PrefixingDelegatingAggregationOperationContext(AggregationOperationContext delegate, String prefix,
Collection<String> blacklist) {
Collection<String> denylist) {
this.delegate = delegate;
this.prefix = prefix;
this.blacklist = new HashSet<>(blacklist);
this.denylist = new HashSet<>(denylist);
}
/*
@ -121,7 +121,7 @@ public class PrefixingDelegatingAggregationOperationContext implements Aggregati @@ -121,7 +121,7 @@ public class PrefixingDelegatingAggregationOperationContext implements Aggregati
}
private String prefixKey(String key) {
return (key.startsWith("$") || isBlacklisted(key)) ? key : (prefix + "." + key);
return (key.startsWith("$") || isDenied(key)) ? key : (prefix + "." + key);
}
private Object prefixCollection(Collection<Object> sourceCollection) {
@ -139,9 +139,9 @@ public class PrefixingDelegatingAggregationOperationContext implements Aggregati @@ -139,9 +139,9 @@ public class PrefixingDelegatingAggregationOperationContext implements Aggregati
return prefixed;
}
private boolean isBlacklisted(String key) {
private boolean isDenied(String key) {
if (blacklist.contains(key)) {
if (denylist.contains(key)) {
return true;
}
@ -149,8 +149,8 @@ public class PrefixingDelegatingAggregationOperationContext implements Aggregati @@ -149,8 +149,8 @@ public class PrefixingDelegatingAggregationOperationContext implements Aggregati
return false;
}
for (String blacklisted : blacklist) {
if (key.startsWith(blacklisted + ".")) {
for (String denied : denylist) {
if (key.startsWith(denied + ".")) {
return true;
}
}

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/messaging/ChangeStreamTask.java

@ -62,7 +62,7 @@ import com.mongodb.client.model.changestream.FullDocument; @@ -62,7 +62,7 @@ import com.mongodb.client.model.changestream.FullDocument;
*/
class ChangeStreamTask extends CursorReadingTask<ChangeStreamDocument<Document>, Object> {
private final Set<String> blacklist = new HashSet<>(
private final Set<String> denylist = new HashSet<>(
Arrays.asList("operationType", "fullDocument", "documentKey", "updateDescription", "ns"));
private final QueryMapper queryMapper;
@ -176,7 +176,7 @@ class ChangeStreamTask extends CursorReadingTask<ChangeStreamDocument<Document>, @@ -176,7 +176,7 @@ class ChangeStreamTask extends CursorReadingTask<ChangeStreamDocument<Document>,
template.getConverter().getMappingContext(), queryMapper)
: Aggregation.DEFAULT_CONTEXT;
return agg.toPipeline(new PrefixingDelegatingAggregationOperationContext(context, "fullDocument", blacklist));
return agg.toPipeline(new PrefixingDelegatingAggregationOperationContext(context, "fullDocument", denylist));
}
if (filter instanceof List) {

14
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Meta.java

@ -284,9 +284,21 @@ public class Meta { @@ -284,9 +284,21 @@ public class Meta {
*/
EXHAUST,
/** Allows querying of a replica slave. */
/**
* Allows querying of a replica.
*
* @deprecated since 3.0.2, use {@link #SECONDARY_READS} instead.
*/
@Deprecated
SLAVE_OK,
/**
* Allows querying of a replica.
*
* @since 3.0.2
*/
SECONDARY_READS,
/**
* Sets the cursor to return partial data from a query against a sharded cluster in which some shards do not respond
* rather than throwing an error.

17
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Query.java

@ -411,18 +411,33 @@ public class Query { @@ -411,18 +411,33 @@ public class Query {
}
/**
* Allows querying of a replica slave.
* Allows querying of a replica.
*
* @return this.
* @see org.springframework.data.mongodb.core.query.Meta.CursorOption#SLAVE_OK
* @since 1.10
* @deprecated since 3.0.2, use {@link #allowSecondaryReads()}.
*/
@Deprecated
public Query slaveOk() {
meta.addFlag(Meta.CursorOption.SLAVE_OK);
return this;
}
/**
* Allows querying of a replica.
*
* @return this.
* @see org.springframework.data.mongodb.core.query.Meta.CursorOption#SECONDARY_READS
* @since 3.0.2
*/
public Query allowSecondaryReads() {
meta.addFlag(Meta.CursorOption.SECONDARY_READS);
return this;
}
/**
* @return this.
* @see org.springframework.data.mongodb.core.query.Meta.CursorOption#PARTIAL

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.0.xsd

@ -434,7 +434,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -434,7 +434,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.1.xsd

@ -432,7 +432,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -432,7 +432,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.10.2.xsd

@ -531,7 +531,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -531,7 +531,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.10.xsd

@ -531,7 +531,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -531,7 +531,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.2.xsd

@ -447,7 +447,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -447,7 +447,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.3.xsd

@ -462,7 +462,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -462,7 +462,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.4.xsd

@ -480,7 +480,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -480,7 +480,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.5.xsd

@ -498,7 +498,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -498,7 +498,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.7.xsd

@ -531,7 +531,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -531,7 +531,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

2
spring-data-mongodb/src/main/resources/org/springframework/data/mongodb/config/spring-mongo-1.8.xsd

@ -537,7 +537,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c @@ -537,7 +537,7 @@ This controls whether or not to fsync. The 'fsync' option to the getlasterror c
<xsd:attribute name="slave-ok" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
This controls if the driver is allowed to read from secondaries or slaves. Defaults to false.
This controls if the driver is allowed to read from secondaries or replicas. Defaults to false.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

8
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java

@ -1162,7 +1162,7 @@ public class MongoTemplateTests { @@ -1162,7 +1162,7 @@ public class MongoTemplateTests {
assertThat(p5.getFirstName()).isEqualTo("Mark");
}
@Test
@Test // DATAMONGO-2572
public void testUsingReadPreference() throws Exception {
this.template.execute("readPref", new CollectionCallback<Object>() {
public Object doInCollection(MongoCollection<org.bson.Document> collection)
@ -1173,9 +1173,9 @@ public class MongoTemplateTests { @@ -1173,9 +1173,9 @@ public class MongoTemplateTests {
return null;
}
});
MongoTemplate slaveTemplate = new MongoTemplate(factory);
slaveTemplate.setReadPreference(ReadPreference.secondary());
slaveTemplate.execute("readPref", new CollectionCallback<Object>() {
MongoTemplate secondaryTemplate = new MongoTemplate(factory);
secondaryTemplate.setReadPreference(ReadPreference.secondary());
secondaryTemplate.execute("readPref", new CollectionCallback<Object>() {
public Object doInCollection(MongoCollection<org.bson.Document> collection)
throws MongoException, DataAccessException {
assertThat(collection.getReadPreference()).isEqualTo(ReadPreference.secondary());

24
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateUnitTests.java

@ -1714,34 +1714,34 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests { @@ -1714,34 +1714,34 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests {
Assertions.assertThat(ReflectionTestUtils.getField(template, "entityCallbacks")).isSameAs(callbacks);
}
@Test // DATAMONGO-2344
void slaveOkQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFind() {
@Test // DATAMONGO-2344, DATAMONGO-2572
void allowSecondaryReadsQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFind() {
template.find(new Query().slaveOk(), AutogenerateableId.class);
template.find(new Query().allowSecondaryReads(), AutogenerateableId.class);
verify(collection).withReadPreference(eq(ReadPreference.primaryPreferred()));
}
@Test // DATAMONGO-2344
void slaveOkQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFindOne() {
@Test // DATAMONGO-2344, DATAMONGO-2572
void allowSecondaryReadsQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFindOne() {
template.findOne(new Query().slaveOk(), AutogenerateableId.class);
template.findOne(new Query().allowSecondaryReads(), AutogenerateableId.class);
verify(collection).withReadPreference(eq(ReadPreference.primaryPreferred()));
}
@Test // DATAMONGO-2344
void slaveOkQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFindDistinct() {
@Test // DATAMONGO-2344, DATAMONGO-2572
void allowSecondaryReadsQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFindDistinct() {
template.findDistinct(new Query().slaveOk(), "name", AutogenerateableId.class, String.class);
template.findDistinct(new Query().allowSecondaryReads(), "name", AutogenerateableId.class, String.class);
verify(collection).withReadPreference(eq(ReadPreference.primaryPreferred()));
}
@Test // DATAMONGO-2344
void slaveOkQueryOptionShouldApplyPrimaryPreferredReadPreferenceForStream() {
@Test // DATAMONGO-2344, DATAMONGO-2572
void allowSecondaryReadsQueryOptionShouldApplyPrimaryPreferredReadPreferenceForStream() {
template.stream(new Query().slaveOk(), AutogenerateableId.class);
template.stream(new Query().allowSecondaryReads(), AutogenerateableId.class);
verify(collection).withReadPreference(eq(ReadPreference.primaryPreferred()));
}

18
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/ReactiveMongoTemplateUnitTests.java

@ -896,26 +896,26 @@ public class ReactiveMongoTemplateUnitTests { @@ -896,26 +896,26 @@ public class ReactiveMongoTemplateUnitTests {
Assertions.assertThat(ReflectionTestUtils.getField(template, "entityCallbacks")).isSameAs(callbacks);
}
@Test // DATAMONGO-2344
void slaveOkQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFind() {
@Test // DATAMONGO-2344, DATAMONGO-2572
void allowSecondaryReadsQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFind() {
template.find(new Query().slaveOk(), AutogenerateableId.class).subscribe();
template.find(new Query().allowSecondaryReads(), AutogenerateableId.class).subscribe();
verify(collection).withReadPreference(eq(ReadPreference.primaryPreferred()));
}
@Test // DATAMONGO-2344
void slaveOkQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFindOne() {
@Test // DATAMONGO-2344, DATAMONGO-2572
void allowSecondaryReadsQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFindOne() {
template.findOne(new Query().slaveOk(), AutogenerateableId.class).subscribe();
template.findOne(new Query().allowSecondaryReads(), AutogenerateableId.class).subscribe();
verify(collection).withReadPreference(eq(ReadPreference.primaryPreferred()));
}
@Test // DATAMONGO-2344
void slaveOkQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFindDistinct() {
@Test // DATAMONGO-2344, DATAMONGO-2572
void allowSecondaryReadsQueryOptionShouldApplyPrimaryPreferredReadPreferenceForFindDistinct() {
template.findDistinct(new Query().slaveOk(), "name", AutogenerateableId.class, String.class).subscribe();
template.findDistinct(new Query().allowSecondaryReads(), "name", AutogenerateableId.class, String.class).subscribe();
verify(collection).withReadPreference(eq(ReadPreference.primaryPreferred()));
}

4
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/QueryTests.java

@ -297,14 +297,14 @@ class QueryTests { @@ -297,14 +297,14 @@ class QueryTests {
.isNotEqualTo(source.getFieldsObject());
}
@Test // DATAMONGO-1783
@Test // DATAMONGO-1783, DATAMONGO-2572
void clonedQueryShouldNotDependOnMetaFromSource() {
Query source = new Query().maxTimeMsec(100);
Query target = Query.of(source);
compareQueries(target, source);
source.slaveOk();
source.allowSecondaryReads();
Meta meta = new Meta();
meta.setMaxTimeMsec(100);

6
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/MongoQueryMethodUnitTests.java

@ -194,7 +194,7 @@ public class MongoQueryMethodUnitTests { @@ -194,7 +194,7 @@ public class MongoQueryMethodUnitTests {
.contains(org.springframework.data.mongodb.core.query.Meta.CursorOption.NO_TIMEOUT);
}
@Test // DATAMONGO-1480
@Test // DATAMONGO-1480, DATAMONGO-2572
public void createsMongoQueryMethodWithMultipleFlagsCorrectly() throws Exception {
MongoQueryMethod method = queryMethod(PersonRepository.class, "metaWithMultipleFlags");
@ -202,7 +202,7 @@ public class MongoQueryMethodUnitTests { @@ -202,7 +202,7 @@ public class MongoQueryMethodUnitTests {
assertThat(method.hasQueryMetaAttributes()).isTrue();
assertThat(method.getQueryMetaAttributes().getFlags()).contains(
org.springframework.data.mongodb.core.query.Meta.CursorOption.NO_TIMEOUT,
org.springframework.data.mongodb.core.query.Meta.CursorOption.SLAVE_OK);
org.springframework.data.mongodb.core.query.Meta.CursorOption.SECONDARY_READS);
}
@Test // DATAMONGO-1266
@ -273,7 +273,7 @@ public class MongoQueryMethodUnitTests { @@ -273,7 +273,7 @@ public class MongoQueryMethodUnitTests {
List<User> metaWithNoCursorTimeout();
@Meta(flags = { org.springframework.data.mongodb.core.query.Meta.CursorOption.NO_TIMEOUT,
org.springframework.data.mongodb.core.query.Meta.CursorOption.SLAVE_OK })
org.springframework.data.mongodb.core.query.Meta.CursorOption.SECONDARY_READS })
List<User> metaWithMultipleFlags();
// DATAMONGO-1266

Loading…
Cancel
Save