1
0
mirror of synced 2026-08-04 01:07:02 +00:00

Remove Advised Methods from Authorization Proxy Objects

Closes gh-15561
This commit is contained in:
DingHao
2024-08-25 10:10:26 +08:00
committed by Josh Cummings
parent ecf6cace82
commit fd05c5ad76
3 changed files with 16 additions and 31 deletions
@@ -2227,37 +2227,6 @@ class UserController {
----
======
If you are using Jackson, though, this may result in a serialization error like the following:
[source,bash]
====
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to cycle
====
This is due to how Jackson works with CGLIB proxies.
To address this, add the following annotation to the top of the `User` class:
[tabs]
======
Java::
+
[source,java,role="primary"]
----
@JsonSerialize(as = User.class)
public class User {
}
----
Kotlin::
+
[source,kotlin,role="secondary"]
----
@JsonSerialize(`as` = User::class)
class User
----
======
Finally, you will need to publish a <<custom_advice, custom interceptor>> to catch the `AccessDeniedException` thrown for each field, which you can do like so:
[tabs]