Skip to content
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

GPMONGODB-263: Service methods calling local method named 'find' fail after upgrade to mongodb-1.1.0.GA #279

Closed
graemerocher opened this issue Jan 23, 2013 · 0 comments

Comments

@graemerocher
Copy link
Member

Original Reporter: mjpowersjr
Environment: jdk 1.6.x, Ubuntu 12.10, Grails 2.1.1
Version: 1.1.0.GA
Migrated From: http:https://jira.grails.org/browse/GPMONGODB-263

After upgrading from {{mongodb-1.0.0.GA}} to {{mongodb-1.1.0.GA}}, a number of existing services broke. I discovered the bug was triggered by services proving a method named {{find()}}. If a service method makes a call to the same service's {{find()}} method, the following exception is produced:

{code}
| groovy.lang.MissingMethodException: No signature of method: mongodb.service.find.bug.ProductService.whereLazy() is applicable for argument types: () values: []
at mongodb.service.find.bug.ProductService.willCallFindMethod(BookServiceSpec.groovy:40)
at mongodb.service.find.bug.BookServiceSpec.Test that services can call local find method(BookServiceSpec.groovy:25)
{code}

I can confirm that downgrading to {{mongodb 1.0.0.GA}} works around the issue.

I have attached a sample Grails project which demonstrates this. The Grails demo project contains a single Spock unit test to reproduce the bug. For simplicity, I have appended a copy of the unit test below. This unit test will pass with {{mongodb-1.0.0.GA}}, but fail with {{mongo-1.1.0.GA}}. The missing method exception will be thrown when calling {{bookService.willCallFindMethod()}}

{code}
class BookServiceSpec extends spock.lang.Specification {

void "Test that services can call local find method"() {
    BookService bookService = new BookService()
    boolean success = false

    when:"A service method's find() method is called directly"
        success = bookService.find()
    then:"The service is called correctly"
        success == true

    when:"A service method does not call the service's find() method"
        success = bookService.willNotCallFindMethod()
    then:"The service is called correctly"
        success == true

    when:"A service method calls the service's find() method"
        success = bookService.willCallFindMethod()
    then:"The service is called correctly"
        success == true

}

}

class BookService {

def willNotCallFindMethod() {
    return true
}

def willCallFindMethod() {
    // TODO: If the bug exists, this will cause a MissingMethodException
    // should we catch the exception and return false in this case
    // ...or let the exception bubble up?
    find()
    return true
}

def find() {
    return true
}

}
{code}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant