apache/pulsar · error · IllegalArgumentException

No resources have been configured while using shareConfigure

Error message

No resources have been configured while using shareConfigured mode

What it means

When constructing PulsarClientSharedResources in shareConfigured mode, the client shares only the resources that were explicitly configured. If no resource was configured at all, there is nothing to share, so the constructor refuses to proceed with this IllegalArgumentException.

Source

Thrown at pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientSharedResourcesImpl.java:65

public class PulsarClientSharedResourcesImpl implements PulsarClientSharedResources {
    Set<SharedResource> sharedResources;
    protected final EventLoopGroup ioEventLoopGroup;
    private final ExecutorProvider internalExecutorProvider;
    private final ExecutorProvider externalExecutorProvider;
    private final ScheduledExecutorProvider scheduledExecutorProvider;
    private final Timer timer;
    private final ExecutorProvider lookupExecutorProvider;
    private final DnsResolverGroupImpl dnsResolverGroup;
    private final MemoryLimitController memoryLimitController;
    private final InstrumentProvider instrumentProvider;
    private final MemoryBufferStats memoryBufferStats;

    public PulsarClientSharedResourcesImpl(Set<SharedResource> sharedResources,
                                           Map<SharedResource, PulsarClientSharedResourcesBuilderImpl.ResourceConfig>
                                                   resourceConfigs, boolean shareConfigured) {
        if (shareConfigured) {
            if (resourceConfigs.isEmpty()) {
                throw new IllegalArgumentException(
                        "No resources have been configured while using shareConfigured mode");
            }
            this.sharedResources = Set.copyOf(resourceConfigs.keySet());
        } else {
            if (sharedResources.isEmpty()) {
                this.sharedResources = EnumSet.allOf(SharedResource.class);
            } else {
                this.sharedResources = Set.copyOf(sharedResources);
            }
        }
        this.ioEventLoopGroup = this.sharedResources.contains(SharedResource.EventLoopGroup)
                ? createEventLoopGroupWithResourceConfig(
                getResourceConfig(resourceConfigs, SharedResource.EventLoopGroup))
                : null;
        this.externalExecutorProvider = this.sharedResources.contains(SharedResource.ListenerExecutor)
                ? createExternalExecutorProviderWithResourceConfig(
                getResourceConfig(resourceConfigs, SharedResource.ListenerExecutor))
                : null;

View on GitHub (pinned to 820761864e)

Solutions

  1. Configure at least one shared resource via PulsarClientSharedResourcesBuilder before using shareConfigured mode
  2. If no configuration is needed, disable shareConfigured mode (share default resources instead)
  3. Verify the code path that sets shareConfigured actually runs the corresponding configure* builder calls

Example fix

// before
PulsarClientSharedResources resources = new PulsarClientSharedResourcesBuilderImpl()
        .shareConfigured(true)   // nothing configured -> throws
        .build();
// after
PulsarClientSharedResources resources = new PulsarClientSharedResourcesBuilderImpl()
        .configureIo(conf -> conf.setIoThreads(4))
        .shareConfigured(true)
        .build();
Defensive patterns

Strategy: validation

Validate before calling

if (shareConfigured && resourceConfigs.isEmpty()) {
    throw new IllegalStateException("shareConfigured=true requires at least one configured shared resource");
}

Try / catch

try {
    PulsarClientSharedResources res = new PulsarClientSharedResourcesImpl(sharedResources, resourceConfigs, shareConfigured);
} catch (IllegalArgumentException e) {
    log.warn("shareConfigured mode enabled but no resources configured; falling back to defaults", e);
    res = new PulsarClientSharedResourcesImpl(sharedResources, resourceConfigs, false);
}

Prevention

When it happens

Trigger: Calling PulsarClientImpl constructor or client builder with sharedResources(shareConfigured=true) (via PulsarClientSharedResources sharing options) while never having called any configureXxx method on PulsarClientSharedResourcesBuilder, so resourceConfigs is empty.

Common situations: Enabling the shareConfigured flag in config but forgetting to actually configure the shared IO/memory/thread-pool resources; a builder chain where the configure calls were accidentally removed or conditionally skipped (e.g. an empty properties file).

Related errors


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