Skip to content

Commit b0ef3c0

Browse files
authored
Fix #5354: do not write cglibs Callback[] getCallbacks() (3.x) (#5357)
1 parent 4a13ca9 commit b0ef3c0

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

release-notes/CREDITS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,8 @@ Dónal Murtagh (@donalmurtagh)
8787
Phil Clay (@philsttr)
8888
* Reported #5344: "Unexpected end-of-input" for `JsonParser.readValueAs()` (in 3.0)
8989
[3.0.1]
90+
91+
Rob Winch (@rwinch)
92+
* Reported, contributed fix for #5354: jackson-databind 3.0.0 renders `callbacks`
93+
property from Spring CGLIB Proxy
94+
[3.0.1]

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Versions: 3.x (for earlier see VERSION-2.x)
1616
(reported by @Artur)
1717
#5344: "Unexpected end-of-input" for `JsonParser.readValueAs()` (in 3.0)
1818
(reported by Phil C)
19+
#5354: jackson-databind 3.0.0 renders `callbacks` property from Spring CGLIB Proxy
20+
(reported, fix contributed by Rob W)
1921

2022
3.0.0 (03-Oct-2025)
2123

src/main/java/tools/jackson/databind/introspect/DefaultAccessorNamingStrategy.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,12 @@ public String findNameForRegularGetter(AnnotatedMethod am, String name)
110110
// coverage without false matches; but for now let's assume there is
111111
// no reason to use any such getter from CGLib.
112112

113-
// 05-Oct-2020, tatu: Removed from Jackson 3.0
114-
/*
113+
// 20-Oct-2025 https://github.com/FasterXML/jackson-databind/issues/5354
115114
if ("getCallbacks".equals(name)) {
116115
if (_isCglibGetCallbacks(am)) {
117116
return null;
118117
}
119-
} else */
120-
if ("getMetaClass".equals(name)) {
118+
} else if ("getMetaClass".equals(name)) {
121119
// 30-Apr-2009, tatu: Need to suppress serialization of a cyclic reference
122120
if (_isGroovyMetaClassGetter(am)) {
123121
return null;
@@ -198,8 +196,7 @@ protected String stdManglePropertyName(final String basename, final int offset)
198196
// name "getCallbacks" and we need to determine if it is indeed injected
199197
// by Cglib. We do this by verifying that the result type is "net.sf.cglib.proxy.Callback[]"
200198

201-
// 05-Oct-2020, tatu: Removed from 3.0
202-
/*
199+
// 20-Oct-2025 https://github.com/FasterXML/jackson-databind/issues/5354
203200
protected boolean _isCglibGetCallbacks(AnnotatedMethod am)
204201
{
205202
Class<?> rt = am.getRawType();
@@ -222,7 +219,6 @@ protected boolean _isCglibGetCallbacks(AnnotatedMethod am)
222219
}
223220
return false;
224221
}
225-
*/
226222

227223
// 05-Oct-2020, tatu: Left in 3.0 for now
228224
// Another helper method to deal with Groovy's problematic metadata accessors

src/test/java/tools/jackson/databind/ext/cglib/CglibFiltering5354Test.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@ public class CglibFiltering5354Test
2424
@Test
2525
public void testWriteWithSpringCglibProxyDoesNotIncludeCallbacksProperty() throws Exception
2626
{
27-
// 20-Oct-2025, tatu: Temporarily disable until #5357 merged
28-
if (true) { return; }
29-
3027
MockedSpringCglibProxy mockedProxy = new MockedSpringCglibProxy("hello");
3128
String json = MAPPER.writeValueAsString(mockedProxy);
3229
Map<?, ?> properties = MAPPER.readValue(json, Map.class);
3330
assertEquals(Collections.singleton("propertyName"), properties.keySet());
3431
}
3532

3633
// https://github.com/FasterXML/jackson-databind/issues/5354
37-
//@Test
34+
@Test
3835
public void testWriteWithHibernateCglibProxyDoesNotIncludeCallbacksProperty() throws Exception
3936
{
4037
MockedHibernateCglibProxy mockedProxy = new MockedHibernateCglibProxy("hello");
@@ -44,7 +41,7 @@ public void testWriteWithHibernateCglibProxyDoesNotIncludeCallbacksProperty() th
4441
}
4542

4643
// https://github.com/FasterXML/jackson-databind/issues/5354
47-
//@Test
44+
@Test
4845
public void testWriteWithNetCglibProxyDoesNotIncludeCallbacksProperty() throws Exception
4946
{
5047
MockedNetCglibProxy mockedProxy = new MockedNetCglibProxy("hello");

0 commit comments

Comments
 (0)