Skip to content

Conversation

@JacksonJang
Copy link
Contributor

@JacksonJang JacksonJang commented Dec 9, 2025

Issue: #1516

I resolved the issue where @JsonManagedReference and @JsonBackReference annotations didn't work when used with property-based creators (@ConstructorProperties).

In addition, I added a test case in TestKotlinGithub129 to verify the fix.
This test is based on testGithub129() in TestGithub149 class from [jackson-module-kotlin].

@JacksonJang
Copy link
Contributor Author

JacksonJang commented Dec 9, 2025

@cowtowncoder
I added conditional logic to ManagedReferenceProperty._setBackReference() and consolidated duplicate code into a single shared method.
When you have a moment, please take a look.

if (value == null) {
  return;
}

@github-actions
Copy link

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 78.8% 📈 +0.100%
Branches branches 72.5% 📈 +0.000%

Coverage data generated from JaCoCo test results

}

// [databind#1516]: Inject back references for managed reference creator properties
for (SettableBeanProperty prop : creator.properties()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should optimize so we don't always iterate over all properties (there should be a flag to indicate if we have any managed ref props, I think)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

I agree that iterating over all properties unconditionally is unnecessary.
I’ll look into adding a lightweight flag to indicate whether any managed reference properties are present, so that we only perform the iteration when it’s actually needed.

Thank you :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your advice.
I’ve implemented the change accordingly and pushed the commit.

import static org.junit.jupiter.api.Assertions.*;

// [databind#1516]
public class TestKotlinGithub129 extends DatabindTestUtil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming: should end with Test, not start

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll make sure to keep this in mind as well.
Thank you again :)

@cowtowncoder
Copy link
Member

Looks promising: I'll try to review soon -- next PR on my list to handle.

@github-actions
Copy link

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 78.8% 📈 +0.100%
Branches branches 72.5% 📈 +0.000%

Coverage data generated from JaCoCo test results

@github-actions
Copy link

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 78.8% 📈 +0.100%
Branches branches 72.5% 📈 +0.000%

Coverage data generated from JaCoCo test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants