[JAVA-4913] PojoBuilderHelper#configureClassModelBuilder is causing different output Created: 21/Mar/23 Updated: 19/Apr/23 |
|
| Status: | Backlog |
| Project: | Java Driver |
| Component/s: | POJO |
| Affects Version/s: | 4.3.2, 4.9.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Sergey Nikitin | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | Investigate our POJO implementation |
| Quarter: | FY23Q4, FY24Q2 |
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
| Description |
|
Running this test code multiple times returns different results: package org.bson.codecs.pojo; import org.bson.codecs.pojo.annotations.BsonProperty; public class Test { public static final String TEST_ID = "testId"; @BsonProperty(TEST_ID) @BsonProperty(BATCH_ID) public Test(String testId, String batchId) { public String getTestId() { public void setTestId(String testId) { public boolean isTestId() { public String getBatchId() { public void setBatchId(String batchId) { public boolean isBatchId() { public static void main(String[] args) { Results:{{{}
{{null
{{Property 'batchId' in Test, has differing data types: TypeData{type=String} and TypeData{type=Boolean}.
{{null |
| Comments |
| Comment by Jeffrey Yemin [ 25/Mar/23 ] | ||
|
Because the POJO codec follows the Java Beans standard of treating "is"-prefixed methods as boolean getter properties, so I suspect that's what's confusing it. | ||
| Comment by Sergey Nikitin [ 25/Mar/23 ] | ||
|
It may not be reproducible in a loop, build is required each time. In this case an order of getters in the | ||
| Comment by Jeffrey Yemin [ 25/Mar/23 ] | ||
|
I can't reproduce this. I ran it 1000 times in a loop and it prints
every time. So not sure what's going on. But if you can't figure out what's different in your environment, it seems like a workaround would be to change isTestId/isBatchId to hasTestId/hasBatchId, as the "is" prefix does have special meaning in the Java Beans specification. |