apache/pulsar · warning · RuntimeException

Failed to clone ClientConfigurationData

Error message

Failed to clone ClientConfigurationData

What it means

ClientConfigurationData.clone() relies on Object.clone() (the class implements Cloneable). CloneNotSupportedException is theoretically impossible for a Cloneable class, but clone() still wraps it in a RuntimeException "Failed to clone ClientConfigurationData" as a defensive measure. Called by PulsarChannelInitializer when it needs a per-connection copy of the config.

Source

Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ClientConfigurationData.java:606

     *
     * @param out the object output stream
     * @throws IOException if the configuration cannot be written
     */
    private void writeObject(java.io.ObjectOutputStream out) throws IOException {
        if (v5Authentication != null && StringUtils.isBlank(authPluginClassName)) {
            throw new NotSerializableException("A v5 authentication plugin ("
                    + v5Authentication.getClass().getName() + ") cannot be serialized with the client "
                    + "configuration. Configure authentication with authPluginClassName + authParams instead "
                    + "of a pre-built plugin instance when the configuration has to cross a boundary.");
        }
        out.defaultWriteObject();
    }

    public ClientConfigurationData clone() {
        try {
            return (ClientConfigurationData) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException("Failed to clone ClientConfigurationData");
        }
    }

    public InetSocketAddress getSocks5ProxyAddress() {
        if (Objects.nonNull(socks5ProxyAddress)) {
            return socks5ProxyAddress;
        }
        String proxyAddress = System.getProperty("socks5Proxy.address");
        return Optional.ofNullable(proxyAddress).map(address -> {
            try {
                URI uri = URI.create(address);
                return new InetSocketAddress(uri.getHost(), uri.getPort());
            } catch (Exception e) {
                throw new RuntimeException("Invalid config [socks5Proxy.address]", e);
            }
        }).orElse(null);
    }

View on GitHub (pinned to 820761864e)

Solutions

  1. Verify ClientConfigurationData still implements Cloneable in your build (no shading/bytecode issue).
  2. Update/repair the Pulsar client jar — a stock build cannot trigger this path.
  3. If it reproduces with an agent installed, exclude the pulsar-client classes from instrumentation.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    ClientConfigurationData copy = conf.clone();
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().equals("Failed to clone ClientConfigurationData")) {
        // bytecode/agent or shading issue; rebuild config manually
    } else throw e;
}

Prevention

When it happens

Trigger: Practically unreachable: it fires only if super.clone() throws CloneNotSupportedException, which would mean the class lost its Cloneable marker (e.g. bytecode manipulation, unusual classloading, or a fork removing 'implements Cloneable').

Common situations: Agent/bytecode-weaving tools or shaded builds interfering with class metadata; custom forks of Pulsar that altered the class hierarchy.

Related errors


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