{"record":{"id":"47937cc9d22baa51","repo":"pentaho/pentaho-kettle","slug":"defaultauthenticationconsumerfactory-consume","errorCode":"DefaultAuthenticationConsumerFactory.Consume","errorMessage":"DefaultAuthenticationConsumerFactory.Consume","messagePattern":"DefaultAuthenticationConsumerFactory\\.Consume","errorType":"error_code","errorClass":"AuthenticationFactoryException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/core/auth/core/impl/DefaultAuthenticationConsumerFactory.java","lineNumber":62,"sourceCode":"      throw new AuthenticationFactoryException( BaseMessages.getString( PKG,\n          \"DefaultAuthenticationConsumerFactory.Constructor.Arg\", getClass().getName(), consumerClass\n              .getCanonicalName() ) );\n    }\n\n    Method consumeMethod = null;\n    Class<?> consumedType = Object.class;\n    for ( Method method : consumerClass.getMethods() ) {\n      if ( \"consume\".equals( method.getName() ) ) {\n        Class<?>[] methodParameterTypes = method.getParameterTypes();\n        if ( methodParameterTypes.length == 1 && consumedType.isAssignableFrom( methodParameterTypes[0] ) ) {\n          consumeMethod = method;\n          consumedType = methodParameterTypes[0];\n        }\n      }\n    }\n\n    if ( consumeMethod == null ) {\n      throw new AuthenticationFactoryException( BaseMessages.getString( PKG,\n          \"DefaultAuthenticationConsumerFactory.Consume\", consumerClass.getCanonicalName() ) );\n    }\n    this.consumedType = (Class<Object>) consumeMethod.getParameterTypes()[0];\n    this.returnType = (Class<Object>) consumeMethod.getReturnType();\n    this.createArgType = (Class<Object>) parameterTypes[0];\n  }\n\n  @Override\n  public Class<Object> getConsumedType() {\n    return consumedType;\n  }\n\n  @Override\n  public Class<Object> getReturnType() {\n    return returnType;\n  }\n\n  @Override","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/core/auth/core/impl/DefaultAuthenticationConsumerFactory.java#L44-L80","documentation":"DefaultAuthenticationConsumerFactory scans public methods to find the consume() entry point; if no suitable method is found it throws AuthenticationFactoryException with key 'DefaultAuthenticationConsumerFactory.Consume'. The consumer class therefore does not implement the expected consume contract.","triggerScenarios":"Registering a consumer class with no public method whose name matches the expected convention (consume/returns non-void taking one parameter) — the scan loop ends with consumeMethod == null.","commonSituations":"Consumer classes that renamed or overloaded consume(); method made private; a class passed in that isn't actually an AuthenticationConsumer implementation.","solutions":["Implement a public method named consume(...) taking exactly one parameter (the consumed authentication type) with a meaningful return type.","Ensure the method is public and not buried behind unrelated overloads that break the selection logic.","Verify the class passed to the factory actually implements the consumer interface."],"exampleFix":"// before\npublic class MyConsumer { public void run(PasswordAuthentication p) {} }\n// after\npublic class MyConsumer {\n  public String consume(PasswordAuthentication p) { return doWork(p); }\n}","handlingStrategy":"validation","validationCode":"boolean hasConsume = Arrays.stream(MyConsumer.class.getMethods())\n  .anyMatch(m -> m.getName().equals(\"consume\") && m.getParameterTypes().length == 1);\nif (!hasConsume) throw new IllegalStateException(\"Missing public consume(T) method\");","typeGuard":null,"tryCatchPattern":"try { new DefaultAuthenticationConsumerFactory(MyConsumer.class); } catch (AuthenticationFactoryException e) { logError(\"Consumer lacks consume() method\", e); }","preventionTips":["Always implement the public consume(T) method in consumer classes","Add reflection-based contract tests for consumer classes","Keep consume() un-renamed and public"],"tags":["authentication","reflection","contract"],"backgroundTag":"method-not-implemented","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}