{"record":{"id":"300355567d54bb2d","repo":"binarywang/WxJava","slug":"http","errorCode":null,"errorMessage":"不支持的http执行器类型：","messagePattern":"不支持的http执行器类型：","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernRequestExecutor.java","lineNumber":42,"sourceCode":"    this.requestHttp = requestHttp;\n  }\n\n  @Override\n  public void execute(String uri, File data, ResponseHandler<String> handler, WxType wxType) throws WxErrorException, IOException {\n    handler.handle(this.execute(uri, data, wxType));\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 OcrDiscernApacheHttpRequestExecutor(\n          (RequestHttp<org.apache.http.impl.client.CloseableHttpClient, org.apache.http.HttpHost>) requestHttp);\n      case HTTP_COMPONENTS:\n        return new OcrDiscernHttpComponentsRequestExecutor(\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":24,"sourceCodeEnd":46,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-common/src/main/java/me/chanjar/weixin/common/requestexecuter/ocr/OcrDiscernRequestExecutor.java#L24-L46","documentation":"OcrDiscernRequestExecutor.create only supports APACHE_HTTP and HTTP_COMPONENTS (Apache HttpClient 4.x and 5.x). JODD_HTTP and OK_HTTP fall through to the default branch and throw. The OCR feature ships no Jodd/OkHttp implementations, so those clients cannot perform OCR requests.","triggerScenarios":"The service (MP/Channel) is configured with an OkHttp or Jodd RequestHttp backend, and an OCR (image recognition) API routed through OcrDiscernRequestExecutor is called.","commonSituations":"Migrating to OkHttp globally without checking OCR coverage; sharing a Jodd/OkHttp client config with the OCR-capable service.","solutions":["Configure the OCR-capable service with Apache HttpClient 4.x (APACHE_HTTP) or 5.x (HTTP_COMPONENTS).","Give the OCR service a dedicated Apache-based client.","Assert requestHttp.getRequestType() is APACHE_HTTP or HTTP_COMPONENTS at startup before any OCR call."],"exampleFix":"// before\nmpService.setWxHttpService(okHttpService); // OK_HTTP\nString text = ocrService.discern(imgFile); // throws\n\n// after\nmpService.setWxHttpService(apacheHttpService); // APACHE_HTTP\nString text = ocrService.discern(imgFile);","handlingStrategy":"validation","validationCode":"Set<HttpClientType> supported = EnumSet.of(HttpClientType.APACHE_HTTP, HttpClientType.HTTP_COMPONENTS);\nif (!supported.contains(requestHttp.getRequestType())) {\n  throw new IllegalStateException(\"OCR requires Apache HttpClient, got \" + requestHttp.getRequestType());\n}","typeGuard":"private static boolean ocrSupported(RequestHttp<?,?> http) {\n  HttpClientType t = http.getRequestType();\n  return t == HttpClientType.APACHE_HTTP || t == HttpClientType.HTTP_COMPONENTS;\n}","tryCatchPattern":"try {\n  ocrService.discern(imgFile);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"不支持的http执行器类型\")) {\n    // reconfigure the OCR-capable service with Apache HttpClient\n  }\n  throw e;\n}","preventionTips":["Use Apache HttpClient (4.x/5.x) for any service that calls OCR APIs.","Assert the client type before the first OCR call.","Do not share an OkHttp/Jodd client with the OCR-capable service."],"tags":["http-client","ocr","configuration","unsupported-executor"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}