{"record":{"id":"1568ec9add50974e","repo":"theonedev/onedev","slug":"cannot-find-setter-class-s-property-s-type","errorCode":null,"errorMessage":"Cannot find setter (class: %s, property: %s, type: %s)","messagePattern":"Cannot find setter \\(class: (.+?), property: (.+?), type: (.+?)\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/BeanUtils.java","lineNumber":265,"sourceCode":"\t\t}\n\t}\n\t\n\t/**\n\t * Find corresponding setter method by getter in specified class and super classes.\n\t * <p>\n\t * @param getter\n\t * \t\t\tgetter method to search setter for\n\t * @return\n\t * \t\t\tsetter method\n\t * @throws\n\t * \t\t\tRuntimeException if not found in class hierarchy\n\t */\n\tpublic static Method getSetter(Method getter) {\n\t\tMethod setter = findSetter(getter);\n\t\tif (setter == null) {\n\t\t\tString message = String.format(\"Cannot find setter (class: %s, property: %s, type: %s)\", \n\t\t\t\t\tgetter.getDeclaringClass().getName(), getPropertyName(getter), getter.getReturnType().getName());\n\t\t\tthrow new RuntimeException(message);\n\t\t}\n\t\treturn setter;\n\t}\n\n\tpublic static String getDisplayName(AnnotatedElement element) {\n\t\tif (element instanceof Class)\n\t\t\treturn WordUtils.uncamel(((Class<?>)element).getSimpleName());\n\t\telse if (element instanceof Field) \n\t\t\treturn WordUtils.uncamel(WordUtils.capitalize(((Field)element).getName()));\n\t\telse if (element instanceof Method)\n\t\t\treturn StringUtils.substringAfter(WordUtils.uncamel(((Method)element).getName()), \" \");\n\t\telse if (element instanceof Package) \n\t\t\treturn ((Package)element).getName();\n\t\telse\n\t\t\tthrow new RuntimeException(\"Invalid element type: \" + element.getClass().getName());\n\t}\n\t\n}","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/BeanUtils.java#L247-L283","documentation":"BeanUtils.getSetter finds the setter Method corresponding to a given getter via JavaBeans conventions (setXxx with a single parameter matching the getter return type). It throws this RuntimeException when findSetter returns null, i.e. no matching setter exists on the declaring class.","triggerScenarios":"Calling BeanUtils.getSetter(getter) where the class has a readable property (getXxx/isXxx) but no public setXxx(Method type) accepting the getter's return type, or the setter has a different/incompatible parameter type, or the property is read-only.","commonSituations":"Reflection-based bean copying/serialization utilities over classes with computed or read-only properties (e.g. getters without setters), Lombok @Getter without @Setter, immutable value objects, or a setter whose parameter type differs from the getter return type (covariant getter overriding).","solutions":["Add a public setter matching JavaBeans conventions: public void setPropertyName(<getterReturnType> value).","If using Lombok, add @Setter (or @Data) to the class or the field.","Verify the setter parameter type exactly matches the getter's return type; autoboxing/generics mismatches are not resolved by this lookup.","If the property is intentionally read-only, use findSetter(...) and handle null, or avoid reflective write of that property instead of calling getSetter."],"exampleFix":"// before (read-only bean, throws)\nclass Config { public String getName() { return name; } }\n// after\nclass Config {\n  private String name;\n  public String getName() { return name; }\n  public void setName(String name) { this.name = name; }\n}","handlingStrategy":"validation","validationCode":"Method setter = BeanUtils.findSetter(getter);\nif (setter == null) {\n    // skip read-only property or fail fast with your own message\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep getters/setters symmetric on beans used reflectively (use @Data or generate both).","Prefer findSetter and null-check when properties may be read-only.","Ensure setter parameter types match getter return types exactly."],"tags":["reflection","javabeans","runtime"],"backgroundTag":"method-not-implemented","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}