spring-projects/spring-framework · error · IntrospectionException
Bad indexed read method arg count: {}
Error message
Bad indexed read method arg count: {} What it means
Thrown as java.beans.IntrospectionException by PropertyDescriptorUtils.findIndexedPropertyType when an indexed read method does not have exactly one parameter. Indexed getters must take exactly one (the int index) parameter.
Source
Thrown at spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java:200
propertyType = params[0];
}
}
return propertyType;
}
/**
* See {@link java.beans.IndexedPropertyDescriptor#findIndexedPropertyType}.
*/
public static @Nullable Class<?> findIndexedPropertyType(String name, @Nullable Class<?> propertyType,
@Nullable Method indexedReadMethod, @Nullable Method indexedWriteMethod) throws IntrospectionException {
Class<?> indexedPropertyType = null;
if (indexedReadMethod != null) {
Class<?>[] params = indexedReadMethod.getParameterTypes();
if (params.length != 1) {
throw new IntrospectionException("Bad indexed read method arg count: " + indexedReadMethod);
}
if (params[0] != int.class) {
throw new IntrospectionException("Non int index to indexed read method: " + indexedReadMethod);
}
indexedPropertyType = indexedReadMethod.getReturnType();
if (indexedPropertyType == void.class) {
throw new IntrospectionException("Indexed read method returns void: " + indexedReadMethod);
}
}
if (indexedWriteMethod != null) {
Class<?>[] params = indexedWriteMethod.getParameterTypes();
if (params.length != 2) {
throw new IntrospectionException("Bad indexed write method arg count: " + indexedWriteMethod);
}
if (params[0] != int.class) {
throw new IntrospectionException("Non int index to indexed write method: " + indexedWriteMethod);
}View on GitHub (pinned to 69bf83ad71)
Solutions
- Make the indexed read method take exactly one parameter (the int index): Type getXxx(int i).
- If the property is not indexed, do not register the method as an indexed accessor.
- Correct or regenerate the offending class.
Example fix
// before public Item getItem(); // wrong arity for indexed getter // after public Item getItem(int i);
Defensive patterns
Strategy: validation
Validate before calling
if (indexedReadMethod != null && indexedReadMethod.getParameterCount() != 1) {
throw new IllegalArgumentException("indexed getter must take 1 arg: " + indexedReadMethod);
} Type guard
static boolean validIndexedReadMethod(Method m) {
return m != null && m.getParameterCount() == 1 && m.getParameterTypes()[0] == int.class
&& m.getReturnType() != void.class;
} Prevention
- Indexed getters take exactly one parameter: getXxx(int).
- Do not register plain (zero-arg) getters as indexed accessors.
- Keep indexed and simple accessors distinct in naming/arity.
When it happens
Trigger: findIndexedPropertyType is called with an indexedReadMethod whose parameter count != 1 - e.g. an indexed getter taking 0 args (degenerate simple getter) or 2+ args.
Common situations: A method intended as an indexed getter (getXxx(int)) that has wrong arity, misregistration of a plain getter as indexed, or generated classes with malformed indexed accessors.
Related errors
- Non int index to indexed read method: {}
- Indexed read method returns void: {}
- Bad indexed write method arg count: {}
- Bad read method arg count: {readMethod}
- Read method returns void: {readMethod}
AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09).
Data as JSON: /api/errors/4da3b050af01f938.
Report an issue: GitHub.