apache/pulsar · error · RuntimeException

Failed to clone ConsumerConfigurationData

Error message

Failed to clone ConsumerConfigurationData

What it means

ConsumerConfigurationData.clone() calls super.clone() inside a try-catch for CloneNotSupportedException and rethrows it as this RuntimeException. In practice Object.clone() never throws CloneNotSupportedException here because ConsumerConfigurationData implements Cloneable, so this is a defensive, effectively-unreachable guard failure.

Source

Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ConsumerConfigurationData.java:463

        checkArgument(interval > 0, "interval needs to be > 0");
        this.autoUpdatePartitionsIntervalSeconds = timeUnit.toSeconds(interval);
    }

    @JsonIgnore
    public String getSingleTopic() {
        checkArgument(topicNames.size() == 1, "topicNames needs to be = 1");
        return topicNames.iterator().next();
    }

    public ConsumerConfigurationData<T> clone() {
        try {
            @SuppressWarnings("unchecked")
            ConsumerConfigurationData<T> c = (ConsumerConfigurationData<T>) super.clone();
            c.topicNames = Sets.newTreeSet(this.topicNames);
            c.properties = new TreeMap<>(this.properties);
            return c;
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException("Failed to clone ConsumerConfigurationData");
        }
    }

    /**
     * Backward compatibility with the old `replicateSubscriptionState` field.
     * @deprecated Using {@link #getReplicateSubscriptionState()} instead.
     */
    @JsonIgnore
    @Deprecated
    public boolean isReplicateSubscriptionState() {
        return replicateSubscriptionState != null && replicateSubscriptionState;
    }
}

View on GitHub (pinned to 820761864e)

Solutions

  1. Check for bytecode instrumentation agents or shading that could strip/alter the Cloneable interface.
  2. Ensure the client jar and its dependencies come from the same Pulsar version (no mixed-jar classpath corruption).
  3. Rebuild/verify the class against the official artifact; report to Pulsar if reproducible on a clean classpath.
Defensive patterns

Strategy: try-catch

Try / catch

try { ConsumerConfigurationData<T> copy = conf.clone(); } catch (RuntimeException e) { /* defensive clone failure: rebuild conf manually */ }

Prevention

When it happens

Trigger: Called by cloneConf() and createInternalConsumer() when a MultiTopicsConsumerImpl/Reader-based internal consumer needs a defensive copy of its configuration. Only fires if the JVM considers the class non-Cloneable (a bug/JVM-level anomaly, not user input).

Common situations: Essentially only seen when constructing a multi-topic consumer or reader from ConsumerConfigurationData if the runtime environment is inconsistent (incompatible bytecode weaving/agent corrupting class flags).

Related errors


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