{"record":{"id":"3e37af6a161a7f4c","repo":"spring-projects/spring-framework","slug":"indexed-read-method-returns-void","errorCode":null,"errorMessage":"Indexed read method returns void: {}","messagePattern":"Indexed read method returns void: (.+?)","errorType":"exception","errorClass":"IntrospectionException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java","lineNumber":207,"sourceCode":"\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\n\t\t\t\t\tindexedPropertyType = params[1];\n\t\t\t\t}\n\t\t\t\telse if (params[1].isAssignableFrom(indexedPropertyType)) {\n\t\t\t\t\t// Proceed with read method's property type","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java#L189-L225","documentation":"Thrown as java.beans.IntrospectionException by PropertyDescriptorUtils.findIndexedPropertyType when an indexed read method returns void. An indexed getter must return the element type, so a void return makes the indexed property type unresolvable.","triggerScenarios":"findIndexedPropertyType called with an indexedReadMethod whose getReturnType() == void.class (e.g. void getXxx(int i)).","commonSituations":"A void-returning method named getXxx(int) misregistered as an indexed getter, generated code emitting void indexed accessors, or a typo.","solutions":["Make the indexed getter return the element type: Type getXxx(int i).","Rename the void method so it is not picked up as an indexed getter.","Regenerate the offending class with correct return types."],"exampleFix":"// before\npublic void getItems(int i); // void indexed getter\n\n// after\npublic Item getItems(int i);","handlingStrategy":"validation","validationCode":"if (indexedReadMethod != null && indexedReadMethod.getReturnType() == void.class) {\n    throw new IllegalArgumentException(\"indexed getter returns void: \" + indexedReadMethod);\n}","typeGuard":"static boolean indexedGetterReturnsValue(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 (getXxx(int)) must return the element type.","Rename void methods that look like indexed getters.","Review generated classes for void indexed accessors."],"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"}