DATAMONGO-1608 - Add guard against NPE in MongoQueryCreator when using IgnoreCase.

Original Pull Request: #439
This commit is contained in:
Edward Prentice
2017-02-07 21:27:40 +00:00
committed by Christoph Strobl
parent 439616c788
commit eacfd2c172
2 changed files with 18 additions and 2 deletions

View File

@@ -55,6 +55,7 @@ import org.springframework.util.ClassUtils;
* @author Oliver Gierke
* @author Thomas Darimont
* @author Christoph Strobl
* @author Edward Prentice
*/
class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
@@ -297,7 +298,9 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
criteria = criteria.not();
}
return addAppropriateLikeRegexTo(criteria, part, parameters.next().toString());
Object next = parameters.next();
return addAppropriateLikeRegexTo(criteria, part, next != null ? next.toString() : "");
case NEVER:
// intentional no-op

View File

@@ -66,6 +66,8 @@ import org.springframework.test.util.ReflectionTestUtils;
* @author Thomas Darimont
* @author Christoph Strobl
* @author Mark Paluch
* @author Fırat KÜÇÜK
* @author Edward Prentice
*/
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class AbstractPersonRepositoryIntegrationTests {
@@ -712,6 +714,17 @@ public abstract class AbstractPersonRepositoryIntegrationTests {
assertThat(results.getAverageDistance().getMetric(), is((Metric) Metrics.KILOMETERS));
}
/***
* @see DATAMONGO-1608
*/
@Test
public void findByFirstNameIgnoreCaseWithNull() {
List<Person> result = repository.findByFirstnameIgnoreCase(null);
assertThat(result.size(), is(0));
}
/**
* @see DATAMONGO-770
*/
@@ -1010,7 +1023,7 @@ public abstract class AbstractPersonRepositoryIntegrationTests {
/**
* Ignored for now as this requires Querydsl 3.4.1 to succeed.
*
*
* @see DATAMONGO-972
*/
@Test