DATAJPA-201 - Fixed NullPointerException for null Pageables.
The optimization for DATAJPA-124 introduced a NullPointerException being thrown if the Pageable instance handed to a paging query was null. Added a guard to handle this situation correctly. Unfortunately had to disable the test case for EclipseLink as the bug with HSQL still exists.
This commit is contained in:
@@ -104,7 +104,8 @@ public abstract class JpaQueryExecution {
|
||||
ParameterAccessor accessor = new ParametersParameterAccessor(parameters, values);
|
||||
Pageable pageable = accessor.getPageable();
|
||||
|
||||
List<Object> content = total > pageable.getOffset() ? query.getResultList() : Collections.emptyList();
|
||||
List<Object> content = pageable == null || total > pageable.getOffset() ? query.getResultList() : Collections
|
||||
.emptyList();
|
||||
|
||||
return new PageImpl<Object>(content, pageable, total);
|
||||
}
|
||||
|
||||
@@ -35,4 +35,12 @@ public class EclipseLinkNamespaceUserRepositoryTests extends NamespaceUserReposi
|
||||
public void findsAllByGivenIds() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignored until https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 is resolved.
|
||||
*/
|
||||
@Override
|
||||
public void allowsExecutingPageableMethodWithNullPageable() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,6 +818,7 @@ public class UserRepositoryTests {
|
||||
/**
|
||||
* @see DATAJPA-201
|
||||
*/
|
||||
@Test
|
||||
public void allowsExecutingPageableMethodWithNullPageable() {
|
||||
|
||||
flushTestUsers();
|
||||
@@ -829,6 +830,10 @@ public class UserRepositoryTests {
|
||||
Page<User> page = repository.findByFirstnameIn(null, "Oliver");
|
||||
assertThat(page.getNumberOfElements(), is(1));
|
||||
assertThat(page.getContent(), hasItem(firstUser));
|
||||
|
||||
page = repository.findAll((Pageable) null);
|
||||
assertThat(page.getNumberOfElements(), is(3));
|
||||
assertThat(page.getContent(), hasItems(firstUser, secondUser, thirdUser));
|
||||
}
|
||||
|
||||
protected void flushTestUsers() {
|
||||
|
||||
Reference in New Issue
Block a user