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