{"record":{"id":"6a1389aab767a229","repo":"theonedev/onedev","slug":"not-recognized-getter-method-class-s-method","errorCode":null,"errorMessage":"Not recognized getter method (class: %s, method: %s)","messagePattern":"Not recognized getter method \\(class: (.+?), method: (.+?)\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/BeanUtils.java","lineNumber":213,"sourceCode":"\t}\n\t\n\t/**\n\t * Get property name associated with the getter method.\n\t * \n\t * @param getter\n\t * \t\t\tgetter method to retrieve property name from\n\t * @return\n\t * \t\t\tproperty name associated with the getter method\n\t * @throws\n\t * \t\t\tRuntimeException if specified method is not a getter method\n\t */\n\tpublic static String getPropertyName(Method getter) {\n\t\tif (getter.getName().startsWith(\"get\")) {\n\t\t\treturn getPropertyName(getter.getName().substring(3));\n\t\t} else if (getter.getName().startsWith(\"is\")) {\n\t\t\treturn getPropertyName(getter.getName().substring(2));\n\t\t} else {\n\t\t\tthrow new RuntimeException(String.format(\"Not recognized getter method (class: %s, method: %s)\", \n\t\t\t\t\tgetter.getDeclaringClass().getName(), getter.getName()));\n\t\t}\n\t}\n\t\n\t/**\n\t * Find corresponding setter method in declaring class of specified getter. Note that it will not \n\t * search in super classes as the sub class may intentionally override getter without overriding \n\t * setter to make some property read only\n\t * \n\t * @param getter\n\t * \t\t\tgetter method to find corresponding setter\n\t * @return\n\t * \t\t\tsetter method, or <tt>null</tt> if not found in declared class of the getter\n\t */\n\tpublic static Method findSetter(Method getter) {\n\t\tString setterName = \"set\" + getAccessorSuffix(getPropertyName(getter));\n\t\ttry {\n\t\t\treturn getter.getDeclaringClass().getDeclaredMethod(setterName, getter.getReturnType());","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/BeanUtils.java#L195-L231","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nString prop = BeanUtils.getPropertyName(method); // method = build(), throws\n// after\nif (method.getName().startsWith(\"get\") || method.getName().startsWith(\"is\")) {\n    String prop = BeanUtils.getPropertyName(method);\n}","handlingStrategy":"type-guard","validationCode":"public static boolean isJavaBeanGetter(Method m) {\n    String n = m.getName();\n    return (n.startsWith(\"get\") && n.length() > 3) || (n.startsWith(\"is\") && n.length() > 2);\n}","typeGuard":"methods.stream().filter(BeanUtilsHelper::isJavaBeanGetter)\n       .forEach(m -> use(BeanUtils.getPropertyName(m)));","tryCatchPattern":"try {\n    String prop = BeanUtils.getPropertyName(method);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Not recognized getter method\"))\n        logger.warn(\"Skipping non-getter method {}\", method.getName());\n    else throw e;\n}","preventionTips":["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"],"tags":["reflection","javabeans","naming-convention","runtime"],"backgroundTag":"invalid-argument-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}