-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Labels
api: firestoreIssues related to the googleapis/java-firestore API.Issues related to the googleapis/java-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Specify the API at the beginning of the title. For example, "BigQuery: ...").
com.google.cloud:google-cloud-firestore:1.33.0 - OS type and version:
Windows 10 - Java version:
Java 11 - firestore version(s):
1.33.0
Steps to reproduce
- Load a class having a property extending the ArrayList class (InternalFieldDefinition in my example)
Code example
package io.test;
import java.util.ArrayList;
public class InternalFieldPath extends ArrayList<InternalMappingField> {
public InternalFieldPath() {
super();
}
}package io.test;
public class InternalFieldDefinition extends InternalModel {
private String name;
private InternalFieldPath path;
}Stack trace
java.lang.RuntimeException: Could not deserialize object. Can't convert object of type java.util.ArrayList to type io.blendeez.common.domain.model.internal.InternalFieldPath (found in field 'fieldDefinitions.[0].sourceFieldPath')
at com.google.cloud.firestore.CustomClassMapper.deserializeError(CustomClassMapper.java:563)
at com.google.cloud.firestore.CustomClassMapper.convertBean(CustomClassMapper.java:544)
Any additional information below
It seems the case where a bean extends an ArrayList is not properly handled in CustomClassMapper (only Map):
private static <T> T convertBean(Object o, Class<T> clazz, DeserializeContext context) {
BeanMapper<T> mapper = loadOrCreateBeanMapperForClass(clazz);
if (o instanceof Map) {
return mapper.deserialize(expectMap(o, context), context);
} else {
throw deserializeError(
context.errorPath,
"Can't convert object of type " + o.getClass().getName() + " to type " + clazz.getName());
}
}FYI while switching the class attribute to a list it works:
public class InternalFieldDefinition {
private String name;
private List<InternalMappingField> path;
}Metadata
Metadata
Assignees
Labels
api: firestoreIssues related to the googleapis/java-firestore API.Issues related to the googleapis/java-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.