You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementing custom logic for an error response is done by extending DefaultErrorAttributes, overriding getErrorAttributes() and changing the map returned by super.getErrorAttributes(request, options).
I think it does not behave correctly anymore since this change, because now getErrorAttributes() is called twice - on the first call the options only include STATUS and on the second call the options are ErrorAttributeOptions.defaults() (or whatever is configured), see: 60b7e6c#diff-b4233363b899b2fb4ab8045726ed3e9d6d04c766cb363c2973c137750b340b62R150-R151
When using custom logic this may lead to a NPE when the map unexpectedly only contains "status" on the first call.
It still works correctly for the non-reactive version where getErrorAttributes() is only called once when overriden.
We could handle the first call ourselves by discarding it when the options only include STATUS but I don't think that's the desired solution.
In Version 3.3.1 60b7e6c got merged.
Implementing custom logic for an error response is done by extending
DefaultErrorAttributes
, overridinggetErrorAttributes()
and changing the map returned bysuper.getErrorAttributes(request, options)
.I think it does not behave correctly anymore since this change, because now
getErrorAttributes()
is called twice - on the first call theoptions
only includeSTATUS
and on the second call the options areErrorAttributeOptions.defaults()
(or whatever is configured), see: 60b7e6c#diff-b4233363b899b2fb4ab8045726ed3e9d6d04c766cb363c2973c137750b340b62R150-R151When using custom logic this may lead to a NPE when the map unexpectedly only contains
"status"
on the first call.It still works correctly for the non-reactive version where
getErrorAttributes()
is only called once when overriden.We could handle the first call ourselves by discarding it when the options only include
STATUS
but I don't think that's the desired solution.Simple Test-Project: https://github.com/hsteinmueller/spring-error-attributes-bug/blob/master/error-attributes-demo-reactive/src/main/java/org/example/errorattributesdemoreactive/CustomErrorAttributes.java
The text was updated successfully, but these errors were encountered: