-
Notifications
You must be signed in to change notification settings - Fork 687
Log a warning if param not annotated with @ProjectedPayload
#3303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduces a warning log if a parameter is not annotated with `@ProjectedPayload` that this style is deprecated and that we will drop support for projections if a parameter (or the parameter type) is not explicitly annotated with `@ProjectedPayload`. Resolves #3300 Signed-off-by: Chris Bono <chris.bono@broadcom.com>
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Outdated
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Outdated
Show resolved
Hide resolved
src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java
Outdated
Show resolved
Hide resolved
|
||
private final LogAccessor logger = new LogAccessor(ProxyingHandlerMethodArgumentResolver.class); | ||
|
||
private final ConcurrentHashMap<MethodParameter, Boolean> loggedParameters = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My spidey-senses are typically activated when I add a map of things that could ultimately grow unbounded and OOME if something went awry. That would lead me to use the ConcurrentLruCache
from framework. However, the added complexity plus the LruCache get
API has no signal as to whether the cache was originally empty (this is the signal I needed). I chose simplicity over paranoia here.
What is the biggest number of method params we have encountered in the wilderness via bug reports etc..???
IOW - you good w/ this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to switch to a simple static boolean? I guess a single warning is just enough. That would reduce this to a Logger
declaration in ProxyingHandlerMethodArgumentResolver
and a simple if
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thinking behind logging per parameter is that the user will get a more directly actionable message. Otherwise they may end up doing wak-a-mole to find the problematic parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR to include more context/location in the log message. It now looks like:
2025-06-02 11:18:57,706 WARN eb.ProxyingHandlerMethodArgumentResolver: 271 - Parameter 'foo' at position 0 in org.springframework.data.web.ProxyingHandlerMethodArgumentResolverUnitTests$Controller.withModelAttribute is not annotated with @ProjectedPayload - support for parameters not explicitly annotated with @ProjectedPayload (at the parameter or type level) will be dropped in a future version.
- Move logger up to resolver Signed-off-by: Chris Bono <chris.bono@broadcom.com>
Signed-off-by: Chris Bono <chris.bono@broadcom.com>
This commit introduces a warning log if a parameter is not annotated with `@ProjectedPayload` that this style is deprecated and that we will drop support for projections if a parameter (or the parameter type) is not explicitly annotated with `@ProjectedPayload`. Resolves #3300 Original pull request: #3303 Signed-off-by: Chris Bono <chris.bono@broadcom.com>
This commit introduces a warning log if a parameter is not annotated with
@ProjectedPayload
that this style is deprecated and that we will drop support for projections if a parameter is not annotated with@ProjectedPayload
.Resolves #3300
The output log message looks as follows:
Note
If the parameter actually has a name (
MethodParameter.getName() != null
) then it will be included just before(method 'withModelAttribute' parameter...