{"record":{"id":"b5b9fb51b23b5f67","repo":"quarkusio/quarkus","slug":"executorservice-must-not-be-null","errorCode":null,"errorMessage":"ExecutorService must not be null","messagePattern":"ExecutorService must not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java","lineNumber":246,"sourceCode":"    }\n\n    @Override\n    public RestClientBuilder keyStore(KeyStore keyStore, String keystorePassword) {\n        this.keyStore = keyStore;\n        this.keystorePassword = keystorePassword;\n        return this;\n    }\n\n    @Override\n    public RestClientBuilder hostnameVerifier(HostnameVerifier hostnameVerifier) {\n        this.hostnameVerifier = hostnameVerifier;\n        return this;\n    }\n\n    @Override\n    public RestClientBuilder executorService(ExecutorService executor) {\n        if (executor == null) {\n            throw new IllegalArgumentException(\"ExecutorService must not be null\");\n        }\n        executorService = ContextualExecutors.wrap(executor);\n        return this;\n    }\n\n    public <T> T build(Class<T> aClass, ClientHttpEngine httpEngine)\n            throws IllegalStateException, RestClientDefinitionException {\n\n        RestClientListeners.get().forEach(listener -> listener.onNewClient(aClass, this));\n\n        // Interface validity\n        verifyInterface(aClass);\n\n        if (baseURI == null) {\n            throw new IllegalStateException(\"Neither baseUri nor baseUrl was specified\");\n        }\n\n        // Provider annotations","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java#L228-L264","documentation":"Thrown by QuarkusRestClientBuilder.executorService when a null ExecutorService is passed. The builder wraps the executor with ContextualExecutors so async calls run with proper context propagation, and a null executor has no valid meaning.","triggerScenarios":"Calling builder.executorService(null); passing an executor field/lookup result that resolved to null (e.g. container-managed executor not available, failed JNDI/CDI lookup).","commonSituations":"Programmatic client building in tests where an executor mock wasn't wired; relying on a ManagedExecutorService that isn't injected; refactor leaving the executor uninitialized.","solutions":["Pass a non-null ExecutorService, e.g. a ManagedExecutor or Executors.newFixedThreadPool(...)","Use Quarkus's ManagedExecutor injection (io.quarkus.threadpool.ThreadPoolConfig managed executor) instead of building one by hand","Omit the executorService call entirely and let the builder use its default executor"],"exampleFix":"// before\nExecutorService exec = lookupExecutor(); // may return null\nbuilder.executorService(exec); // IllegalArgumentException\n// after\nExecutorService exec = lookupExecutor();\nif (exec != null) {\n    builder.executorService(exec);\n}","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(executor, \"ExecutorService must not be null\");","typeGuard":null,"tryCatchPattern":"try {\n    builder.executorService(exec);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"ExecutorService must not be null\")) {\n        builder.executorService(Executors.newFixedThreadPool(4));\n    } else {\n        throw e;\n    }\n}","preventionTips":["Use Quarkus ManagedExecutor injection to guarantee a non-null executor","Skip the executorService call to use the builder default","Null-check any lazily resolved executor before passing it"],"tags":["rest-client","executor","async","illegal-argument"],"backgroundTag":"null-argument-validation","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}