2929import org .apache .commons .logging .LogFactory ;
3030import org .bson .Document ;
3131import org .bson .conversions .Bson ;
32+
3233import org .springframework .beans .BeansException ;
3334import org .springframework .context .ApplicationContext ;
3435import org .springframework .context .ApplicationContextAware ;
@@ -2070,6 +2071,8 @@ public <T> GroupByResults<T> group(@Nullable Criteria criteria, String inputColl
20702071 */
20712072 @ Override
20722073 public <O > AggregationResults <O > aggregate (TypedAggregation <?> aggregation , Class <O > outputType ) {
2074+
2075+ Assert .notNull (aggregation , "Aggregation pipeline must not be null" );
20732076 return aggregate (aggregation , getCollectionName (aggregation .getInputType ()), outputType );
20742077 }
20752078
@@ -2079,9 +2082,6 @@ public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, Clas
20792082 @ Override
20802083 public <O > AggregationResults <O > aggregate (TypedAggregation <?> aggregation , String inputCollectionName ,
20812084 Class <O > outputType ) {
2082-
2083- Assert .notNull (aggregation , "Aggregation pipeline must not be null!" );
2084-
20852085 return aggregate (aggregation , inputCollectionName , outputType , null );
20862086 }
20872087
@@ -2091,6 +2091,7 @@ public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, Stri
20912091 @ Override
20922092 public <O > AggregationResults <O > aggregate (Aggregation aggregation , Class <?> inputType , Class <O > outputType ) {
20932093
2094+ Assert .notNull (aggregation , "Aggregation pipeline must not be null" );
20942095 return aggregate (aggregation , getCollectionName (inputType ), outputType ,
20952096 queryOperations .createAggregation (aggregation , inputType ).getAggregationOperationContext ());
20962097 }
@@ -2109,8 +2110,6 @@ public <O> AggregationResults<O> aggregate(Aggregation aggregation, String colle
21092110 @ Override
21102111 public <O > CloseableIterator <O > aggregateStream (TypedAggregation <?> aggregation , String inputCollectionName ,
21112112 Class <O > outputType ) {
2112-
2113- Assert .notNull (aggregation , "Aggregation pipeline must not be null!" );
21142113 return aggregateStream (aggregation , inputCollectionName , outputType , null );
21152114 }
21162115
@@ -2119,6 +2118,8 @@ public <O> CloseableIterator<O> aggregateStream(TypedAggregation<?> aggregation,
21192118 */
21202119 @ Override
21212120 public <O > CloseableIterator <O > aggregateStream (TypedAggregation <?> aggregation , Class <O > outputType ) {
2121+
2122+ Assert .notNull (aggregation , "Aggregation pipeline must not be null" );
21222123 return aggregateStream (aggregation , getCollectionName (aggregation .getInputType ()), outputType );
21232124 }
21242125
@@ -2128,6 +2129,7 @@ public <O> CloseableIterator<O> aggregateStream(TypedAggregation<?> aggregation,
21282129 @ Override
21292130 public <O > CloseableIterator <O > aggregateStream (Aggregation aggregation , Class <?> inputType , Class <O > outputType ) {
21302131
2132+ Assert .notNull (aggregation , "Aggregation pipeline must not be null" );
21312133 return aggregateStream (aggregation , getCollectionName (inputType ), outputType ,
21322134 queryOperations .createAggregation (aggregation , inputType ).getAggregationOperationContext ());
21332135 }
@@ -2286,8 +2288,8 @@ protected <O> AggregationResults<O> doAggregate(Aggregation aggregation, String
22862288 protected <O > CloseableIterator <O > aggregateStream (Aggregation aggregation , String collectionName ,
22872289 Class <O > outputType , @ Nullable AggregationOperationContext context ) {
22882290
2289- Assert .hasText (collectionName , "Collection name must not be null or empty!" );
22902291 Assert .notNull (aggregation , "Aggregation pipeline must not be null!" );
2292+ Assert .hasText (collectionName , "Collection name must not be null or empty!" );
22912293 Assert .notNull (outputType , "Output type must not be null!" );
22922294 Assert .isTrue (!aggregation .getOptions ().isExplain (), "Can't use explain option with streaming!" );
22932295
0 commit comments