Skip to content

Commit f91b10e

Browse files
rozzavbabaninstrogiyotecAlmas Abdrazaknhachicha
authored
Merge main into ByteBuf (#1907)
* Revert NettyByteBuf.asReadOnly change (#1871) Originally introduced in 057649f This change had the unintended side effect of leaking netty ByteBufs when logging. JAVA-5982 * Update Netty dependency to the latest version. (#1867) JAVA-5818 * Adjust timeout handling in client-side operations to account for RTT variations (#1793) JAVA-5375 --------- Co-authored-by: Ross Lawley <ross@mongodb.com> * Update Snappy version for the latest security fixes. (#1868) JAVA-6069 * Bson javadoc improvements (#1883) Fixed no comment warning in BinaryVector Improved BsonBinary asUuid documentation Improved BsonBinarySubType isUuid documentation JAVA-6086 * Make NettyByteBuf share parent reference count. (#1891) JAVA-6107 * JAVA-5907 (#1893) * JAVA-5907 * JAVA-5907 use execute within executor service If we don't use the return value from executor then we should use `execute` instead of `submit` * format * revert error log for netty leak --------- Co-authored-by: Almas Abdrazak <abdrazak.almas@mongodb.com> * Fix RawBsonDocument encoding performance regression (#1888) Add instanceof check in BsonDocumentCodec to route RawBsonDocument to RawBsonDocumentCodec, restoring efficient byte-copy encoding. Previous BsonType-based lookup led to sub-optimal performance as it could not distinguish RawBsonDocument from BsonDocument. JAVA-6101 * Update specifications to latest (#1884) JAVA-6092 * Evergreen atlas search fix (#1894) Update evergreen atlas-deployed-task-group configuration Assume test secrets and follow the driver-evergreen-tools atlas recommended usage: https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/atlas#usage JAVA-6103 * [JAVA-6028] Add Micrometer/OpenTelemetry tracing support to the reactive-streams (#1898) * Add Micrometer/OpenTelemetry tracing support to the reactive-streams driver https://jira.mongodb.org/browse/JAVA-6028 Port the tracing infrastructure from the sync driver to driver-reactive-streams, reusing the existing driver-core, TracingManager, Span, and TraceContext classes. * Move error handling and span lifecycle (span.error(), span.end()) from Reactor's doOnError/doFinally operators into the async callback, before emitting the result to the subscriber. * Making sure span is properly closed when an exception occurs * Clone command event document before storing to prevent use-after-free. (#1901) * Version: bump 5.7.0-beta1 * Version: bump 5.7.0-SNAPSHOT * Remove unneeded variable --------- Co-authored-by: Viacheslav Babanin <slav.babanin@mongodb.com> Co-authored-by: Almas Abdrazak <almas337519@gmail.com> Co-authored-by: Almas Abdrazak <abdrazak.almas@mongodb.com> Co-authored-by: Nabil Hachicha <nabil.hachicha@mongodb.com> Co-authored-by: Nabil Hachicha <1793238+nhachicha@users.noreply.github.com>
1 parent 945bdd7 commit f91b10e

50 files changed

Lines changed: 876 additions & 277 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.evergreen/.evg.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,16 +1939,18 @@ task_groups:
19391939
setup_group:
19401940
- func: "fetch-source"
19411941
- func: "prepare-resources"
1942+
- func: "assume-aws-test-secrets-role"
19421943
- command: subprocess.exec
19431944
type: "setup"
19441945
params:
19451946
working_dir: "src"
19461947
binary: bash
1947-
add_expansions_to_env: true
1948+
include_expansions_in_env: [ "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN" ]
19481949
env:
1950+
CLUSTER_PREFIX: "dbx-java"
19491951
MONGODB_VERSION: "8.0"
19501952
args:
1951-
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
1953+
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup.sh
19521954
- command: expansions.update
19531955
params:
19541956
file: src/atlas-expansion.yml
@@ -1960,7 +1962,7 @@ task_groups:
19601962
binary: bash
19611963
add_expansions_to_env: true
19621964
args:
1963-
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
1965+
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown.sh
19641966
tasks:
19651967
- "atlas-search-index-management-task"
19661968
- "aws-lambda-deployed-task"

bson/src/main/org/bson/BinaryVector.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
* @since 5.3
3333
*/
3434
public abstract class BinaryVector {
35+
/**
36+
* The BinaryVector logger
37+
*/
3538
protected static final Logger LOGGER = Loggers.getLogger("BinaryVector");
3639
private final DataType dataType;
3740

bson/src/main/org/bson/BsonBinary.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,14 @@ public BsonBinary(final UUID uuid, final UuidRepresentation uuidRepresentation)
127127
}
128128

129129
/**
130-
* Returns the binary as a UUID. The binary type must be 4.
130+
* Returns the binary as a UUID.
131+
*
132+
* <p><strong>Note:</strong>The BsonBinary subtype must be {@link BsonBinarySubType#UUID_STANDARD}.</p>
131133
*
132134
* @return the uuid
135+
* @throws BsonInvalidOperationException if BsonBinary subtype is not {@link BsonBinarySubType#UUID_STANDARD}
136+
* @see #asUuid(UuidRepresentation)
137+
* @see BsonBinarySubType
133138
* @since 3.9
134139
*/
135140
public UUID asUuid() {
@@ -162,8 +167,15 @@ public BinaryVector asVector() {
162167
/**
163168
* Returns the binary as a UUID.
164169
*
165-
* @param uuidRepresentation the UUID representation
170+
* <p><strong>Note:</strong>The BsonBinary subtype must be either {@link BsonBinarySubType#UUID_STANDARD} or
171+
* {@link BsonBinarySubType#UUID_LEGACY}.</p>
172+
*
173+
* @param uuidRepresentation the UUID representation, must be {@link UuidRepresentation#STANDARD} or
174+
* {@link UuidRepresentation#JAVA_LEGACY}
166175
* @return the uuid
176+
* @throws BsonInvalidOperationException if the BsonBinary subtype is incompatible with the given {@code uuidRepresentation}, or if
177+
* the {@code uuidRepresentation} is not {@link UuidRepresentation#STANDARD} or
178+
* {@link UuidRepresentation#JAVA_LEGACY}.
167179
* @since 3.9
168180
*/
169181
public UUID asUuid(final UuidRepresentation uuidRepresentation) {

bson/src/main/org/bson/BsonBinarySubType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public enum BsonBinarySubType {
9393
* Returns true if the given value is a UUID subtype.
9494
*
9595
* @param value the subtype value as a byte.
96-
* @return true if value is a UUID subtype.
96+
* @return true if value has a {@link #UUID_STANDARD} or {@link #UUID_LEGACY} subtype.
9797
* @since 3.4
9898
*/
9999
public static boolean isUuid(final byte value) {

bson/src/main/org/bson/codecs/BsonDocumentCodec.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.bson.BsonType;
2323
import org.bson.BsonValue;
2424
import org.bson.BsonWriter;
25+
import org.bson.RawBsonDocument;
2526
import org.bson.codecs.configuration.CodecRegistry;
2627
import org.bson.types.ObjectId;
2728

@@ -40,6 +41,7 @@ public class BsonDocumentCodec implements CollectibleCodec<BsonDocument> {
4041
private static final String ID_FIELD_NAME = "_id";
4142
private static final CodecRegistry DEFAULT_REGISTRY = fromProviders(new BsonValueCodecProvider());
4243
private static final BsonTypeCodecMap DEFAULT_BSON_TYPE_CODEC_MAP = new BsonTypeCodecMap(getBsonTypeClassMap(), DEFAULT_REGISTRY);
44+
private static final RawBsonDocumentCodec RAW_BSON_DOCUMENT_CODEC = new RawBsonDocumentCodec();
4345

4446
private final CodecRegistry codecRegistry;
4547
private final BsonTypeCodecMap bsonTypeCodecMap;
@@ -101,6 +103,10 @@ protected BsonValue readValue(final BsonReader reader, final DecoderContext deco
101103

102104
@Override
103105
public void encode(final BsonWriter writer, final BsonDocument value, final EncoderContext encoderContext) {
106+
if (value instanceof RawBsonDocument) {
107+
RAW_BSON_DOCUMENT_CODEC.encode(writer, (RawBsonDocument) value, encoderContext);
108+
return;
109+
}
104110
writer.writeStartDocument();
105111

106112
beforeFields(writer, encoderContext, value);

bson/src/test/unit/util/ThreadTestHelpers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static void executeAll(final Runnable... runnables) {
4141
CountDownLatch latch = new CountDownLatch(runnables.length);
4242
List<Throwable> failures = Collections.synchronizedList(new ArrayList<>());
4343
for (final Runnable runnable : runnables) {
44-
service.submit(() -> {
44+
service.execute(() -> {
4545
try {
4646
runnable.run();
4747
} catch (Throwable e) {

driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/AbstractBsonDocumentBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public int getBytesPerRun() {
6161
return fileLength * NUM_INTERNAL_ITERATIONS;
6262
}
6363

64-
private byte[] getDocumentAsBuffer(final T document) throws IOException {
64+
protected byte[] getDocumentAsBuffer(final T document) throws IOException {
6565
BasicOutputBuffer buffer = new BasicOutputBuffer();
6666
codec.encode(new BsonBinaryWriter(buffer), document, EncoderContext.builder().build());
6767

driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/BenchmarkSuite.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ private static void runBenchmarks()
7171
runBenchmark(new BsonDecodingBenchmark<>("Deep", "extended_bson/deep_bson.json", DOCUMENT_CODEC));
7272
runBenchmark(new BsonDecodingBenchmark<>("Full", "extended_bson/full_bson.json", DOCUMENT_CODEC));
7373

74+
runBenchmark(new RawBsonNestedEncodingBenchmark("Full RawBsonDocument in BsonDocument BSON Encoding", "extended_bson/full_bson.json"));
75+
runBenchmark(new RawBsonArrayEncodingBenchmark("Full RawBsonDocument Array in BsonDocument BSON Encoding", "extended_bson/full_bson.json", 10));
76+
7477
runBenchmark(new RunCommandBenchmark<>(DOCUMENT_CODEC));
7578
runBenchmark(new FindOneBenchmark<Document>("single_and_multi_document/tweet.json", BenchmarkSuite.DOCUMENT_CLASS));
7679

driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/GridFSMultiFileDownloadBenchmark.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void run() throws Exception {
9797
CountDownLatch latch = new CountDownLatch(50);
9898

9999
for (int i = 0; i < 50; i++) {
100-
gridFSService.submit(exportFile(latch, i));
100+
gridFSService.execute(exportFile(latch, i));
101101
}
102102

103103
latch.await(1, TimeUnit.MINUTES);
@@ -107,7 +107,7 @@ private Runnable exportFile(final CountDownLatch latch, final int fileId) {
107107
return () -> {
108108
UnsafeByteArrayOutputStream outputStream = new UnsafeByteArrayOutputStream(5242880);
109109
bucket.downloadToStream(GridFSMultiFileDownloadBenchmark.this.getFileName(fileId), outputStream);
110-
fileService.submit(() -> {
110+
fileService.execute(() -> {
111111
try {
112112
FileOutputStream fos = new FileOutputStream(new File(tempDirectory, String.format("%02d", fileId) + ".txt"));
113113
fos.write(outputStream.getByteArray());
@@ -124,7 +124,7 @@ private void importFiles() throws Exception {
124124
CountDownLatch latch = new CountDownLatch(50);
125125

126126
for (int i = 0; i < 50; i++) {
127-
fileService.submit(importFile(latch, i));
127+
fileService.execute(importFile(latch, i));
128128
}
129129

130130
latch.await(1, TimeUnit.MINUTES);

driver-benchmarks/src/main/com/mongodb/benchmark/benchmarks/GridFSMultiFileUploadBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void run() throws Exception {
7575
CountDownLatch latch = new CountDownLatch(50);
7676

7777
for (int i = 0; i < 50; i++) {
78-
fileService.submit(importFile(latch, i));
78+
fileService.execute(importFile(latch, i));
7979
}
8080

8181
latch.await(1, TimeUnit.MINUTES);

0 commit comments

Comments
 (0)