{"record":{"id":"44db71662583080c","repo":"spring-projects/spring-framework","slug":"bad-read-method-arg-count-readmethod","errorCode":null,"errorMessage":"Bad read method arg count: {readMethod}","messagePattern":"Bad read method arg count: (.+?)","errorType":"exception","errorClass":"IntrospectionException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java","lineNumber":155,"sourceCode":"\t\t}\n\n\t\t// See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor)\n\t\ttarget.setPropertyEditorClass(source.getPropertyEditorClass());\n\t\ttarget.setBound(source.isBound());\n\t\ttarget.setConstrained(source.isConstrained());\n\t}\n\n\t/**\n\t * See {@link java.beans.PropertyDescriptor#findPropertyType}.\n\t */\n\tpublic static @Nullable Class<?> findPropertyType(@Nullable Method readMethod, @Nullable Method writeMethod)\n\t\t\tthrows IntrospectionException {\n\n\t\tClass<?> propertyType = null;\n\n\t\tif (readMethod != null) {\n\t\t\tif (readMethod.getParameterCount() != 0) {\n\t\t\t\tthrow new IntrospectionException(\"Bad read method arg count: \" + readMethod);\n\t\t\t}\n\t\t\tpropertyType = readMethod.getReturnType();\n\t\t\tif (propertyType == void.class) {\n\t\t\t\tthrow new IntrospectionException(\"Read method returns void: \" + readMethod);\n\t\t\t}\n\t\t}\n\n\t\tif (writeMethod != null) {\n\t\t\tClass<?>[] params = writeMethod.getParameterTypes();\n\t\t\tif (params.length != 1) {\n\t\t\t\tthrow new IntrospectionException(\"Bad write method arg count: \" + writeMethod);\n\t\t\t}\n\t\t\tif (propertyType != null) {\n\t\t\t\tif (propertyType.isAssignableFrom(params[0])) {\n\t\t\t\t\t// Write method's property type potentially more specific\n\t\t\t\t\tpropertyType = params[0];\n\t\t\t\t}\n\t\t\t\telse if (params[0].isAssignableFrom(propertyType)) {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java#L137-L173","documentation":"Thrown as java.beans.IntrospectionException by PropertyDescriptorUtils.findPropertyType when a read method passed in has a non-zero parameter count. JavaBeans getters must take no arguments, so this signals a malformed PropertyDescriptor read method.","triggerScenarios":"findPropertyType(readMethod, writeMethod) is invoked (typically while building a GenericTypeAwarePropertyDescriptor) and readMethod.getParameterCount() != 0. Means a method with arguments was registered as a read method.","commonSituations":"A getter-like method that actually takes arguments, a misconfigured custom PropertyDescriptor, or a generated/bytecode-altered class exposing a method as a getter that has parameters. This is usually an internal Spring/Introspector state, surfaced as a wrapped fatal exception by callers.","solutions":["Ensure the getter method takes no parameters (e.g. getName(), not getName(int)).","If the method is genuinely a different accessor (indexed/computed), name it according to indexed conventions (getXxx(int)).","Regenerate or correct the offending class so its bean accessors are valid."],"exampleFix":"// before\npublic String getName(int locale);  // misread as getter\n\n// after\npublic String getName();\npublic String getName(int locale); // renamed usage: use indexed/getter-of-locale pattern explicitly","handlingStrategy":"validation","validationCode":"// before registering a read method\nif (readMethod.getParameterCount() != 0) {\n    throw new IllegalArgumentException(\"read method takes args: \" + readMethod);\n}","typeGuard":"static boolean validReadMethod(Method m) {\n    return m != null && m.getParameterCount() == 0 && m.getReturnType() != void.class;\n}","tryCatchPattern":null,"preventionTips":["JavaBeans getters take zero arguments.","Static-analyze bean classes to flag getXxx methods that take parameters.","Avoid reusing getter names for parameterized overloads."],"tags":["property-descriptor","introspection","javabeans","spring-beans"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}