{"record":{"id":"a7993ee96ba03521","repo":"apache/pulsar","slug":"unknown-resource-type","errorCode":null,"errorMessage":"Unknown resource type: ","messagePattern":"Unknown resource type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientSharedResourcesBuilderImpl.java","lineNumber":282,"sourceCode":"\n    @SuppressWarnings(\"unchecked\")\n    private <T extends ResourceConfig> T getOrCreateConfig(PulsarClientSharedResources.SharedResource sharedResource) {\n        return (T) resourceConfigs.computeIfAbsent(sharedResource, k -> {\n            switch (sharedResource.getType()) {\n                case EventLoopGroup:\n                    return new EventLoopResourceConfig();\n                case DnsResolver:\n                    return new DnsResolverResourceConfig();\n                case ThreadPool:\n                    return new ThreadPoolResourceConfig();\n                case Timer:\n                    return new TimerResourceConfig();\n                case MemoryLimitController:\n                    return new MemoryLimitResourceConfig();\n                case OpenTelemetry:\n                    return new OpenTelemetryResourceConfig();\n                default:\n                    throw new IllegalArgumentException(\"Unknown resource type: \" + sharedResource.getType());\n            }\n        });\n    }\n\n    @Override\n    public PulsarClientSharedResourcesBuilder configureThreadPool(\n            PulsarClientSharedResources.SharedResource sharedResource, Consumer<ThreadPoolConfig<?>> configurer) {\n        if (sharedResource.getType() != PulsarClientSharedResources.SharedResourceType.ThreadPool) {\n            throw new IllegalArgumentException(\"The shared resource \" + sharedResource + \" doesn't support thread pool\"\n                    + \" configuration\");\n        }\n        configurer.accept(getOrCreateConfig(sharedResource));\n        return this;\n    }\n\n    @Override\n    public PulsarClientSharedResourcesBuilder configureEventLoop(Consumer<EventLoopGroupConfig> configurer) {\n        configurer.accept(getOrCreateConfig(PulsarClientSharedResources.SharedResource.EventLoopGroup));","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientSharedResourcesBuilderImpl.java#L264-L300","documentation":"getOrCreateConfig maps a SharedResource to its default ResourceConfig via a switch over SharedResourceType. A resource whose type is not one of the six known types (EventLoopGroup, DnsResolver, ThreadPool, Timer, MemoryLimitController, OpenTelemetry) reaches the default branch and throws IllegalArgumentException.","triggerScenarios":"Passing a SharedResource with a custom or unrecognized SharedResourceType to any configure* method (configureThreadPool, configureEventLoop, configureDnsResolver, configureTimer, configureMemoryLimitController, configureOpenTelemetry), typically because a SharedResource from a newer Pulsar version or a user-defined type is fed to an older builder.","commonSituations":"Upgrading/downgrading Pulsar client so a SharedResourceType enum constant exists in one jar but not the other; constructing a SharedResource with a hand-rolled type instead of using the provided constants; mixing client versions on the classpath (shaded vs non-shaded jars).","solutions":["Use only the built-in SharedResource constants/types from the same Pulsar version as the client library (check PulsarClientSharedResources.SharedResourceType).","Align all Pulsar client jar versions on the classpath; duplicate shaded/unshaded jars cause enum mismatch.","Verify with a debug print that sharedResource.getType() is a known SharedResourceType before calling the configure method.","Upgrade the client library if the resource type is a newer addition not present in your current version."],"exampleFix":"// before\nSharedResource custom = SharedResource.of(myCustomType, \"mine\"); // custom type\nbuilder.configureThreadPool(custom, cfg -> ...); // throws Unknown resource type\n// after\nbuilder.configureThreadPool(PulsarClientSharedResources.THREAD_POOL, cfg -> ...);","handlingStrategy":"validation","validationCode":"PulsarClientSharedResources.SharedResourceType t = resource.getType();\nboolean known = t == SharedResourceType.EventLoopGroup || t == SharedResourceType.DnsResolver\n    || t == SharedResourceType.ThreadPool || t == SharedResourceType.Timer\n    || t == SharedResourceType.MemoryLimitController || t == SharedResourceType.OpenTelemetry;\nif (!known) throw new IllegalArgumentException(\"Unsupported shared resource type: \" + t);","typeGuard":"static boolean isKnownResourceType(PulsarClientSharedResources.SharedResource r) {\n    switch (r.getType()) {\n        case EventLoopGroup: case DnsResolver: case ThreadPool:\n        case Timer: case MemoryLimitController: case OpenTelemetry:\n            return true;\n        default:\n            return false;\n    }\n}","tryCatchPattern":"try {\n    builder.configureEventLoop(cfg -> cfg.numThreads(8));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unknown resource type\")) {\n        log.error(\"SharedResource type not supported by this client version: {}\", e.getMessage());\n    } else { throw e; }\n}","preventionTips":["Only use SharedResource constants shipped with the same Pulsar client version you compile against.","Check for duplicate/shaded pulsar-client jars on the classpath that could shadow enum values.","When upgrading, diff SharedResourceType enums between versions before feeding resources to configure* methods.","Never define custom SharedResourceType values; the builder switch cannot handle them."],"tags":["pulsar","client","illegal-argument","enum"],"backgroundTag":"unknown-resource-type","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}