restfulapi / restful-api

Grails plugin to facilitate exposing non-trivial RESTful APIs
Apache License 2.0
52 stars 27 forks source link

ArrayList.sort getting passed java.util.Comparator instead of Closure #10

Closed michaelcdillon closed 10 years ago

michaelcdillon commented 10 years ago

I recently just upgraded my grails app to 2.4.0 and I'm actively using and loving this plugin so when it failed to return any http requests that should be handled by the restful-api plugin I went digging. The issue is very simple, the latest version of grails includes a newer version of groovy and the arraylist.sort method expects a boolean argument along with a java.util.Comparator when sorting that way. I quickly searched the rest of the code base and saw no other usage of Comparators so I modified MediaTypeParser to use a closure with the same functionality as the comparator.

corystevens commented 10 years ago

I had this problem too, I solved it the way the Grails authors did in DefaultAcceptHeaderParser

return mimes.sort(true, new QualityComparator()) as MediaType[]

It was fixed recently in this commit in grails-core

sriddell commented 10 years ago

Thanks for bringing this up; I'm looking at fixing it the same way grails-core does. Unfortunately, it's taking me a bit of time to get it merged; not because the fix itself is complex, but because I need to get our test application upgraded and running under grails 2.4.0.

In any case, it will be fixed in the next release.

corystevens commented 10 years ago

I've started to do that as well. I'll update my fork this weekend detailing any problems I encountered.

sriddell commented 10 years ago

Fixed with using

return mimes.sort(true, new QualityComparator()) as MediaType[]

in commit f3744b67966b765279d719be8d89965557a0b165.

Currently scheduled for release in 0.9.1 or greater in the next week or so.