PojoBuilderHelper#configureClassModelBuilder is causing different output

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: 4.3.2, 4.9.0
    • Component/s: POJO
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      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";
          public static final String BATCH_ID = "batchId";

          @BsonProperty(TEST_ID)
          private String testId;

          @BsonProperty(BATCH_ID)
          private String batchId;

          public Test(String testId, String batchId) {
              this.testId = testId;
              this.batchId = batchId;
          }

          public String getTestId() {
              return testId;
          }

          public void setTestId(String testId) {
              this.testId = testId;
          }

          public boolean isTestId() {
              return !testId.isEmpty();
          }

          public String getBatchId() {
              return batchId;
          }

          public void setBatchId(String batchId) {
              this.batchId = batchId;
          }

          public boolean isBatchId() {
              return !batchId.isEmpty();
          }

          public static void main(String[] args) {
                  PropertyModelBuilder<?> property1 = ClassModel.builder(Test.class).getProperty(BATCH_ID);
                  PropertyModelBuilder<?> property2 = ClassModel.builder(Test.class).getProperty(TEST_ID);
                  System.out.println(((PropertyAccessorImpl) property1.getPropertyAccessor()).getPropertyMetadata().getError());
                  System.out.println(((PropertyAccessorImpl) property2.getPropertyAccessor()).getPropertyMetadata().getError());
          }
      }

      Results:{{{}
      Property 'batchId' in Test, has differing data types: TypeData{type=String} and TypeData{type=Boolean}.
      null{}}}

       

      {{null
      Property 'testId' in Test, has differing data types: TypeData{type=String} and TypeData{type=Boolean}.}}

       

      {{Property 'batchId' in Test, has differing data types: TypeData{type=String} and TypeData{type=Boolean}.
      Property 'testId' in Test, has differing data types: TypeData{type=String} and TypeData{type=Boolean}.}}

       

      {{null
      null}}

            Assignee:
            Unassigned
            Reporter:
            Sergey Nikitin
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: