Skip to content

Commit 9137119

Browse files
committed
Add nullability annotations to preHandle and postHandle methods in GlobalUserModelInterceptor
1 parent 5ab1815 commit 9137119

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/com/digitalsanctuary/spring/user/web/GlobalUserModelInterceptor.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.digitalsanctuary.spring.user.web;
22

33

4+
import org.springframework.lang.NonNull;
5+
import org.springframework.lang.Nullable;
46
import org.springframework.security.core.context.SecurityContextHolder;
57
import org.springframework.stereotype.Component;
68
import org.springframework.web.method.HandlerMethod;
@@ -27,7 +29,7 @@ public class GlobalUserModelInterceptor implements HandlerInterceptor {
2729
* Pre-handle method to allow all requests to proceed by default.
2830
*/
2931
@Override
30-
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
32+
public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) throws Exception {
3133
// Allow all requests to proceed by default
3234
log.debug("Handling request for path: {}", request.getRequestURI());
3335

@@ -39,7 +41,8 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
3941
* Post-handle method to add the current user to the model for applicable requests.
4042
*/
4143
@Override
42-
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
44+
public void postHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler,
45+
@Nullable ModelAndView modelAndView) throws Exception {
4346
log.debug("handler is: {}", handler.getClass().getName());
4447
log.debug("modelAndView: {}", modelAndView);
4548
if (modelAndView == null || !(handler instanceof HandlerMethod)) {
@@ -58,7 +61,7 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response,
5861
}
5962
} else {
6063
// Global Opt-Out Mode (globalUserModelOptIn=false) - DEFAULT:
61-
// - User is NOT added to any views by default
64+
// - User is NOT added to any views by default
6265
// - Only add if @IncludeUserInModel is present
6366
if (!hasAnnotation(handlerMethod, IncludeUserInModel.class)) {
6467
return; // Skip - not explicitly included

0 commit comments

Comments
 (0)