apache/beam · error · RuntimeException

Java Bean ' ' contains a setter for field ' ' that has a…

Error message

Java Bean '%s' contains a setter for field '%s' that has a mismatching nullable attribute. %s

What it means

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.

Solutions

  1. Annotate both getter and setter (parameter) consistently with @Nullable — or remove it from both.
  2. Ensure nullable fields use boxed types (Integer, not int) on both accessors.
  3. If using Lombok, put @Nullable on the field so both generated accessors inherit it where applicable.

Example fix

// before
@Nullable public String getEmail() {...} public void setEmail(String e) {...}
// after
@Nullable public String getEmail() {...} public void setEmail(@Nullable String e) {...}
Defensive patterns

Strategy: validation

Validate before calling

Method g = ..., s = ...;
boolean gNull = g.getAnnotation(Nullable.class) != null; boolean sNull = s.getParameters()[0].getAnnotation(Nullable.class) != null;
if (gNull != sNull) throw new IllegalStateException("@Nullable mismatch on " + propertyName);

Try / catch

try { Schema.of(MyBean.class); } catch (RuntimeException e) { if (e.getMessage().contains("mismatching nullable")) { /* align @Nullable annotations */ } throw e; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/382ee0adcc4923dd. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java:122

    for (FieldValueTypeInformation type : getters) {
      FieldValueTypeInformation setterType = setterMap.get(type.getName());
      Method m =
          Preconditions.checkArgumentNotNull(type.getMethod(), GETTER_WITH_NULL_METHOD_ERROR);
      if (setterType == null) {
        throw new RuntimeException(
            String.format(
                "Java Bean '%s' contains a getter for field '%s', but does not contain a matching"
                    + " setter. %s",
                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));
      }
      if (!type.getType().equals(setterType.getType())) {
        throw new RuntimeException(
            String.format(
                "Java Bean '%s' contains a setter for field '%s' that has a mismatching type. %s",
                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));
      }
      if (!type.isNullable() == setterType.isNullable()) {
        throw new RuntimeException(
            String.format(
                "Java Bean '%s' contains a setter for field '%s' that has a mismatching nullable"
                    + " attribute. %s",
                m.getDeclaringClass(), type.getName(), CONSTRUCTOR_HELP_STRING));
      }
    }
  }

  // Static ByteBuddy instance used by all helpers.
  private static final ByteBuddy BYTE_BUDDY = new ByteBuddy();

  private static final Map<TypeDescriptorWithSchema<?>, List<FieldValueTypeInformation>>
      CACHED_FIELD_TYPES = Maps.newConcurrentMap();

  public static List<FieldValueTypeInformation> getFieldTypes(
      TypeDescriptor<?> typeDescriptor,
      Schema schema,
      FieldValueTypeSupplier fieldValueTypeSupplier) {

View on GitHub (pinned to 12126d8942)