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}, sinceView on GitHub (pinned to 820761864e)
Solutions
- Verify no mixed versions of pulsar-client jars on the classpath.
- Disable bytecode instrumentation/shading plugins that could modify pulsar-client classes and retry.
- 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
- Avoid mixed pulsar-client jar versions in fat jars.
- Disable instrumentation that alters Cloneable semantics on library classes.
- If seen reproducibly, report upstream.
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
- Failed to clone ConsumerConfigurationData
- Failed to clone ReaderConfigurationData
- Failed to clone ClientConfigurationData
- numPartitionsLimit should be greater than or equal to 1
- maxMessages must be >= 0
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/80cfb6fb6d346f8f.
Report an issue: GitHub.