spring-projects / spring-projects/spring-hateoas

PageableArgumentResolver unable to apply PageableDefaults.

Open
#252 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
476
PR merge metrics
No merged PRs in 30d

Description

Hi,
I have a legacy Spring MVC App, for which I wrote this controller: Sorry if this is the wrong forum for this.

@Controller
@RequestMapping("/report")
public class ReportResource
{
@Inject private ReportService service;
@RequestMapping(method = RequestMethod.GET, produces = "application/hal+json" )
ResponseEntity getReport(@PageableDefault(size = 100, page = 0) Pageable pageable)
{
System.out.println("size = " + pageable.getPageSize());
return new ResponseEntity<>(HttpStatus.OK);
}
}

when I launch my server I can see in the debugger that the method:
getDefaultFromAnnotationOrFallback() at the PageableArgumentResolver
returns false while evaluating if (annotation instanceof PageableDefaults)
because the annotation handler points to a Proxy class instead of PageableDefaults.

what am I doing wrong?
thanks in advance!

  <import resource="classpath:META-INF/spring/app-context.xml"/>
  <context:component-scan base-package="com.precor.reportingApi.rest"/>
  <bean class="org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration" />

 <mvc:annotation-driven>
    <mvc:argument-resolvers>
      <bean  class="org.springframework.data.web.PageableArgumentResolver"/>
    </mvc:argument-resolvers>
  </mvc:annotation-driven>
</beans>

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with PageableArgumentResolver#getDefaultFromAnnotationOrFallback and the controller's @PageableDefault parameter. Then inspect the mvc:argument-resolvers configuration and the annotation type observed by the resolver. Done means determining why the configured resolver receives a proxy rather than the expected pageable-default annotation and documenting or correcting the supported setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.