Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3769

Allow multiple POJO codec providers

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.2.0
    • Affects Version/s: None
    • Component/s: POJO
    • None

      Updated Description

      Enhance the PojoCodeProvider such that multiple instance can be added to the same registry and POJO codecs can be looked up between the providers.

      Original Description

      Using multiple codec providers sometimes causes a problem with a failure to find the 'log_entry' discriminator.

      It appears that loading the same set of providers does not cause a failure if loaded in a different order.

      e.g the following code causes a failure

      
      {
          
      
      		CodecRegistry pojoCodecRegistry = CodecRegistries.fromRegistries(
      				CodecRegistries.fromCodecs(new UuidCodec(UuidRepresentation.STANDARD)), 
      				CodecRegistries.fromProviders(_getCodecProvider1(), _getCodecProvider2()),
      //				CodecRegistries.fromProviders(_getCodecProvider()),
      				MongoClientSettings.getDefaultCodecRegistry());
      
      }
      

      However replacing the line to load the codeC provider with :

      
      {
      CodecRegistries.fromProviders(_getCodecProvider(),_getCodecProvider1(),_getCodecProvider2()),
      }
      

      or this

      
      {
      
      CodecRegistries.fromProviders(_getCodecProvider()),
      				MongoClientSettings.getDefaultCodecRegistry());
      
      }
      

      does not cause a failure.

      So it appears that the issue is related to :

      1. Allowing more than 1 provider.
      2. The order in which the providers are loaded.

      Please advise.

      Best regards,

      Sheila

            Assignee:
            brian.deleonardis@mongodb.com Brian DeLeonardis (Inactive)
            Reporter:
            sheila.doyle@mongodb.com Sheila Doyle
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: