Skip to content

Commit

Permalink
Merge pull request quarkusio#36235 from loicmathieu/mongodb-uuid-repr…
Browse files Browse the repository at this point in the history
…esentation

Allow configuring MongoDB client UUID representation
  • Loading branch information
loicmathieu authored Oct 2, 2023
2 parents 288e2d8 + 74f8b11 commit a45cefb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.Optional;
import java.util.OptionalInt;

import org.bson.UuidRepresentation;

import io.quarkus.runtime.annotations.ConfigDocSection;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
Expand Down Expand Up @@ -197,4 +199,10 @@ public class MongoClientConfig {
@ConfigItem(name = "health.database", defaultValue = "admin")
public String healthDatabase;

/**
* Configures the UUID representation to use when encoding instances of {@link java.util.UUID}
* and when decoding BSON binary values with subtype of 3.
*/
@ConfigItem
public Optional<UuidRepresentation> uuidRepresentation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ private MongoClientSettings createMongoConfiguration(MongoClientConfig config) {
settings.readConcern(new ReadConcern(ReadConcernLevel.fromString(config.readConcern.get())));
}

if (config.uuidRepresentation.isPresent()) {
settings.uuidRepresentation(config.uuidRepresentation.get());
}

return settings.build();
}

Expand Down

0 comments on commit a45cefb

Please sign in to comment.