Skip to content

2.5

Compare
Choose a tag to compare
@jyemin jyemin released this 13 Sep 14:45
· 7570 commits to master since this release

Java Driver 2.5 (Mar 10, 2011)

This release fixes many bugs reported against previous versions of the driver, and also introduces many improvements.

Changes include:

  • Mongo URI; The Mongo URI describes a set of servers with parameters which control the behavior of the driver in a single connection string; this string will be supported in other drivers.
  • ObjectId generated is now unique for each class loaders; this avoids possible collisions in some Java web servers and environments.
  • Replicaset Improvements: the driver now removes unused servers, detects passive nodes, and supports authentication.
  • Map/Reduce: supports the new Mongo 1.8 features, like advanced post-processing on results (replace, merge, reduce, inline).
  • Host-name resolution is now updated every 5min, making it possible to change the IP of mongod servers without restarting the client application.
  • Several Java properties were added to control the behavior of the driver (slave selection for reads, replica set check interval, etc).
  • Javadocs were thoroughly updated and now cover most of the driver.

Important Notes

  • The Mongo constructors have been simplified to only perform local initialization. As a result, no more network I/O is attempted in the constructor, and it is always possible to obtain a Mongo Instance even if no server is reachable. This follows the philosophy that constructors should be simple and errors should be handled when actual operations are called. In turn, if an application relied on the constructor throwing an exception, it should be modified.

Backward Compatibility

  • Map/Reduce: the simple M/R method was removed since it is now required to either specify an output collection, or select "INLINE" type.
  • GridFS: previously the driver would incorrectly store the "metadata" user-supplied object at the root of the gridfs file object. This has been fixed to store it under the "metadata" field, as described in the gridfs specs. This change is backward breaking for applications that stored metadata with previous drivers.
  • The ObjectId class has been refactored to fix several flaws notably for its compareTo() operator. As a result, the underlying BSON encoder/decoder was modified to write/read the ObjectID as big endian, as described by the BSON spec (as opposed to other data written little endian). This enabled to clean up the ObjectID class and improve its behavior. If using auto-generated ObjectID or ones created from String, the change in driver will not be noticeable. But if retrieving a record written with a previous driver and inspecting its machine ID or increment value, they will appear different with the new driver.
  • The exception hierarchies have changed and you should check that you are catching MongoException and not MongoInternalException as that is not thrown in the same places anymore.
  • findAndModify now returns the error from the server if no matching documents can be found for the update.

Tickets

Full ticket information can be seen at http://jira.mongodb.org

  • JAVA-263 NullPointerException due to race condition during concurrent access to DBTCPTransport
  • JAVA-85 CompareTo of ObjectId java driver returns different value than MongoDB implementation
  • JAVA-255 DBCollection.save(obj) does not use the default write concern
  • JAVA-151 Dot allowed in key names
  • JAVA-231 Failed to retrieve any result when using SlaveOK with all slaves are down
  • JAVA-248 For GridFS, driver should ensure indexes at startup on both files and chunks collection, when collection is small
  • JAVA-270 If authentication is on for a replica set, then most likely all writes will always fail once primary server dies
  • JAVA-224 Java driver doesn't automatically discover replica set passive nodes
  • JAVA-251 MapReduceOutput should support getting results inline, or from a collection in another db
  • JAVA-240 Mongo constructor should not attempt network connections and potentially throw exception that prevents app from starting
  • JAVA-227 NPE when replica set is down
  • JAVA-266 Need to update the IP resolved for hosts frequently enough to pick up dns changes
  • JAVA-269 NullPointerException when authentication used with replica sets not logged correctly
  • JAVA-241 driver has a bunch of hardcoded timing settings that many customers want to tweak
  • JAVA-276 findAndModify does not throw MongoException on error, fails silently
  • JAVA-256 fix all javadoc
  • JAVA-239 make sure src/main/org/bson has no mongodb deps
  • JAVA-273 many db commands (stats, list db, group, etc) should succeed if slaveOk=true and at least one server is up
  • JAVA-282 on ioexception, call to port.close() after putting back port in the pool, may break other thread that is using port
  • JAVA-281 when dropping a database or a collection, they remain in the driver cache, which can lead to problems
  • JAVA-257 when getLastError() is called on a WriteResult, behavior has several flaws
  • JAVA-275 with default write concern (no getLastError), if master changes in repl set, small edge case where writes will fail undetected
  • JAVA-258 Need oid in WriteResult
  • JAVA-174 prevent stack overflow in case of erroneous cyclic reference
  • JAVA-264 Deprecate DBCollection.getCount methods
  • JAVA-261 GridFSInputFile.getMetaData() returns wrong value
  • JAVA-279 ObjectId could generate duplicate ids if used in different classloader
  • JAVA-237 Should only have 1 DBCleanerThread per Mongo instance
  • JAVA-238 add optional parameter dropTarget to DBCollection.rename()
  • JAVA-247 authenticate method declares throw MongoException but doesn't actually throw it
  • JAVA-252 clean up the list of servers in replica based on list returned from isMaster
  • JAVA-267 update DBCusor .next() .hasNext() javadoc to say it can throw an exception WAS: MongoInternalException from DBCursor.hasNext() is inappropriate
  • JAVA-196 ReplicaSetStatus does not remove dead nodes automatically
  • JAVA-244 MongoURI for Java Driver should support all speced options (e.g. w, fsync, etc)
  • JAVA-289 driver does not allow doc sizes matching the server limit, for both insert and find