{"record":{"id":"a4f723cbc240e2ef","repo":"binarywang/WxJava","slug":"http-requesttype-a4f723","errorCode":null,"errorMessage":"不支持的http执行器类型：{requestType}","messagePattern":"不支持的http执行器类型：(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutor.java","lineNumber":55,"sourceCode":"   *\n   * @param requestHttp 请求信息\n   * @return 执行器\n   */\n  @SuppressWarnings(\"unchecked\")\n  public static RequestExecutor<String, CommonUploadParam> create(RequestHttp<?, ?> requestHttp) {\n    switch (requestHttp.getRequestType()) {\n      case APACHE_HTTP:\n        return new CommonUploadRequestExecutorApacheImpl(\n          (RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);\n      case JODD_HTTP:\n        return new CommonUploadRequestExecutorJoddHttpImpl((RequestHttp<HttpConnectionProvider, ProxyInfo>) requestHttp);\n      case OK_HTTP:\n        return new CommonUploadRequestExecutorOkHttpImpl((RequestHttp<OkHttpClient, OkHttpProxyInfo>) requestHttp);\n      case HTTP_COMPONENTS:\n        return new CommonUploadRequestExecutorHttpComponentsImpl(\n          (RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp);\n      default:\n        throw new IllegalArgumentException(\"不支持的http执行器类型：\" + requestHttp.getRequestType());\n    }\n  }\n}\n","sourceCodeStart":37,"sourceCodeEnd":59,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutor.java#L37-L59","documentation":"CommonUploadRequestExecutor.create handles all four HttpClientType values (APACHE_HTTP, JODD_HTTP, OK_HTTP, HTTP_COMPONENTS), so the default branch is a forward-compatibility guard. It only fires if a new HttpClientType enum constant is added without a matching case, or a custom RequestHttp returns an unrecognised type.","triggerScenarios":"A future WxJava version adds a new HttpClientType without updating this switch; or a custom RequestHttp subclass returns a type string/enum not among the four known values.","commonSituations":"Upgrading WxJava to a version that introduced a new client type while your code still pins an older executor; subclassing RequestHttp in a non-standard way.","solutions":["Keep WxJava modules in sync (same version across all modules and BOM) so executor factories and enum stay aligned.","Avoid custom RequestHttp subclasses that return fabricated RequestType values; use the built-in client types.","If hit on upgrade, update all modules to the matching release that includes the new case."],"exampleFix":"// before — mixed versions\n// common 4.6 + an older module that only knows 3 client types\n\n// after — align via BOM\n<dependencyManagement>\n  <dependency>\n    <groupId>com.github.binarywang</groupId>\n    <artifactId>wx-java-bom</artifactId>\n    <version>${wx-java.version}</version>\n    <type>pom</type>\n    <scope>import</scope>\n  </dependency>\n</dependencyManagement>","handlingStrategy":"try-catch","validationCode":"// Keep all WxJava modules on the same version via the BOM so the switch and enum stay in sync.\n// No runtime validation needed unless you use a custom RequestHttp.","typeGuard":"private static boolean knownUploadExecutorType(RequestHttp<?,?> http) {\n  HttpClientType t = http.getRequestType();\n  return t == HttpClientType.APACHE_HTTP || t == HttpClientType.JODD_HTTP\n      || t == HttpClientType.OK_HTTP || t == HttpClientType.HTTP_COMPONENTS;\n}","tryCatchPattern":"try {\n  service.upload(param);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"不支持的http执行器类型\")) {\n    // align WxJava module versions via BOM, or stop using custom RequestHttp\n  }\n  throw e;\n}","preventionTips":["Import wx-java-bom so all modules share one version.","Avoid custom RequestHttp subclasses returning non-standard RequestType values.","On upgrade, verify executor factories cover all enum constants you use."],"tags":["http-client","upload","version-mismatch","unsupported-executor"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}