{"record":{"id":"5fe363b6ddb6f7dd","repo":"apache/iceberg","slug":"cannot-initialize-adlstokencredentialprovider-s","errorCode":null,"errorMessage":"Cannot initialize AdlsTokenCredentialProvider, %s does not implement AdlsTokenCredentialProvider.","messagePattern":"Cannot initialize AdlsTokenCredentialProvider, (.+?) does not implement AdlsTokenCredentialProvider\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"azure/src/main/java/org/apache/iceberg/azure/AdlsTokenCredentialProviders.java","lineNumber":75,"sourceCode":"    try {\n      ctor =\n          DynConstructors.builder(AdlsTokenCredentialProvider.class)\n              .loader(AdlsTokenCredentialProviders.class.getClassLoader())\n              .hiddenImpl(impl)\n              .buildChecked();\n    } catch (NoSuchMethodException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize AdlsTokenCredentialProvider, missing no-arg constructor: %s\",\n              impl),\n          e);\n    }\n\n    AdlsTokenCredentialProvider provider;\n    try {\n      provider = ctor.newInstance();\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot initialize AdlsTokenCredentialProvider, %s does not implement AdlsTokenCredentialProvider.\",\n              impl),\n          e);\n    }\n\n    provider.initialize(properties);\n    return provider;\n  }\n\n  static class DefaultTokenCredentialProvider implements AdlsTokenCredentialProvider {\n\n    @Override\n    public TokenCredential credential() {\n      return new DefaultAzureCredentialBuilder().build();\n    }\n\n    @Override","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/azure/src/main/java/org/apache/iceberg/azure/AdlsTokenCredentialProviders.java#L57-L93","documentation":"After reflectively constructing an instance from the configured class name, loadCredentialProvider casts it to AdlsTokenCredentialProvider. If the class was instantiated but does not actually implement that interface, the ClassCastException is converted into this IllegalArgumentException.","triggerScenarios":"Configuring the ADLS credential provider class name with a class that exists and has a no-arg constructor but does not implement org.apache.iceberg.azure.AdlsTokenCredentialProvider.","commonSituations":"Copy-pasting a class name from another provider mechanism (e.g. a Hadoop CredentialProvider or generic auth class); renaming/refactoring an implementation away from the interface while the config still points at it.","solutions":["Make the configured class implement org.apache.iceberg.azure.AdlsTokenCredentialProvider.","Check the configured class name; replace it with a class that implements the interface.","If the old implementation was removed or renamed, update the configuration to the new class name."],"exampleFix":"// before\npublic class MyProvider { public String token() { ... } }\n// after\npublic class MyProvider implements AdlsTokenCredentialProvider {\n  @Override public Credential getOAuth2Token() { ... }\n}","handlingStrategy":"type-guard","validationCode":"Class<?> cls = Class.forName(implClassName);\nif (!AdlsTokenCredentialProvider.class.isAssignableFrom(cls)) throw new IllegalArgumentException(implClassName + \" does not implement AdlsTokenCredentialProvider\");","typeGuard":"boolean isProvider = obj instanceof AdlsTokenCredentialProvider;","tryCatchPattern":"try { provider = AdlsTokenCredentialProviders.from(config); } catch (IllegalArgumentException e) { log.error(\"Configured class does not implement AdlsTokenCredentialProvider: {}\", config.get(\"impl\")); throw e; }","preventionTips":["Have custom provider classes implement AdlsTokenCredentialProvider and verify with a compile-time check (e.g. an abstract base class).","Double-check the fully-qualified class name in configuration.","Add a smoke test that instantiates the configured provider at startup."],"tags":["azure","reflection","type-mismatch","configuration"],"backgroundTag":"type-mismatch","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"}