{"id":"5c3eca26a0662946","repo":"spring-projects/spring-framework","slug":"non-int-index-to-indexed-read-method-indexedrea","errorCode":null,"errorMessage":"Non int index to indexed read method: ${indexedReadMethod}","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/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java#L185-L221","documentation":"IntrospectionException from PropertyDescriptorUtils.findIndexedPropertyType when the single parameter of an indexed read method is not int. The JavaBean spec mandates that indexed accessors use int as the index type; long, Integer, or any other type is rejected.","triggerScenarios":"An indexed getter declared as getX(long index) or getX(Integer index) being registered as an indexed read method; passing a boxed Integer or non-int primitive as the index parameter.","commonSituations":"Code using long indices for large collections; auto-boxed Integer parameters from generated code; cross-language interop producing non-int index types.","solutions":["Change the indexed getter's index parameter type to primitive int.","If you need long indexing, do not use IndexedPropertyDescriptor - expose a custom accessor pattern instead.","Regenerate any code-producing non-int indices."],"exampleFix":"// before\npublic String getItems(long index) { ... }\n\n// after\npublic String getItems(int index) { ... }","handlingStrategy":"type-guard","validationCode":"static void assertIntIndex(Method indexedReadMethod) {\n    if (indexedReadMethod.getParameterTypes()[0] != int.class) {\n        throw new IllegalArgumentException(\"Indexed read index must be int: \" + indexedReadMethod);\n    }\n}","typeGuard":"static boolean hasIntIndex(Method m) {\n    Class<?>[] p = m.getParameterTypes();\n    return p.length == 1 && p[0] == int.class;\n}","tryCatchPattern":"try {\n    return new IndexedPropertyDescriptor(name, null, null, indexedReadMethod, indexedWriteMethod);\n} catch (java.beans.IntrospectionException ex) {\n    if (ex.getMessage().startsWith(\"Non int index to indexed read\")) {\n        log.error(\"Change {} index param to int\", indexedReadMethod);\n    }\n    throw ex;\n}","preventionTips":["Use primitive int for indexed accessors, not long or Integer.","If long indexing is needed, drop IndexedPropertyDescriptor.","Static-analyse indexed methods for non-int index types."],"tags":["property-descriptor","indexed","introspection","spring-beans"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}