apache/pulsar · error · IllegalArgumentException

An error occurred while processing the field: ${f.getName()}

Error message

An error occurred while processing the field: ${f.getName()}

What it means

OffloadPoliciesImpl.toProperties() reflects over every field of the offload policies object and copies it into a Properties map. If reflective access on any field throws (IllegalAccessException, unexpected getter/value problems), it is wrapped in this IllegalArgumentException naming the offending field. It indicates the policies object is in a state reflection cannot serialize, not a data-value problem.

Source

Thrown at pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/OffloadPoliciesImpl.java:371

        return false;
    }

    public Properties toProperties() {
        Properties properties = new Properties();
        for (Field f : CONFIGURATION_FIELDS) {
            try {
                f.setAccessible(true);
                if ("managedLedgerExtraConfigurations".equals(f.getName())) {
                    @SuppressWarnings("unchecked") // field type is Map<String, String>
                    Map<String, String> extraConfig = (Map<String, String>) f.get(this);
                    extraConfig.forEach((key, value) -> {
                        setProperty(properties, EXTRA_CONFIG_PREFIX + key, value);
                    });
                } else {
                    setProperty(properties, f.getName(), f.get(this));
                }
            } catch (Exception e) {
                throw new IllegalArgumentException("An error occurred while processing the field: " + f.getName(), e);
            }
        }
        return properties;
    }

    private static void setProperty(Properties properties, String key, Object value) {
        if (value != null) {
            properties.setProperty(key, "" + value);
        }
    }

    @Target(ElementType.FIELD)
    @Retention(RetentionPolicy.RUNTIME)
    private @interface Configuration {

    }

    /**

View on GitHub (pinned to 820761864e)

Solutions

  1. Identify the field named in the message and check its getter/initialization for throwing code
  2. Construct OffloadPoliciesImpl via its builder/setters rather than subclassing or proxying it
  3. Run on a JDK where reflective access to pulsar-common classes is permitted; add --add-opens if module access errors occur
  4. Update to a recent Pulsar version where offload policy serialization is more robust

Example fix

// before
OffloadPoliciesImpl policies = new OffloadPoliciesImpl() { /* anonymous subclass breaks reflection */ };
Properties props = policies.toProperties();
// after
OffloadPoliciesImpl policies = OffloadPoliciesImpl.builder()
    .bucket("my-bucket").region("us-east-1").build();
Properties props = policies.toProperties();
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the instance is a plain OffloadPoliciesImpl built via builder/setters
if (!(policies instanceof OffloadPoliciesImpl) || policies.getClass() != OffloadPoliciesImpl.class) {
    throw new IllegalStateException("Use a non-proxied OffloadPoliciesImpl for toProperties()");
}

Type guard

static boolean isPlainOffloadPolicies(Object o) {
    return o != null && o.getClass() == OffloadPoliciesImpl.class;
}

Try / catch

try {
    Properties props = policies.toProperties();
} catch (IllegalArgumentException e) {
    log.error("Offload policy field failed: {}", e.getMessage(), e.getCause());
    throw new ConfigException("Invalid offload policies configuration", e);
}

Prevention

When it happens

Trigger: Calling toProperties() on an OffloadPoliciesImpl instance where a field's getter throws or is inaccessible — e.g. a subclassed/anonymized instance, a field with a throwing custom getter, or reflection restrictions (Java module system / SecurityManager) blocking f.get(this).

Common situations: Programmatic construction of offload policies with unusual field values, running on newer JDKs with strict module access, or frameworks wrapping the policy object in a proxy before calling config serialization.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/9865631d98141d80. Report an issue: GitHub.