spring-projects/spring-framework · error · IntrospectionException
Read method returns void
Error message
Read method returns void: {readMethod} What it means
Thrown as java.beans.IntrospectionException by PropertyDescriptorUtils.findPropertyType when the supplied read method's return type is void. A JavaBeans getter must return a value; a void return makes the property type unresolvable.
Solutions
- Change the getter to return the property type instead of void.
- Rename the void method so it is not picked up as a getter (no getXxx/isXxx prefix).
- Regenerate the class with corrected getter signatures.
Example fix
// before
public void getName() { return this.name; } // void return
// after
public String getName() { return this.name; } Defensive patterns
Strategy: validation
Validate before calling
if (readMethod != null && readMethod.getReturnType() == void.class) {
throw new IllegalArgumentException("getter returns void: " + readMethod);
} Type guard
static boolean getterReturnsValue(Method m) {
return m != null && m.getParameterCount() == 0 && m.getReturnType() != void.class;
} Prevention
- Getters (getXxx/isXxx) must return a value, never void.
- If a method only performs a side effect, do not name it with a getter prefix.
- Code-review generated classes for void getters.
When it happens
Trigger: findPropertyType(readMethod, writeMethod) is called and readMethod.getReturnType() == void.class. Means a void method was registered as a read method.
Common situations: A method named getXxx or isXxx that returns void (a typo, or a side-effecting 'is' method), a code generator that emitted getters incorrectly, or accidental registration of a non-getter void method as a property read method.
Related errors
- Bad indexed read method arg count
- Bad indexed write method arg count
- Bad read method arg count
- Bad write method arg count
- Indexed read method returns void
AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09).
Data as JSON: /api/errors/4cda32fbd9cafb2d.
Report an issue: GitHub.
Appendix: source
Thrown at spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java:159
target.setBound(source.isBound());
target.setConstrained(source.isConstrained());
}
/**
* See {@link java.beans.PropertyDescriptor#findPropertyType}.
*/
public static @Nullable Class<?> findPropertyType(@Nullable Method readMethod, @Nullable Method writeMethod)
throws IntrospectionException {
Class<?> propertyType = null;
if (readMethod != null) {
if (readMethod.getParameterCount() != 0) {
throw new IntrospectionException("Bad read method arg count: " + readMethod);
}
propertyType = readMethod.getReturnType();
if (propertyType == void.class) {
throw new IntrospectionException("Read method returns void: " + readMethod);
}
}
if (writeMethod != null) {
Class<?>[] params = writeMethod.getParameterTypes();
if (params.length != 1) {
throw new IntrospectionException("Bad write method arg count: " + writeMethod);
}
if (propertyType != null) {
if (propertyType.isAssignableFrom(params[0])) {
// Write method's property type potentially more specific
propertyType = params[0];
}
else if (params[0].isAssignableFrom(propertyType)) {
// Proceed with read method's property type
}
else {
throw new IntrospectionException(View on GitHub (pinned to 69bf83ad71)