Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncWaitStrategyFactoryConfig - potential NPE when creating programatically #3159

Open
JWT007 opened this issue Nov 4, 2024 · 0 comments
Open

Comments

@JWT007
Copy link
Contributor

JWT007 commented Nov 4, 2024

AsyncWaitStrategyFactoryConfig (Log4j 2.24.1)

This @Plugin doesn't behave like most others where if the configuration is invalid, it will return a null from the Builder.

The @PluginBuilderAttribute factoryClassName (for the XML class attribute) is marked as @Required, but if creating programatically the missing value is not checked and the constructor will throw a NPE.

@Override
public AsyncWaitStrategyFactoryConfig build() {
    return new AsyncWaitStrategyFactoryConfig(factoryClassName);
}
public AsyncWaitStrategyFactoryConfig(final String factoryClassName) {
    this.factoryClassName = Objects.requireNonNull(factoryClassName, "factoryClassName");
}

Typical behaviour here would be to return null from the build() method if misconfigured.

  • adding a NotEmpty check to the Builder#withFactoryClassName(...) method might be sensible.
  • adding a NotEmpty check to the constructor might be sensible (an empty string here makes no sense)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant