@jyemin jyemin released this Apr 3, 2014 · 3861 commits to master since this release

Java Driver 2.12.0 (April 3, 2014)

The 2.12.0 MongoDB Java Driver includes bug fixes, new features, and improvements. It is binary compatible with 2.11.4 except for any incompatibilities explicitly noted below, and supports all MongoDB server versions since 2.0.

This is a recommended upgrade for all users.


Below and on maven central



Compatibility changes

  • The domain for JMX MBeans registered by the driver has changed from "com.mongodb" to "org.mongodb.driver".
  • The driver's connection pool no longer supports connection affinity to threads. Previous versions of the driver tried to provide a given thread the same connection to a MongoDB server as was provided to it the last time it requested one. This was done on a best effort, so that if the max pool size was less than the number of threads using a MongoClient instance, connections would be shared amongst those threads and there would be no guarantee of any connection affinity. But if the max pool size was greater or equal to the number of threads, then effectively each thread would have its own dedicated connection.
    In this release the connection affinity has been removed as part of a re-write of the connection pool. While this will have no effects on most driver users, it will have ramifications for some:
    • For applications that access mongos servers through a load balancer, ensure that the load balancer is configured according to the guidelines for client affinity. If the load balancer is instead configured to allocate connections to mongos servers with the least load or in a round-robin fashion, applications are more likely to experience failures when iterating query results.
    • For applications using unacknowledged writes and subsequently calling WriteResult.getLastError (directly or indirectly, through any of the now-deprecated methods in WriteResult). Even in previous versions of the driver, this call could fail if the connection was "stolen" by another thread, but the removal of connection affinity makes failure of this method more likely. To avoid any issues, replace calls to any of the deprecated methods in the WriteResult class with an acknowledged write, which will throw an exception if the write fails. Note that if you are constructing MongoClient
      instances (rather than deprecated Mongo instances) the driver will default to using acknowledged writes.
  • The methods getStatistics and memSize in DBPortPool have been removed.


This release supports all the new features introduced in MongoDB 2.6, including:

Additionally, this release includes these new driver features:

  • Improved replica set monitoring, including more predictable fail-fast behavior, faster discovery, faster detection of IP address changes, and configuration via MongoClientOptions.
  • Improved connection pooling, including support for maxConnectionIdleTime, maxConnectionLifeTime, and minPoolSize properties
  • Support for IPv6 literal host names

Finally, this release is most likely the last feature release before the 3.0 release, which will contain backwards-breaking changes. To prepare for 3.0, the 2.12 release deprecates many classes and methods, most of which will be removed in 3.0. So to prepare for an eventual upgrade, please compile against 2.12 with deprecation warnings enabled. Code which compiles without any deprecation warnings against 2.12 should run without modification against the eventual 3.0 release. You can find a complete list of deprecated classes and methods that will be removed in the 3.0 release here.

Additionally, the 2.12.0 release will be the last non-bug fix release that will support Java 5.

Issues fixed since the last release candidate

You can find a list of bug fixes since the last release candidate here.

Bug fixes

You can find a full list of bug fixes here.


You can find a full list of improvements here.

New Features

You can find a full list of new features here.