{"record":{"id":"9182b1ec13d3a427","repo":"spring-projects/spring-framework","slug":"non-int-index-to-indexed-read-method","errorCode":null,"errorMessage":"Non int index to indexed read method: {}","messagePattern":"Non int index to indexed read method: (.+?)","errorType":"exception","errorClass":"IntrospectionException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java","lineNumber":203,"sourceCode":"\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}\n\t\t\tif (indexedPropertyType != null) {\n\t\t\t\tif (indexedPropertyType.isAssignableFrom(params[1])) {\n\t\t\t\t\t// Write method's property type potentially more specific","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java#L185-L221","documentation":"Thrown as java.beans.IntrospectionException by PropertyDescriptorUtils.findIndexedPropertyType when the indexed read method's single parameter is not of type int. JavaBeans indexed accessors require the index parameter to be int.","triggerScenarios":"findIndexedPropertyType called with an indexedReadMethod whose single param is not int.class (e.g. long, Integer, String).","commonSituations":"An overloaded accessor getXxx(long) or getXxx(Integer), a custom indexing scheme using a non-int key, or generated code using the wrong index type.","solutions":["Change the indexed getter's index parameter to int: Type getXxx(int i).","If you need a non-int key, do not model it as a JavaBeans indexed property; use a Map-typed simple property instead.","Correct or regenerate the offending class."],"exampleFix":"// before\npublic Item getItem(long index); // non-int index\n\n// after\npublic Item getItem(int index);","handlingStrategy":"validation","validationCode":"if (indexedReadMethod != null && indexedReadMethod.getParameterTypes()[0] != int.class) {\n    throw new IllegalArgumentException(\"indexed getter index must be int: \" + indexedReadMethod);\n}","typeGuard":"static boolean indexedReadUsesInt(Method m) {\n    return m != null && m.getParameterCount() == 1 && m.getParameterTypes()[0] == int.class;\n}","tryCatchPattern":null,"preventionTips":["JavaBeans indexed property index is always primitive int.","For keyed (non-int) access, use a Map-typed simple property instead of indexed accessors.","Avoid boxing the index (Integer) in accessor signatures."],"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"}