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

CodecConfigurationException when creating an instance of DocumentCodec

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.0
    • Affects Version/s: 3.11.2, 3.12.5, 4.0.4
    • Component/s: Codecs
    • None

      While looking at flame graphs for my application under the load, I found that my application was spending significant time on filling stack traces though there were no errors in logs.

      I found that the reason is in that my application is heavily using Document#toJson method. Under the hood, the method creates a new instance of DocumentCodec. And deep inside there is also a call to create a new instance of BsonTypeCodecMap which has the following code:

                      try {
                          codecs[cur.getValue()] = codecRegistry.get(clazz);
                      } catch (CodecConfigurationException e) {
                          // delay reporting this until the codec is actually requested
                      }
      

      The thing is in that it can't find a codec for BsonType "ARRAY" and clazz "interface java.util.List", then throws an exception, ignores it, and affects application performance.

      I think that the simplest way to reproduce the issue is to set a breakpoint on the line with the catch condition and to create a new instance of DocumentCodec.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            eugeny.ganchurin@gmail.com Eugeny Ganchurin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: