|
17 | 17 |
|
18 | 18 | import static org.springframework.data.mongodb.core.query.SerializationUtils.*;
|
19 | 19 |
|
20 |
| -import org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition; |
21 |
| -import org.springframework.data.mongodb.core.aggregation.RelaxedTypeBasedAggregationOperationContext; |
22 | 20 | import reactor.core.publisher.Flux;
|
23 | 21 | import reactor.core.publisher.Mono;
|
24 | 22 | import reactor.util.function.Tuple2;
|
|
38 | 36 | import org.reactivestreams.Subscriber;
|
39 | 37 | import org.slf4j.Logger;
|
40 | 38 | import org.slf4j.LoggerFactory;
|
41 |
| - |
42 | 39 | import org.springframework.beans.BeansException;
|
43 | 40 | import org.springframework.context.ApplicationContext;
|
44 | 41 | import org.springframework.context.ApplicationContextAware;
|
|
63 | 60 | import org.springframework.data.mongodb.ReactiveMongoDatabaseUtils;
|
64 | 61 | import org.springframework.data.mongodb.SessionSynchronization;
|
65 | 62 | import org.springframework.data.mongodb.core.EntityOperations.AdaptibleEntity;
|
| 63 | +import org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition; |
66 | 64 | import org.springframework.data.mongodb.core.QueryOperations.CountContext;
|
67 | 65 | import org.springframework.data.mongodb.core.QueryOperations.DeleteContext;
|
68 | 66 | import org.springframework.data.mongodb.core.QueryOperations.DistinctQueryContext;
|
|
72 | 70 | import org.springframework.data.mongodb.core.aggregation.AggregationOperationContext;
|
73 | 71 | import org.springframework.data.mongodb.core.aggregation.AggregationOptions;
|
74 | 72 | import org.springframework.data.mongodb.core.aggregation.PrefixingDelegatingAggregationOperationContext;
|
| 73 | +import org.springframework.data.mongodb.core.aggregation.RelaxedTypeBasedAggregationOperationContext; |
75 | 74 | import org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext;
|
76 | 75 | import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
|
77 | 76 | import org.springframework.data.mongodb.core.convert.DbRefResolver;
|
@@ -157,18 +156,6 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
157 | 156 |
|
158 | 157 | private static final Logger LOGGER = LoggerFactory.getLogger(ReactiveMongoTemplate.class);
|
159 | 158 | private static final WriteResultChecking DEFAULT_WRITE_RESULT_CHECKING = WriteResultChecking.NONE;
|
160 |
| - private static final Collection<Class<?>> ITERABLE_CLASSES; |
161 |
| - |
162 |
| - static { |
163 |
| - |
164 |
| - Set<Class<?>> iterableClasses = new HashSet<>(); |
165 |
| - iterableClasses.add(List.class); |
166 |
| - iterableClasses.add(Collection.class); |
167 |
| - iterableClasses.add(Iterator.class); |
168 |
| - iterableClasses.add(Publisher.class); |
169 |
| - |
170 |
| - ITERABLE_CLASSES = Collections.unmodifiableCollection(iterableClasses); |
171 |
| - } |
172 | 159 |
|
173 | 160 | private final MongoConverter mongoConverter;
|
174 | 161 | private final MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext;
|
@@ -2668,13 +2655,27 @@ private MongoCollection<Document> getAndPrepareCollection(MongoDatabase db, Stri
|
2668 | 2655 | }
|
2669 | 2656 | }
|
2670 | 2657 |
|
2671 |
| - protected void ensureNotIterable(Object o) { |
| 2658 | + /** |
| 2659 | + * Ensure the given {@literal source} is not an {@link java.lang.reflect.Array}, {@link Collection} or |
| 2660 | + * {@link Iterator}. |
| 2661 | + * |
| 2662 | + * @param source can be {@literal null}. |
| 2663 | + * @deprecated since 3.2. Call {@link #ensureNotCollectionLike(Object)} instead. |
| 2664 | + */ |
| 2665 | + protected void ensureNotIterable(@Nullable Object source) { |
| 2666 | + ensureNotCollectionLike(source); |
| 2667 | + } |
2672 | 2668 |
|
2673 |
| - boolean isIterable = o.getClass().isArray() |
2674 |
| - || ITERABLE_CLASSES.stream().anyMatch(iterableClass -> iterableClass.isAssignableFrom(o.getClass()) |
2675 |
| - || o.getClass().getName().equals(iterableClass.getName())); |
| 2669 | + /** |
| 2670 | + * Ensure the given {@literal source} is not an {@link java.lang.reflect.Array}, {@link Collection} or |
| 2671 | + * {@link Iterator}. |
| 2672 | + * |
| 2673 | + * @param source can be {@literal null}. |
| 2674 | + * @since 3.2. |
| 2675 | + */ |
| 2676 | + protected void ensureNotCollectionLike(@Nullable Object source) { |
2676 | 2677 |
|
2677 |
| - if (isIterable) { |
| 2678 | + if (EntityOperations.isCollectionLike(source) || source instanceof Publisher) { |
2678 | 2679 | throw new IllegalArgumentException("Cannot use a collection here.");
|
2679 | 2680 | }
|
2680 | 2681 | }
|
|
0 commit comments