@@ -153,6 +153,35 @@ When ``MongoClient.close()`` is called by any thread, the driver
153
153
closes all idle sockets and closes all sockets that are in
154
154
use as they are returned to the pool.
155
155
156
+ How do I prevent the "IllegalStateException: state should be: open" error?
157
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158
+
159
+ You may encounter this exception if you call an operation on a ``MongoClient``
160
+ instance that closed its connections to MongoDB. Once the ``close()`` method
161
+ is called on the ``MongoClient``, any further operation calls on that instance
162
+ throw this exception.
163
+
164
+ To avoid this exception, do not call operations on ``MongoClient`` instance
165
+ after any code that calls ``close()`` on it.
166
+
167
+ .. tip::
168
+
169
+ The code that closes the ``MongoClient`` instance may be difficult to
170
+ locate in certain cases. To locate potential sources of this exception,
171
+ search for the following cases:
172
+
173
+ - Calls to ``close()`` on a ``MongoClient`` instance
174
+ - Operation calls on a ``MongoClient`` instance that are outside the scope
175
+ of the try-with-resources statement in which the ``MongoClient`` is
176
+ declared
177
+
178
+ If your application uses a framework to manage the ``MongoClient``
179
+ such as Spring Boot, check the documentation of the framework to locate the
180
+ best practices for managing the connection behavior.
181
+
182
+ To learn more about accessing MongoDB from Spring Boot, see
183
+ `Spring Boot and MongoDB <https://www.mongodb.com/compatibility/spring-boot>`__.
184
+
156
185
POJOs
157
186
-----
158
187
@@ -229,7 +258,7 @@ For example, the following methods throws an exception during encoding:
229
258
public String setField(String x);
230
259
231
260
How do I fix: "org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class X."?
232
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233
262
234
263
This exception means you need to register a codec for the class since
235
264
there is none at the moment.
0 commit comments