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

UUIDCodec default UuidRepresentation should be STANDARD

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.0
    • Component/s: BSON
    • Labels:
      None
    • Environment:
      Windows 10

      According to documentation, since version 3.0 the default UUID representation is the `STANDARD` one.

      Except for `UuidCodec` default constructor uses `JAVA_LEGACY` representation, making applications still store `LUUID` by default.

      It is interesting to note that `ValueCodecProvider`, which is the default codec provider uses the default constructor for `UuidCodec`, making sure that `JAVA_LEGACY`/`LUUID` type is used by default.

      I think the default constructor can be changed to `STANDARD` representation, as stated in documentation, and even in code:

      // changed the default subtype to STANDARD since 3.0
      if (encoderUuidRepresentation == UuidRepresentation.STANDARD) {
       writer.writeBinaryData(new BsonBinary(BsonBinarySubType.UUID_STANDARD, binaryData));
      } else {
       writer.writeBinaryData(new BsonBinary(BsonBinarySubType.UUID_LEGACY, binaryData));
      }
      

      Environment variables could be used to restore legacy behaviour withour resorting to mess with code.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            gmcouto@gmail.com Gabriel Couto
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: