-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ClassCastException in MappingMongoConverter when having Map<String, Object> as a field type. #3692
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
Comments
Thanks for reporting can you please add the domain types involved as well as the raw document representation. Ideally you have a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
I will try but in 3.1.x there was no cast to Bson and this the problem when using Object as value in a map.
|
minimal_sample.zip In the following link, near the end of the article, you could find Postman collection with all crud ops. |
The java driver uses I admit the restriction in place is a kinda hard one and I'll take this to the team to see if we want it to be softened to something like: if (typeHint.isMap()) {
if(source instanceof Bson) {
return (S) mapConverter.convert(this, (Bson) source, typeHint);
}
if(source instanceof Map) {
return (S) mapConverter.convert(this, new Document((Map<String,Object>)source), typeHint);
}
throw new IllegalArgumentException(String.format("Expected map like structure but found %s", source.getClass()));
} For the time being please |
Closing as duplicate of #3702 |
After upgrading to Spring Boot from 2.4.4 to 2.5.2(spring-data-mongodb 3.1.6 --> 3.2.2) I am having the following exception:
In the domain object there is a the following property:
protected Map<String, Object> _flexFields = new HashMap<>()
When
MappingMongoConverter
try to convert it in line1905
, the exception is thrown even the map is empty.The 3.1.x
MappingMongoConverter
implementation works fine.Please some fix.
The text was updated successfully, but these errors were encountered: