Fix new Sonar smells

This commit is contained in:
Artem Bilan
2020-01-24 09:49:23 -05:00
parent cf01b7c0e5
commit a201bdebee
3 changed files with 11 additions and 12 deletions

View File

@@ -21,7 +21,6 @@ import java.util.function.Supplier;
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
import org.springframework.data.mongodb.core.convert.MongoConverter;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.integration.dsl.MessageSourceSpec;
@@ -49,7 +48,7 @@ public class ReactiveMongoDbMessageSourceSpec
/**
* Allow you to set the type of the entityClass that will be passed to the
* {@link ReactiveMongoOperations#find(Query, Class)} or {@link ReactiveMongoOperations#findOne(Query, Class)}
* {@link ReactiveMongoOperations#find} or {@link ReactiveMongoOperations#findOne}
* method.
* Default is {@link com.mongodb.DBObject}.
* @param entityClass The entity class.

View File

@@ -177,7 +177,7 @@ public class MongoDbMessageSource extends AbstractMessageSource<Object> {
//Register MongoDB query API package so FQCN can be avoided in query-expression.
((StandardTypeLocator) typeLocator).registerImport("org.springframework.data.mongodb.core.query");
}
if (this.mongoTemplate == null) {
if (this.mongoDbFactory != null) {
this.mongoTemplate = new MongoTemplate(this.mongoDbFactory, this.mongoConverter);
}
this.initialized = true;

View File

@@ -39,21 +39,20 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.mongodb.DBObject;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* An instance of {@link org.springframework.integration.core.MessageSource} which returns
* a {@link org.springframework.messaging.Message} with a payload which is the result of
* execution of a {@link Query}. When {@code expectSingleResult} is false (default), the MongoDb
* {@link Query} is executed using {@link ReactiveMongoOperations#find(Query, Class)} method which
* returns a {@link Flux}. The returned {@link Flux} will be used as the payload of the
* returns a {@link reactor.core.publisher.Flux}.
* The returned {@link reactor.core.publisher.Flux} will be used as the payload of the
* {@link org.springframework.messaging.Message} returned by the {@link #receive()}
* method.
* <p>
* When {@code expectSingleResult} is true, the {@link ReactiveMongoOperations#findOne(Query, Class)} is
* used instead, and the message payload will be a {@link Mono} for the single object returned from the
* query.
* used instead, and the message payload will be a {@link reactor.core.publisher.Mono}
* for the single object returned from the query.
*
* @author David Turanski
* @author Artem Bilan
@@ -183,7 +182,7 @@ public class ReactiveMongoDbMessageSource extends AbstractMessageSource<Publishe
//Register MongoDB query API package so FQCN can be avoided in query-expression.
((StandardTypeLocator) typeLocator).registerImport("org.springframework.data.mongodb.core.query");
}
if (this.reactiveMongoTemplate == null) {
if (this.reactiveMongoDatabaseFactory != null) {
ReactiveMongoTemplate template =
new ReactiveMongoTemplate(this.reactiveMongoDatabaseFactory, this.mongoConverter);
if (this.applicationContext != null) {
@@ -196,11 +195,12 @@ public class ReactiveMongoDbMessageSource extends AbstractMessageSource<Publishe
/**
* Execute a {@link Query} returning its results as the Message payload.
* The payload can be either {@link Flux} or {@link Mono} of objects of type
* identified by {@link #entityClass}, or a single element of type identified by {@link #entityClass}
* The payload can be either {@link reactor.core.publisher.Flux} or
* {@link reactor.core.publisher.Mono} of objects of type identified by {@link #entityClass},
* or a single element of type identified by {@link #entityClass}
* based on the value of {@link #expectSingleResult} attribute which defaults to 'false' resulting
* {@link org.springframework.messaging.Message} with payload of type
* {@link Flux}. The collection name used in the
* {@link reactor.core.publisher.Flux}. The collection name used in the
* query will be provided in the {@link MongoHeaders#COLLECTION_NAME} header.
*/
@Override