Pull requests

#1 Merged
Repository
mhurne
Branch
default
Repository
commercehub_oss
Branch
default

Clarify runtime type of argument to DBCursor#sort to prevent "ambiguous method overloading" GroovyRuntimeException when GMongo is in use

Author
  1. Matt Hurne
Reviewers
Description

If GMongo is in use by an application using grails-mongeez, the following GroovyRuntimeException was thrown when accessing the MongeezController's default action:

Ambiguous method overloading for method com.mongodb.DBCursor#sort. Cannot resolve which method to invoke for [class com.mongodb.BasicDBObject] due to overlapping prototypes between: [interface com.mongodb.DBObject] [interface java.util.Map]

This happens because GMongo adds a sort method to DBCursor that accepts a Map argument, and the BasicDBObject MongeezController was passing to DBCursor#sort implements both the Map and DBObject interfaces. Casting the argument as a DBObject ensures that the "vanilla" DBCursor#sort(DBObject) method is called at runtime, which should work fine whether GMongo is in use or not.

  • Learn about pull requests

Comments (0)