Skip to content

DOCSP-26368: FAQ entry for state should be open exception #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion source/faq.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,35 @@ When ``MongoClient.close()`` is called by any thread, the driver
closes all idle sockets and closes all sockets that are in
use as they are returned to the pool.

How do I prevent the "IllegalStateException: state should be: open" error?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You may encounter this exception if you call an operation on a ``MongoClient``
instance that closed its connections to MongoDB. Once the ``close()`` method
is called on the ``MongoClient``, any further operation calls on that instance
throw this exception.

To avoid this exception, do not call operations on ``MongoClient`` instance
after any code that calls ``close()`` on it.

.. tip::

The code that closes the ``MongoClient`` instance may be difficult to
locate in certain cases. To locate potential sources of this exception,
search for the following cases:

- Calls to ``close()`` on a ``MongoClient`` instance
- Operation calls on a ``MongoClient`` instance that are outside the scope
of the try-with-resources statement in which the ``MongoClient`` is
declared

If your application uses a framework to manage the ``MongoClient``
such as Spring Boot, check the documentation of the framework to locate the
best practices for managing the connection behavior.

To learn more about accessing MongoDB from Spring Boot, see
`Spring Boot and MongoDB <https://www.mongodb.com/compatibility/spring-boot>`__.

POJOs
-----

Expand Down Expand Up @@ -224,7 +253,7 @@ For example, the following methods throws an exception during encoding:
public String setField(String x);

How do I fix: "org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class X."?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This exception means you need to register a codec for the class since
there is none at the moment.
Expand Down