{"record":{"id":"e7da065113285f99","repo":"apache/beam","slug":"schemacaseformat-can-only-be-used-on-getters-in-java-beans","errorCode":null,"errorMessage":"@SchemaCaseFormat can only be used on getters in Java Beans. Found on setter '%s'","messagePattern":"@SchemaCaseFormat can only be used on getters in Java Beans\\. Found on setter '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaBeanSchema.java","lineNumber":133,"sourceCode":"                Method m =\n                    Preconditions.checkNotNull(\n                        t.getMethod(), JavaBeanUtils.SETTER_WITH_NULL_METHOD_ERROR);\n                if (m.getAnnotation(SchemaFieldNumber.class) != null) {\n                  throw new RuntimeException(\n                      String.format(\n                          \"@SchemaFieldNumber can only be used on getters in Java Beans. Found on\"\n                              + \" setter '%s'\",\n                          m.getName()));\n                }\n                if (m.getAnnotation(SchemaFieldName.class) != null) {\n                  throw new RuntimeException(\n                      String.format(\n                          \"@SchemaFieldName can only be used on getters in Java Beans. Found on\"\n                              + \" setter '%s'\",\n                          m.getName()));\n                }\n                if (m.getAnnotation(SchemaCaseFormat.class) != null) {\n                  throw new RuntimeException(\n                      String.format(\n                          \"@SchemaCaseFormat can only be used on getters in Java Beans. Found on\"\n                              + \" setter '%s'\",\n                          m.getName()));\n                }\n                return t;\n              })\n          .collect(Collectors.toList());\n    }\n\n    @Override\n    public int hashCode() {\n      return System.identityHashCode(this);\n    }\n\n    @Override\n    public boolean equals(@Nullable Object obj) {\n      return obj instanceof SetterTypeSupplier;","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/JavaBeanSchema.java#L115-L151","documentation":"JavaBeanSchema validates that schema-annotation @SchemaCaseFormat appears only on getter methods. When introspecting a Java Bean, if a setter method carries @SchemaCaseFormat, the schema provider throws a RuntimeException because case-format mapping is only meaningful for reading properties into schema fields.","triggerScenarios":"Using JavaBeanSchema as the schema provider for a class whose setter method (e.g. setFoo(String)) is annotated with @SchemaCaseFormat instead of its getter.","commonSituations":"Copy-pasting annotations from getter to setter, applying class-wide annotation search-and-replace, or IDE-generated setters that inherited annotations from fields/getters.","solutions":["Move the @SchemaCaseFormat annotation from the setter to the corresponding getter method.","Remove @SchemaCaseFormat from the setter if the format mapping is not needed for that property.","If a write-side transformation is required, implement it manually in the setter body instead of via annotation."],"exampleFix":"// before\npublic void setName(String name) { this.name = name; }\n@SchemaCaseFormat(LOWER_SNAKE) public void setName2(String n) {}\n\n// after\n@SchemaCaseFormat(LOWER_SNAKE)\npublic String getName() { return name; }\npublic void setName(String name) { this.name = name; }","handlingStrategy":"validation","validationCode":"// Java: verify annotations before registering schema\nfor (Method m : MyBean.class.getMethods()) {\n  if (m.getName().startsWith(\"set\") && m.isAnnotationPresent(SchemaCaseFormat.class)) {\n    throw new IllegalStateException(\"@SchemaCaseFormat on setter: \" + m.getName());\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Annotate getters only in Java Beans used with JavaBeanSchema.","Review IDE-generated setters for inherited annotations."],"tags":["java","schema","annotation-misuse","javabeans"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}