{"record":{"id":"94d64e3ae79270a4","repo":"binarywang/WxJava","slug":"http-requesttype","errorCode":null,"errorMessage":"不支持的http执行器类型：{requestType}","messagePattern":"不支持的http执行器类型：(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelFileUploadRequestExecutor.java","lineNumber":31,"sourceCode":"public abstract class ChannelFileUploadRequestExecutor<H, P> implements RequestExecutor<String, File> {\n\n  protected RequestHttp<H, P> requestHttp;\n\n  public ChannelFileUploadRequestExecutor(RequestHttp<H, P> requestHttp) {\n    this.requestHttp = requestHttp;\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  public static RequestExecutor<String, File> create(RequestHttp<?, ?> requestHttp) {\n    switch (requestHttp.getRequestType()) {\n      case APACHE_HTTP:\n        return new ApacheHttpChannelFileUploadRequestExecutor(\n          (RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);\n      case HTTP_COMPONENTS:\n        return new HttpComponentsChannelFileUploadRequestExecutor(\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}\n","sourceCodeStart":13,"sourceCodeEnd":36,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelFileUploadRequestExecutor.java#L13-L36","documentation":"ChannelFileUploadRequestExecutor.create switches on the configured HttpClientType and only provides implementations for APACHE_HTTP and HTTP_COMPONENTS (Apache HttpClient 4.x and 5.x). Any other client type — JODD_HTTP or OK_HTTP — falls through to the default branch and throws. The Channel module simply does not ship Jodd/OkHttp upload executors.","triggerScenarios":"The WxChannelService is configured with an OkHttp or Jodd RequestHttp backend, and a file upload API (any method routed through ChannelFileUploadRequestExecutor) is invoked.","commonSituations":"Sharing an HTTP client config across modules where MP/MiniApp support OkHttp/Jodd but Channel does not; upgrading a multi-module app to OkHttp without checking Channel upload coverage.","solutions":["Configure the Channel service with Apache HttpClient 4.x (APACHE_HTTP) or 5.x (HTTP_COMPONENTS) as its RequestHttp backend.","If you must use a different client for other modules, give the Channel service its own dedicated Apache-based WxHttpClient.","Check requestHttp.getRequestType() at startup and fail fast with a clear message if it is not supported for uploads."],"exampleFix":"// before — shared OkHttp config breaks channel uploads\nWxChannelService service = new WxChannelServiceImpl();\nservice.setWxHttpService(okHttpService); // OK_HTTP\nservice.uploadFile(...); // throws\n\n// after — Apache HttpClient for channel\nservice.setWxHttpService(apacheHttpService); // APACHE_HTTP\nservice.uploadFile(...);","handlingStrategy":"validation","validationCode":"Set<HttpClientType> supported = EnumSet.of(HttpClientType.APACHE_HTTP, HttpClientType.HTTP_COMPONENTS);\nif (!supported.contains(requestHttp.getRequestType())) {\n  throw new IllegalStateException(\"Channel file upload requires Apache HttpClient, got \" + requestHttp.getRequestType());\n}","typeGuard":"private static boolean channelUploadSupported(RequestHttp<?,?> http) {\n  HttpClientType t = http.getRequestType();\n  return t == HttpClientType.APACHE_HTTP || t == HttpClientType.HTTP_COMPONENTS;\n}","tryCatchPattern":"try {\n  service.uploadFile(...);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"不支持的http执行器类型\")) {\n    // switch the Channel service to Apache HttpClient\n  }\n  throw e;\n}","preventionTips":["Give the Channel service a dedicated Apache HttpClient (4.x or 5.x) backend.","Do not share OkHttp/Jodd config with the Channel module.","Assert the client type at startup, before the first upload."],"tags":["http-client","channel","upload","configuration","unsupported-executor"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}