{"record":{"id":"4da3b050af01f938","repo":"spring-projects/spring-framework","slug":"bad-indexed-read-method-arg-count","errorCode":null,"errorMessage":"Bad indexed read method arg count: {}","messagePattern":"Bad indexed read method arg count: (.+?)","errorType":"exception","errorClass":"IntrospectionException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java","lineNumber":200,"sourceCode":"\t\t\t\tpropertyType = params[0];\n\t\t\t}\n\t\t}\n\n\t\treturn propertyType;\n\t}\n\n\t/**\n\t * See {@link java.beans.IndexedPropertyDescriptor#findIndexedPropertyType}.\n\t */\n\tpublic static @Nullable Class<?> findIndexedPropertyType(String name, @Nullable Class<?> propertyType,\n\t\t\t@Nullable Method indexedReadMethod, @Nullable Method indexedWriteMethod) throws IntrospectionException {\n\n\t\tClass<?> indexedPropertyType = null;\n\n\t\tif (indexedReadMethod != null) {\n\t\t\tClass<?>[] params = indexedReadMethod.getParameterTypes();\n\t\t\tif (params.length != 1) {\n\t\t\t\tthrow new IntrospectionException(\"Bad indexed read method arg count: \" + indexedReadMethod);\n\t\t\t}\n\t\t\tif (params[0] != int.class) {\n\t\t\t\tthrow new IntrospectionException(\"Non int index to indexed read method: \" + indexedReadMethod);\n\t\t\t}\n\t\t\tindexedPropertyType = indexedReadMethod.getReturnType();\n\t\t\tif (indexedPropertyType == void.class) {\n\t\t\t\tthrow new IntrospectionException(\"Indexed read method returns void: \" + indexedReadMethod);\n\t\t\t}\n\t\t}\n\n\t\tif (indexedWriteMethod != null) {\n\t\t\tClass<?>[] params = indexedWriteMethod.getParameterTypes();\n\t\t\tif (params.length != 2) {\n\t\t\t\tthrow new IntrospectionException(\"Bad indexed write method arg count: \" + indexedWriteMethod);\n\t\t\t}\n\t\t\tif (params[0] != int.class) {\n\t\t\t\tthrow new IntrospectionException(\"Non int index to indexed write method: \" + indexedWriteMethod);\n\t\t\t}","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java#L182-L218","documentation":"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.","triggerScenarios":"findIndexedPropertyType is called with an indexedReadMethod whose parameter count != 1 - e.g. an indexed getter taking 0 args (degenerate simple getter) or 2+ args.","commonSituations":"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.","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."],"exampleFix":"// before\npublic Item getItem(); // wrong arity for indexed getter\n\n// after\npublic Item getItem(int i);","handlingStrategy":"validation","validationCode":"if (indexedReadMethod != null && indexedReadMethod.getParameterCount() != 1) {\n    throw new IllegalArgumentException(\"indexed getter must take 1 arg: \" + indexedReadMethod);\n}","typeGuard":"static boolean validIndexedReadMethod(Method m) {\n    return m != null && m.getParameterCount() == 1 && m.getParameterTypes()[0] == int.class\n        && m.getReturnType() != void.class;\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["property-descriptor","introspection","indexed-property","javabeans","spring-beans"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}