apache/pulsar · error · RuntimeException

Failed to clone ProducerConfigurationData

Error message

Failed to clone ProducerConfigurationData

What it means

ProducerConfigurationData.clone() performs a deep copy of encryptionKeys and properties and wraps the theoretically-impossible CloneNotSupportedException in this RuntimeException. Like the consumer variant, it is a defensive guard that should not fire for correctly built jars.

Source

Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ProducerConfigurationData.java:265

    /**
     *
     * Returns true if encryption keys are added.
     *
     */
    @JsonIgnore
    public boolean isEncryptionEnabled() {
        return (this.encryptionKeys != null) && !this.encryptionKeys.isEmpty() && (this.cryptoKeyReader != null);
    }

    public ProducerConfigurationData clone() {
        try {
            ProducerConfigurationData c = (ProducerConfigurationData) super.clone();
            c.encryptionKeys = Sets.newTreeSet(this.encryptionKeys);
            c.properties = new TreeMap<>(this.properties);
            return c;
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException("Failed to clone ProducerConfigurationData", e);
        }
    }

    public void setProducerName(String producerName) {
        checkArgument(StringUtils.isNotBlank(producerName), "producerName cannot be blank");
        this.producerName = producerName;
    }

    public void setMaxPendingMessages(int maxPendingMessages) {
        checkArgument(maxPendingMessages >= 0, "maxPendingMessages needs to be >= 0");
        this.maxPendingMessages = maxPendingMessages;
        this.maxPendingMessagesConfigured = true;
    }

    /**
     * The across-partitions budget used to be rejected when it was below {@link #maxPendingMessages},
     * which made the two setters order-dependent: it depended on which of them had been called first,
     * and it made {@code loadConf} fail outright for any positive {@code maxPendingMessages}, since

View on GitHub (pinned to 820761864e)

Solutions

  1. Verify no mixed versions of pulsar-client jars on the classpath.
  2. Disable bytecode instrumentation/shading plugins that could modify pulsar-client classes and retry.
  3. If reproducible on a clean classpath, file a bug with the Pulsar project.
Defensive patterns

Strategy: try-catch

Try / catch

try { ProducerConfigurationData copy = conf.clone(); } catch (RuntimeException e) { /* rebuild conf via copy constructor semantics */ }

Prevention

When it happens

Trigger: Triggered by resolved() when ProducerImpl/PulsarClient prepares the final producer configuration and needs a defensive copy of ProducerConfigurationData.

Common situations: Only realistically hit under classpath corruption, shading issues, or bytecode agents altering the class hierarchy.

Related errors


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