{"record":{"id":"9bab556d397267e3","repo":"apache/iceberg","slug":"cannot-create-s-to-generate-and-configure-the-htt","errorCode":null,"errorMessage":"Cannot create %s to generate and configure the http client builder","messagePattern":"Cannot create (.+?) to generate and configure the http client builder","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/HttpClientProperties.java","lineNumber":275,"sourceCode":"  }\n\n  /**\n   * Dynamically load the http client builder to avoid runtime deps requirements of both {@link\n   * software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient} and {@link\n   * software.amazon.awssdk.http.apache.ApacheHttpClient}, since including both will cause error\n   * described in <a href=\"https://github.com/apache/iceberg/issues/6715\">issue#6715</a>\n   */\n  private <T> T loadHttpClientConfigurations(String impl) {\n    Object httpClientConfigurations;\n    try {\n      httpClientConfigurations =\n          DynMethods.builder(\"create\")\n              .hiddenImpl(impl, Map.class)\n              .buildStaticChecked()\n              .invoke(httpClientProperties);\n      return (T) httpClientConfigurations;\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Cannot create %s to generate and configure the http client builder\", impl),\n          e);\n    }\n  }\n}\n","sourceCodeStart":257,"sourceCodeEnd":281,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/HttpClientProperties.java#L257-L281","documentation":"HttpClientProperties.loadHttpClientConfigurations dynamically loads a HttpClientConfigurations implementation class and invokes its static create(Map<String, String>) method with the properties map. If no such static factory method exists, NoSuchMethodException is wrapped as this IllegalArgumentException naming the implementation class.","triggerScenarios":"Configuring a custom HTTP client configurations class (e.g. via client.http-client-configurations-implements or the property used by urlConnectionHttpClientConfigurations/apacheHttpClientConfigurations) whose class lacks a static create(Map) method.","commonSituations":"Implementing a custom HttpClientConfigurations with only instance methods or a no-arg create(); pointing the property at an internal/SDK class that doesn't follow Iceberg's create(Map) convention.","solutions":["Add a public static T create(Map<String, String> httpClientProperties) factory method to the configured implementation class.","Verify the configured class name refers to your custom configurations class, not an unrelated type.","If a no-arg create exists instead, change it to accept Map<String, String>."],"exampleFix":"// before\npublic class MyHttpConfig implements HttpClientConfigurations {\n  public static MyHttpConfig create() { return new MyHttpConfig(); }\n}\n// after\npublic class MyHttpConfig implements HttpClientConfigurations {\n  public static MyHttpConfig create(Map<String, String> props) { return new MyHttpConfig(); }\n}","handlingStrategy":"type-guard","validationCode":"Class<?> c = Class.forName(implClassName);\nboolean ok = java.util.Arrays.stream(c.getMethods()).anyMatch(m ->\n    m.getName().equals(\"create\") && java.lang.reflect.Modifier.isStatic(m.getModifiers())\n    && m.getParameterCount() == 1 && Map.class.isAssignableFrom(m.getParameterTypes()[0]));\nif (!ok) throw new IllegalStateException(implClassName + \" needs static create(Map<String, String>)\");","typeGuard":"static boolean hasCreateMapFactory(Class<?> c) {\n  return java.util.Arrays.stream(c.getMethods()).anyMatch(m ->\n      m.getName().equals(\"create\") && java.lang.reflect.Modifier.isStatic(m.getModifiers())\n      && m.getParameterCount() == 1 && Map.class.isAssignableFrom(m.getParameterTypes()[0]));\n}","tryCatchPattern":"try {\n  httpClientProps = new HttpClientProperties(props);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Cannot create\")) {\n    LOG.error(\"Configured HTTP configurations class lacks create(Map): {}\", e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Always implement custom HttpClientConfigurations with public static T create(Map<String, String>).","Unit-test dynamic loading of the configured class before deploying.","Keep the implementation class name in config in sync with refactors."],"tags":["aws","reflection","http-client","factory-method"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}