{"record":{"id":"382ee0adcc4923dd","repo":"apache/beam","slug":"java-bean-s-contains-a-setter-for-field-s-that-has-a-382ee0","errorCode":null,"errorMessage":"Java Bean '%s' contains a setter for field '%s' that has a mismatching nullable attribute. %s","messagePattern":"Java Bean '(.+?)' contains a setter for field '(.+?)' that has a mismatching nullable attribute\\. (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java","lineNumber":122,"sourceCode":"    for (FieldValueTypeInformation type : getters) {\n      FieldValueTypeInformation setterType = setterMap.get(type.getName());\n      Method m =\n          Preconditions.checkArgumentNotNull(type.getMethod(), GETTER_WITH_NULL_METHOD_ERROR);\n      if (setterType == null) {\n        throw new RuntimeException(\n            String.format(\n                \"Java Bean '%s' contains a getter for field '%s', but does not contain a matching\"\n                    + \" setter. %s\",\n                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));\n      }\n      if (!type.getType().equals(setterType.getType())) {\n        throw new RuntimeException(\n            String.format(\n                \"Java Bean '%s' contains a setter for field '%s' that has a mismatching type. %s\",\n                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));\n      }\n      if (!type.isNullable() == setterType.isNullable()) {\n        throw new RuntimeException(\n            String.format(\n                \"Java Bean '%s' contains a setter for field '%s' that has a mismatching nullable\"\n                    + \" attribute. %s\",\n                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));\n      }\n    }\n  }\n\n  // Static ByteBuddy instance used by all helpers.\n  private static final ByteBuddy BYTE_BUDDY = new ByteBuddy();\n\n  private static final Map<TypeDescriptorWithSchema<?>, List<FieldValueTypeInformation>>\n      CACHED_FIELD_TYPES = Maps.newConcurrentMap();\n\n  public static List<FieldValueTypeInformation> getFieldTypes(\n      TypeDescriptor<?> typeDescriptor,\n      Schema schema,\n      FieldValueTypeSupplier fieldValueTypeSupplier) {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java#L104-L140","documentation":"Beyond type equality, validateJavaBean requires getter and setter to agree on nullability (@Nullable annotation presence). A getter that is nullable paired with a setter that is not (or vice versa) yields a schema field whose nullability is ambiguous, so Beam throws RuntimeException. This keeps schema NULLABLE flags deterministic.","triggerScenarios":"One of the accessor pair is annotated @Nullable and the other is not — e.g. `@Nullable String getX()` with `void setX(String x)`, or a primitive setter for a nullable getter (int vs Integer).","commonSituations":"Adding @Nullable only to the getter when hardening null-safety; Lombok generated accessors without null annotations while fields carry @Nullable partially; migrating from primitives to boxed types for one accessor only.","solutions":["Annotate both getter and setter (parameter) consistently with @Nullable — or remove it from both.","Ensure nullable fields use boxed types (Integer, not int) on both accessors.","If using Lombok, put @Nullable on the field so both generated accessors inherit it where applicable."],"exampleFix":"// before\n@Nullable public String getEmail() {...} public void setEmail(String e) {...}\n// after\n@Nullable public String getEmail() {...} public void setEmail(@Nullable String e) {...}","handlingStrategy":"validation","validationCode":"Method g = ..., s = ...;\nboolean gNull = g.getAnnotation(Nullable.class) != null; boolean sNull = s.getParameters()[0].getAnnotation(Nullable.class) != null;\nif (gNull != sNull) throw new IllegalStateException(\"@Nullable mismatch on \" + propertyName);","typeGuard":null,"tryCatchPattern":"try { Schema.of(MyBean.class); } catch (RuntimeException e) { if (e.getMessage().contains(\"mismatching nullable\")) { /* align @Nullable annotations */ } throw e; }","preventionTips":["Annotate both accessors whenever a property is nullable.","Use boxed types for nullable properties on both accessors.","Keep @Nullable on the field and mirror it in generated accessors."],"tags":["java","javabean","schema","nullability"],"backgroundTag":"schema-validation-failed","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"}