Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
6.0
-
None
-
None
Description
See: http://stackoverflow.com/questions/37241489/solrj-6-0-0-insertion-of-a-bean-object-which-associate-list-of-bean-object-is-g
for defect description.
Defect is caused by below piece of code if annotation is present at setter for list of child:
public DocField(AccessibleObject member) {
if (member instanceof java.lang.reflect.Field)
else
{ setter = (Method) member; // initialized as annotation is at setter } annotation = member.getAnnotation(Field.class);
storeName(annotation);
storeType(); // giving null pointer exception as field is null see below
// Look for a matching getter
if (setter != null) {
String gname = setter.getName();
if (gname.startsWith("set")) {
gname = "get" + gname.substring(3);
try
catch (Exception ex) {
// no getter – don't worry about it...
if (type == Boolean.class) {
gname = "is" + setter.getName().substring(3);
try
catch(Exception ex2)
{ // no getter -- don't worry about it... } }
}
}
}
}
private void storeType() {
if (field != null)
else {
Class[] params = setter.getParameterTypes();
if (params.length != 1)
type = params[0];
}
if (type == Collection.class || type == List.class || type == ArrayList.class) {
isList = true;
if (annotation.child())
else
{ type = Object.class; }} else if (type == byte[].class)
{ //no op } else if (type.isArray()) {
isArray = true;
if (annotation.child())
else
{ type = type.getComponentType(); } } else if (type == Map.class || type == HashMap.class) { //corresponding to the support for dynamicFields
if (annotation.child()) throw new BindingException("Map should is not a valid type for a child document");
isContainedInMap = true;
//assigned a default type
type = Object.class;
if (field != null) {
if (field.getGenericType() instanceof ParameterizedType) {
//check what are the generic values
ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
Type[] types = parameterizedType.getActualTypeArguments();
if (types != null && types.length == 2 && types[0] == String.class) {
//the key should always be String
//Raw and primitive types
if (types[1] instanceof Class) {
//the value could be multivalued then it is a List, Collection, ArrayList
if (types[1] == Collection.class || types[1] == List.class || types[1] == ArrayList.class)
} else if (types[1] instanceof ParameterizedType) { //Of all the Parameterized types, only List is supported
Type rawType = ((ParameterizedType) types[1]).getRawType();
if (rawType == Collection.class || rawType == List.class || rawType == ArrayList.class) { type = Object.class; isList = true; }
} else if (types[1] instanceof GenericArrayType)
{ //Array types type = (Class) ((GenericArrayType) types[1]).getGenericComponentType(); isArray = true; }else
{ //Throw an Exception if types are not known throw new BindingException("Allowed type for values of mapping a dynamicField are : " + "Object, Object[] and List"); } }
}
}
} else {
if (annotation.child())
}
}