Skip to content

jackson-databind 3.0.0 renders callbacks property from Spring CGLIB Proxy #5354

@rwinch

Description

@rwinch

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

jackson-databind 3.0.0 renders the callbacks property from Spring CGLIB Proxy which appears to be a regression of #674 that occurred in be90675

This change broke Spring Security's / Jackson tests that confirm that objects secured using Spring Security proxies do not render properties on the proxy itself. Details can be found at spring-projects/spring-security#18077

Can the ignoring of CGLIB be restored? If not, what is the reason and what is the recommended way that users should restore this behavior in Jackson 3?

Version Information

tools.jackson.core:jackson-databind-3.0.0

Reproduction

A complete example of the callbacks property not being rendered in Jackson 2 and rendering callbacks property in Jackson 3 can be found at https://github.com/rwinch/spring-sample/tree/jackson-cglib-properties You can run ./gradlew check to perform checks for both Jackson 2 and Jackson 3 or ./gradlew jackson2 and ./gradlew jackson3 to run the tests separately.

static class Person {
	private final String firstName;

	private final String lastName;

	public Person(String firstName, String lastName) {
		this.firstName = firstName;
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}
}

@Test
public void cglibPropertiesNotRendered() throws Exception {
	JsonMapper mapper = JsonMapper.builder().build();
	Person target = new Person("first", "last");
	ProxyFactory factory = new ProxyFactory(target); // ProxyFactory from org.springframework:spring-aop:7.0.0-RC1
	factory.setOpaque(true);

	Person proxied = (Person) factory.getProxy();
	String json = mapper.writeValueAsString(proxied);
	Map<String, Object> properties = mapper.readValue(json, new TypeReference<>() {
	});
	assertThat(properties).containsOnlyKeys("firstName", "lastName"); // fails because callbacks property is included
}

Expected behavior

I'd expect that Jackson 3 does not render CGLIB proxy properties.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.0Issue planned for initial 3.0 release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions