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

Add support for Map<String, List<Object>> and Map<String, List<AnotherPojo>> in PojoCodec

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.8.0
    • Component/s: POJO
    • Labels:
      None
    • Environment:
      mac os

      We're getting an Exception in the following function.

      We have a Pojo that has two members 

      private Map<String, List<MyPojo>> ref;
      private Map<String, List<Object>> myInnerParam;
      Debugging shows that the following function throws an Exception (CodecConfigurationException)
      
      private void specialize() {
       if (specialized) {
       codecCache.put(classModel, this);
       for (PropertyModel<?> propertyModel : classModel.getPropertyModels()) {
       try {
       addToCache(propertyModel);
       } catch (Exception e) {
       throw new CodecConfigurationException(format("Could not create a PojoCodec for '%s'."
       + " Property '%s' errored with: %s", classModel.getName(), propertyModel.getName(), e.getMessage()), e);
       }
       }
       }
      }

       

      The Value of the PropertyModel in the above function.

      propertyModel = {PropertyModel@10278} "PropertyModel{propertyName='myInnerParam', readName='myInnerParam', writeName='myInnerParam', typeData=TypeData{type=Map, typeParameters=[String, List<Object>]}}"

      name = "myInnerParam"

      readName = "myInnerParam"

      writeName = "myInnerParam"

      typeData = {TypeData@10350} "TypeData{type=Map, typeParameters=[String, List<Object>]}"

      codec = null

      propertySerialization = {PropertyModelSerializationImpl@10351}

      useDiscriminator = null

      propertyAccessor = {PropertyAccessorImpl@10352}

      cachedCodec = null

       

       

      Exception

      e = {CodecConfigurationException@11668} "org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Object."
       detailMessage = "Can't find a codec for class java.lang.Object."
       value = {char[46]@11905} 
       hash = 0
       cause = {CodecConfigurationException@11668} "org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Object."
       detailMessage = "Can't find a codec for class java.lang.Object."
       cause = {CodecConfigurationException@11668} "org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.lang.Object."
       stackTrace = {StackTraceElement[0]@11901} 
       suppressedExceptions = {Collections$UnmodifiableRandomAccessList@11902} size = 0
       stackTrace = {StackTraceElement[0]@11901} 
       suppressedExceptions = {Collections$UnmodifiableRandomAccessList@11902} size = 0

       This is a stopper for us - and we are not able to move forward to using the latest Driver - also can you please suggest a work around - if this is something that will take a long time.

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            durgadeep Durga Deep
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: