Skip to content
Snippets Groups Projects

Log the model when filter thymeleaf exception occurs

The stacktrace from the logs in production provided inadquate information to reproduce the problem, hence we added logging of the model variables if the exception occurs.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
79 83 @Autowired
80 84 private RoomRepository roomRepository;
81 85
86 @Autowired
87 private ViewResolver viewResolver;
88 private Logger logger = LoggerFactory.getLogger(ErrorControllerAdvice.class);
  • Is this logger creation copied over from ErrorControllerAdvice? I don't know if we use the feature, but it might be nice and less confusing to use the matching class to get a logger.

  • Please register or sign in to reply
  • The MR is clear in what it should do. I see you wired a ViewResolver to manually catch errors regarding thymeleaf template resolving. The test regarding this page failed, however. This test seems to check if the model contains some requests attribute and whether the GET /requests request returned a 200 status. The following can be found in the build log: RequestControllerTest.testRequestList:100 No ModelAndView found. I believe this may be because you no longer return a string at the end of the method. You may be able to manually return a View-Model pair?

    Also, did you check that the page still loads in a browser?

    Edited by Chris Lemaire
  • 98 106 @PreAuthorize("@permissionService.canViewRequests(principal)")
    99 public String list( HttpServletRequest httpRequest,
    107 public void list( HttpServletRequest httpRequest,
    108 HttpServletResponse httpServletResponse,
    100 109 @AuthenticatedUser User user, Model model,
    101 110 @RequestParam MultiValueMap<String, String> parameters,
    102 111 @QuerydslPredicate(root = Request.class) Predicate predicate,
    103 @PageableDefault(sort = "id", direction = Sort.Direction.DESC, size = 25) Pageable pageable) {
    112 @PageableDefault(sort = "id", direction = Sort.Direction.DESC, size = 25) Pageable pageable)
    113 throws Exception {
    104 114 if (RequestMethod.POST.name().equals(httpRequest.getMethod())) {
    105 115 requestTableService.submitFilters(httpRequest, parameters, predicate);
    106 116 pageable = new PageRequest(0, pageable.getPageSize(), pageable.getSort());
    107 117 }
    108 118
    119 org.springframework.web.servlet.View view = viewResolver.resolveViewName("request/list", Locale.US);
  • closed

  • Please register or sign in to reply
    Loading