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

GmongoClient should extend GMongo #29

Closed
davydotcom opened this issue Mar 2, 2015 · 5 comments
Closed

GmongoClient should extend GMongo #29

davydotcom opened this issue Mar 2, 2015 · 5 comments

Comments

@davydotcom
Copy link

In the java mongo driver MongoClient actually extends Mongo. So i think there can be some slight simplification here and addition of this chain of inheritence so it would be more consistent to use. We are running into a case where that was assumed and its failing as a result. We are working on a PR with a fix. just wanted to give you a heads up. Thanks on releasing 1.4 btw.

@poiati
Copy link
Owner

poiati commented Mar 2, 2015

Hello davy,

I choose to not inherit from Mongo, this was my design decision. Inheritance comes with some problems and I rather using composition with delegation. In the ideal scenario Mongo/MongoClient should be an interface with GMongo implementing it but there isn't such interface.

That said, I know what you mean and what you want, I will take a look at your solution.

Thanks!

@bdwheeler
Copy link
Contributor

Thanks for looking- what you have is super and makes sense. The issue we are facing is that the grails team has code that says: GMongo mongo - and below - if auth is involved set mongo = new GMongoClient.
I think they incorrectly assumed that since MongoClient extends Mongo in the java driver that GMongoClient would extend GMongo.
I know that isn't your problem - but the grails team isn't going to go back and fix all their published versions that have this flaw - and they resolve it in the upcoming grails 3 release.
So it seemed for us the quickest path to getting working with mongo 3 and auth is to extend Gmongo in a custom build.
thanks.

@poiati
Copy link
Owner

poiati commented Mar 2, 2015

I agree, it's easy to think that GMongoClient extends GMongo and maybe it really should. But if what you are saying is true, you mean the mongodb plugin is failing with compilation errors?

@bdwheeler
Copy link
Contributor

Not compilation - it's in groovy code - happens at startup and causes a crash. Depends how you configure the mongo plugin for auth - here is the code where you can see the Gmongo declaration and assignment of a GMongoClient to it - the line it halts on. This is from the grails datastore mongo plugin 3.0.2 branch. 3.0.0 never used GMongoClient and auth against 2.6+ wouldn't work - 3.0.1 didn't work at all and had dependency issues.
http://bertram.d.pr/1MbZ
http://bertram.d.pr/GJP8

In their upcoming grails 3 release they change this all by building up an actual Mongo or MongoClient and then using the GMonog(mongo) constructor which should work. There still might be an advantage to extending and ensuring that using GMongo injections exposes everything MongoClient has.
Thanks again.

@poiati
Copy link
Owner

poiati commented Mar 2, 2015

I see, thanks for all the feedback.

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

No branches or pull requests

3 participants