Skip to content

Commit 2a291ac

Browse files
authored
[Java] v5.0 Tech Review (#507)
* tech review
1 parent 2b31b13 commit 2a291ac

File tree

3 files changed

+49
-24
lines changed

3 files changed

+49
-24
lines changed

source/includes/fundamentals/code-snippets/mcs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ private static void createSocketSettings() {
9191
MongoClient mongoClient = MongoClients.create(
9292
MongoClientSettings.builder().applyConnectionString(new ConnectionString("<your connection string>"))
9393
.applyToSocketSettings(builder ->
94-
builder.connectTimeout(10L, SECONDS)
95-
.readTimeout(15L, SECONDS))
94+
builder.connectTimeout(10, SECONDS)
95+
.readTimeout(15, SECONDS))
9696
.build());
9797
//end SocketSettings
9898
mongoClient.listDatabaseNames().forEach(n -> System.out.println(n));

source/upgrade.txt

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ Version 5.0 Breaking Changes
7777
``long`` instead of type ``int``. Because this change breaks both binary and source
7878
compatibility, update any source code that uses these methods and rebuild your binary.
7979

80-
- This driver version removes the following record annotations:
80+
- The following record annotations from the
81+
``org.bson.codecs.record.annotations`` package are replaced with
82+
annotations of the same name from the ``org.bson.codecs.pojo.annotations`` package:
8183

8284
- ``BsonId``
8385
- ``BsonProperty``
@@ -90,32 +92,66 @@ Version 5.0 Breaking Changes
9092
- ``readTimeout()``
9193

9294
In earlier versions, this parameter is of type ``int`` for both methods. To view an example
93-
that shows how to instantiate a ``SocketSettings`` instance by using
94-
these methods, see the :ref:`SocketSettings Example
95+
that shows how to call ``SocketSettings`` methods, see the :ref:`SocketSettings Example
9596
<java-socketsettings-example>` in the Specify MongoClient Settings
9697
guide.
9798

98-
- This driver version removes the ``Filters.eqFull()`` method, which allowed you
99+
This change breaks binary compatibility (requires recompiling) but does not
100+
require code changes.
101+
102+
- This driver version removes the ``Filters.eqFull()`` method, released
103+
exclusively in ``Beta``, which allowed you
99104
to construct an equality filter when performing a vector search.
100105
You can use the ``Filters.eq()`` method when instantiating a
101106
``VectorSearchOptions`` type, as shown in the following code:
102107

103108
.. code-block:: java
104-
105-
VectorSearchOptions opts = vectorSearchOptions().filter(eq("x", 8));
109+
110+
VectorSearchOptions opts = vectorSearchOptions().filter(eq("x", 8));
106111

107112
.. _java-breaking-changes-v5.0-observables:
108113

109114
- This driver version removes the
110115
``org.mongodb.scala.ObservableImplicits.ToSingleObservableVoid`` implicit
111116
class. This means the ``org.reactivestreams.Publisher[Void]`` type no longer
112-
converts automatically to ``org.mongodb.scala.SingleObservable[Void]``. The also
113-
API exposes ``org.mongodb.scala.Observable[Unit]`` instead of
117+
converts automatically to ``org.mongodb.scala.SingleObservable[Void]``. The
118+
API also exposes ``org.mongodb.scala.Observable[Unit]`` instead of
114119
``org.mongodb.scala.Observable[Void]``.
115120

116121
.. After the 5.0 Scala API docs are released, this line will be uncommented.
117122
For more information, see the `Observable trait documentation <https://mongodb.github.io/mongo-java-driver/5.0/apidocs/mongo-scala-driver/org/mongodb/scala/Observable.html>`__.
118123

124+
- This driver changes how ``ClusterSettings`` computes
125+
``ClusterConnectionMode``, making it more consistent by using the specified
126+
replica set name, regardless of how it is configured. Previously, replica set
127+
name was only considered if it was set by the connection string.
128+
129+
For example, the following two code samples both return the value
130+
``ClusterConnectionMode.MULTIPLE``, while previously the second one returned
131+
``ClusterConnectionMode.SINGLE``.
132+
133+
.. code-block:: java
134+
135+
ClusterSettings.builder()
136+
.applyConnectionString(new ConnectionString("mongodb://127.0.0.1:27017/?replicaSet=replset"))
137+
.build()
138+
.getMode()
139+
140+
.. code-block:: java
141+
142+
ClusterSettings.builder()
143+
.hosts(Collections.singletonList(
144+
new ServerAddress("127.0.0.1", 27017)
145+
))
146+
.requiredReplicaSetName("replset")
147+
.build()
148+
.getMode()
149+
150+
- This driver changes how ``BsonDecimal128`` values respond to method calls, by
151+
responding in the same way as ``Decimal128`` values. In particular,
152+
``BsonDecimal128.isNumber()`` now returns ``true``, and
153+
``BsonDecimal128.asNumber()`` returns the equivalent ``BsonNumber``.
154+
119155
.. _java-breaking-changes-v4.8:
120156

121157
Version 4.8 Breaking Changes

source/whats-new.txt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,12 @@ What's New in 5.0
4242

4343
.. warning:: Breaking Changes in v5.0
4444

45-
This driver version introduces breaking changes. For a list of these changes, see
46-
the :ref:`Version 5.0 Breaking Changes section <java-breaking-changes-v5.0>` in the
47-
Upgrade guide.
45+
This driver version introduces breaking changes. For a list of these changes, see
46+
the :ref:`Version 5.0 Breaking Changes section <java-breaking-changes-v5.0>` in the
47+
Upgrade guide.
4848

4949
The 5.0 driver release introduces the following features:
5050

51-
- Consistent computation of the ``ClusterConnectionMode`` type after
52-
instantiating a ``ClusterSettings``. The connection mode defaults to
53-
``SINGLE`` if you specify one host and do not specify a replica set
54-
name, or it defaults to ``MULTIPLE`` if you specify more than one
55-
host.
56-
57-
- ``BsonDecimal128`` values respond to method calls in the same way as Java
58-
``Decimal128`` values. In particular, the error responses for the
59-
``isNumber()`` and ``asNumber()`` methods match the Java responses for
60-
equivalent ``Decimal128`` values.
61-
6251
- The ``getElapsedTime()`` method on ``com.mongodb.event.ConnectionReadyEvent``
6352
includes the time taken to deliver the ``ConnectionCreatedEvent``. That is,
6453
the time returned includes the duration of the

0 commit comments

Comments
 (0)