{"record":{"id":"d6eb7b756a085541","repo":"apache/pulsar","slug":"no-resources-have-been-configured-while-using-shar","errorCode":null,"errorMessage":"No resources have been configured while using shareConfigured mode","messagePattern":"No resources have been configured while using shareConfigured mode","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientSharedResourcesImpl.java","lineNumber":65,"sourceCode":"public class PulsarClientSharedResourcesImpl implements PulsarClientSharedResources {\n    Set<SharedResource> sharedResources;\n    protected final EventLoopGroup ioEventLoopGroup;\n    private final ExecutorProvider internalExecutorProvider;\n    private final ExecutorProvider externalExecutorProvider;\n    private final ScheduledExecutorProvider scheduledExecutorProvider;\n    private final Timer timer;\n    private final ExecutorProvider lookupExecutorProvider;\n    private final DnsResolverGroupImpl dnsResolverGroup;\n    private final MemoryLimitController memoryLimitController;\n    private final InstrumentProvider instrumentProvider;\n    private final MemoryBufferStats memoryBufferStats;\n\n    public PulsarClientSharedResourcesImpl(Set<SharedResource> sharedResources,\n                                           Map<SharedResource, PulsarClientSharedResourcesBuilderImpl.ResourceConfig>\n                                                   resourceConfigs, boolean shareConfigured) {\n        if (shareConfigured) {\n            if (resourceConfigs.isEmpty()) {\n                throw new IllegalArgumentException(\n                        \"No resources have been configured while using shareConfigured mode\");\n            }\n            this.sharedResources = Set.copyOf(resourceConfigs.keySet());\n        } else {\n            if (sharedResources.isEmpty()) {\n                this.sharedResources = EnumSet.allOf(SharedResource.class);\n            } else {\n                this.sharedResources = Set.copyOf(sharedResources);\n            }\n        }\n        this.ioEventLoopGroup = this.sharedResources.contains(SharedResource.EventLoopGroup)\n                ? createEventLoopGroupWithResourceConfig(\n                getResourceConfig(resourceConfigs, SharedResource.EventLoopGroup))\n                : null;\n        this.externalExecutorProvider = this.sharedResources.contains(SharedResource.ListenerExecutor)\n                ? createExternalExecutorProviderWithResourceConfig(\n                getResourceConfig(resourceConfigs, SharedResource.ListenerExecutor))\n                : null;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientSharedResourcesImpl.java#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Configure at least one shared resource via PulsarClientSharedResourcesBuilder before using shareConfigured mode","If no configuration is needed, disable shareConfigured mode (share default resources instead)","Verify the code path that sets shareConfigured actually runs the corresponding configure* builder calls"],"exampleFix":"// before\nPulsarClientSharedResources resources = new PulsarClientSharedResourcesBuilderImpl()\n        .shareConfigured(true)   // nothing configured -> throws\n        .build();\n// after\nPulsarClientSharedResources resources = new PulsarClientSharedResourcesBuilderImpl()\n        .configureIo(conf -> conf.setIoThreads(4))\n        .shareConfigured(true)\n        .build();","handlingStrategy":"validation","validationCode":"if (shareConfigured && resourceConfigs.isEmpty()) {\n    throw new IllegalStateException(\"shareConfigured=true requires at least one configured shared resource\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    PulsarClientSharedResources res = new PulsarClientSharedResourcesImpl(sharedResources, resourceConfigs, shareConfigured);\n} catch (IllegalArgumentException e) {\n    log.warn(\"shareConfigured mode enabled but no resources configured; falling back to defaults\", e);\n    res = new PulsarClientSharedResourcesImpl(sharedResources, resourceConfigs, false);\n}","preventionTips":["Tie the shareConfigured flag and the configure* calls together in one builder method","Log the set of configured shared resources at client construction time","Fail fast at startup when shareConfigured=true and configs are empty"],"tags":["java","pulsar-client","configuration","illegal-argument"],"backgroundTag":"empty-configuration-not-allowed","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}