GMongo enhancements fail when using invokeDynamic
mathieucarbou opened this issue · 3 comments
When I try to compile my groovy module with Maven using Java 8 and the new gmaven plugin with invokedynamic, my tests fails because GMongo cannot convert maps and list containing teh requests to DbObject.
Thus I am forced to disable invokeDynamic
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<configuration>
<invokeDynamic>false</invokeDynamic>
</configuration>
</plugin>
If I enable it, I have the following error:
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to com.mongodb.DBObject
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:219)
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:204)
at com.mongodb.DBCollection.insert(DBCollection.java:148)
at com.mongodb.DBCollection.insert(DBCollection.java:133)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterf
I am using the Groovy 2.2.1 indy jar.
I will take a look mathieucarbou. Tks for the report.
FYI: when updated to Groovy 2.3.0-rc-4, I do not see the error anymore. But the invoke dynamic makes our app crash elsewhere in inner classes. So nothing more linked to GMongo.
I am reopening: the issue still exists. When using for exemple
collection.insert(LIst<Map> insert)
I am forced to call:
collection.insert(Patcher._convert(insert))
Because the call to .insert directly goes to DBCollection through an invoke dynamic call and does not go through the invokeMethod interceptor set by the Patcher class.