{"record":{"id":"27c15379317b9a46","repo":"binarywang/WxJava","slug":"http-requesttype-27c153","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/ChannelMediaDownloadRequestExecutor.java","lineNumber":45,"sourceCode":"\n  private static final Pattern PATTERN = Pattern.compile(\".*filename=\\\"(.*)\\\"\");\n\n  public ChannelMediaDownloadRequestExecutor(RequestHttp<H, P> requestHttp, File tmpDirFile) {\n    this.requestHttp = requestHttp;\n    this.tmpDirFile = tmpDirFile;\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  public static RequestExecutor<ChannelImageResponse, String> create(RequestHttp<?, ?> requestHttp, File tmpDirFile) {\n    switch (requestHttp.getRequestType()) {\n      case APACHE_HTTP:\n        return new ApacheHttpChannelMediaDownloadRequestExecutor(\n          (RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp, tmpDirFile);\n      case HTTP_COMPONENTS:\n        return new HttpComponentsChannelMediaDownloadRequestExecutor(\n          (RequestHttp<org.apache.hc.client5.http.impl.classic.CloseableHttpClient, org.apache.hc.core5.http.HttpHost>) requestHttp, tmpDirFile);\n      default:\n        throw new IllegalArgumentException(\"不支持的http执行器类型：\" + requestHttp.getRequestType());\n    }\n  }\n\n  /**\n   * 创建临时文件\n   *\n   * @param inputStream 输入文件流\n   * @param name        文件名\n   * @param ext         扩展名\n   * @param tmpDirFile  临时文件夹目录\n   */\n  public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile)\n    throws IOException {\n    File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile);\n    resultFile.deleteOnExit();\n    try (InputStream in = inputStream; OutputStream out = openOutputStream(resultFile)) {\n      IOUtils.copy(in, out);\n    }","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/executor/ChannelMediaDownloadRequestExecutor.java#L27-L63","documentation":"ChannelMediaDownloadRequestExecutor.create only supports APACHE_HTTP and HTTP_COMPONENTS. JODD_HTTP and OK_HTTP hit the default branch and throw. Like the upload executor, the Channel module ships download implementations only for the Apache HttpClient families.","triggerScenarios":"The Channel service is wired with an OkHttp or Jodd RequestHttp backend, and a media-download API (any method routed through ChannelMediaDownloadRequestExecutor) is called.","commonSituations":"Reusing a cross-module OkHttp/Jodd configuration for Channel media retrieval; migrating client backends without verifying download coverage.","solutions":["Configure the Channel service with Apache HttpClient 4.x (APACHE_HTTP) or 5.x (HTTP_COMPONENTS).","Give the Channel service a dedicated Apache-based client rather than sharing a Jodd/OkHttp one.","Guard at startup: assert requestHttp.getRequestType() is APACHE_HTTP or HTTP_COMPONENTS before any media download."],"exampleFix":"// before\nservice.setWxHttpService(joddHttpService); // JODD_HTTP\nFile img = service.downloadMedia(...); // throws\n\n// after\nservice.setWxHttpService(apacheHttpService); // APACHE_HTTP\nFile img = service.downloadMedia(...);","handlingStrategy":"validation","validationCode":"Set<HttpClientType> supported = EnumSet.of(HttpClientType.APACHE_HTTP, HttpClientType.HTTP_COMPONENTS);\nif (!supported.contains(requestHttp.getRequestType())) {\n  throw new IllegalStateException(\"Channel media download requires Apache HttpClient, got \" + requestHttp.getRequestType());\n}","typeGuard":"private static boolean channelDownloadSupported(RequestHttp<?,?> http) {\n  HttpClientType t = http.getRequestType();\n  return t == HttpClientType.APACHE_HTTP || t == HttpClientType.HTTP_COMPONENTS;\n}","tryCatchPattern":"try {\n  service.downloadMedia(...);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"不支持的http执行器类型\")) {\n    // reconfigure Channel service with Apache HttpClient\n  }\n  throw e;\n}","preventionTips":["Use Apache HttpClient (4.x/5.x) for the Channel service.","Check the client type before invoking any media-download API.","Keep the Channel service's client config separate from Jodd/OkHttp modules."],"tags":["http-client","channel","download","configuration","unsupported-executor"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}