theonedev/onedev · error · RuntimeException
Not recognized getter method (class: %s, method: %s)
Error message
Not recognized getter method (class: %s, method: %s)
What it means
BeanUtils.getPropertyName(Method getter) derives the bean property name from a getter method by stripping the 'get' or 'is' prefix. If the passed method is not named according to either convention, a RuntimeException is thrown with the declaring class and method name — the method is not actually a getter.
Source
Thrown at server-core/src/main/java/io/onedev/server/util/BeanUtils.java:213
}
/**
* Get property name associated with the getter method.
*
* @param getter
* getter method to retrieve property name from
* @return
* property name associated with the getter method
* @throws
* RuntimeException if specified method is not a getter method
*/
public static String getPropertyName(Method getter) {
if (getter.getName().startsWith("get")) {
return getPropertyName(getter.getName().substring(3));
} else if (getter.getName().startsWith("is")) {
return getPropertyName(getter.getName().substring(2));
} else {
throw new RuntimeException(String.format("Not recognized getter method (class: %s, method: %s)",
getter.getDeclaringClass().getName(), getter.getName()));
}
}
/**
* Find corresponding setter method in declaring class of specified getter. Note that it will not
* search in super classes as the sub class may intentionally override getter without overriding
* setter to make some property read only
*
* @param getter
* getter method to find corresponding setter
* @return
* setter method, or <tt>null</tt> if not found in declared class of the getter
*/
public static Method findSetter(Method getter) {
String setterName = "set" + getAccessorSuffix(getPropertyName(getter));
try {
return getter.getDeclaringClass().getDeclaredMethod(setterName, getter.getReturnType());View on GitHub (pinned to d44925c47c)
Solutions
- Filter candidate methods by Modifier/is-void-return and name.startsWith("get")||startsWith("is") before calling getPropertyName()
- Rename the accessor to follow JavaBean conventions (getX/isX) if it is meant to be a bean property
- If fluent naming is intentional, resolve the property name yourself instead of via getPropertyName()
- Guard the call: check getter.getName() prefix and handle the fallback in your code rather than letting it throw
Example fix
// before
String prop = BeanUtils.getPropertyName(method); // method = build(), throws
// after
if (method.getName().startsWith("get") || method.getName().startsWith("is")) {
String prop = BeanUtils.getPropertyName(method);
} Defensive patterns
Strategy: type-guard
Validate before calling
public static boolean isJavaBeanGetter(Method m) {
String n = m.getName();
return (n.startsWith("get") && n.length() > 3) || (n.startsWith("is") && n.length() > 2);
} Type guard
methods.stream().filter(BeanUtilsHelper::isJavaBeanGetter)
.forEach(m -> use(BeanUtils.getPropertyName(m))); Try / catch
try {
String prop = BeanUtils.getPropertyName(method);
} catch (RuntimeException e) {
if (e.getMessage().startsWith("Not recognized getter method"))
logger.warn("Skipping non-getter method {}", method.getName());
else throw e;
} Prevention
- Filter method lists to get/is prefixes before property-name derivation
- Use JavaBean naming conventions for accessors you intend to reflect on
- Exclude setters and Object methods when enumerating bean properties
When it happens
Trigger: Calling getPropertyName() with a Method that is not a standard JavaBean getter, i.e. its name starts with neither 'get' nor 'is' (e.g. a setter, a plain method like toString(), or a fluent-named accessor).
Common situations: Passing arbitrary methods obtained from getDeclaredMethods() without filtering for getters; assuming fluent accessors (name() instead of getName()) are supported; passing setters by mistake in reflective mapping code.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Getter not found (class: %s, property: %s)
- Cannot find setter (class: %s, property: %s, type: %s)
- Invalid element type:
- Getter not found for property: ${propertyName}
- Getter not found for property: ${dependsOn.property()}
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/6a1389aab767a229.
Report an issue: GitHub.