Skip to content

Commit 8365566

Browse files
committed
Refine QuerydslRepositoryInvokerAdapter nullability assertions.
QuerydslRepositoryInvokerAdapter now rejects null predicates to enforce nullability constraints. Closes #1501
1 parent 34f212f commit 8365566

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/main/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ public class QuerydslRepositoryInvokerAdapter implements RepositoryInvoker {
4444
*
4545
* @param delegate must not be {@literal null}.
4646
* @param executor must not be {@literal null}.
47-
* @param predicate can be {@literal null}.
47+
* @param predicate must not be {@literal null}.
4848
*/
4949
public QuerydslRepositoryInvokerAdapter(RepositoryInvoker delegate, QuerydslPredicateExecutor<Object> executor,
5050
Predicate predicate) {
5151

5252
Assert.notNull(delegate, "Delegate RepositoryInvoker must not be null");
5353
Assert.notNull(executor, "QuerydslPredicateExecutor must not be null");
54+
Assert.notNull(predicate, "Predicate must not be null");
5455

5556
this.delegate = delegate;
5657
this.executor = executor;

src/test/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapterUnitTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.querydsl;
1717

18+
import static org.assertj.core.api.Assertions.*;
1819
import static org.mockito.Mockito.*;
1920

2021
import java.io.Serializable;
@@ -24,7 +25,6 @@
2425
import org.junit.jupiter.api.extension.ExtendWith;
2526
import org.mockito.Mock;
2627
import org.mockito.junit.jupiter.MockitoExtension;
27-
2828
import org.springframework.data.domain.PageRequest;
2929
import org.springframework.data.domain.Sort;
3030
import org.springframework.data.repository.support.RepositoryInvoker;
@@ -35,6 +35,7 @@
3535
* Unit tests for {@link QuerydslRepositoryInvokerAdapter}.
3636
*
3737
* @author Oliver Gierke
38+
* @author Mark Paluch
3839
* @soundtrack Emilie Nicolas - Grown Up
3940
*/
4041
@ExtendWith(MockitoExtension.class)
@@ -51,6 +52,13 @@ void setUp() {
5152
this.adapter = new QuerydslRepositoryInvokerAdapter(delegate, executor, predicate);
5253
}
5354

55+
@Test // GH-1501
56+
void rejectsNullPredicate() {
57+
58+
assertThatIllegalArgumentException()
59+
.isThrownBy(() -> new QuerydslRepositoryInvokerAdapter(delegate, executor, null));
60+
}
61+
5462
@Test // DATACMNS-669
5563
void forwardsFindAllToExecutorWithPredicate() {
5664

0 commit comments

Comments
 (0)