Skip to content

Replace field injection with setter injection in 3.x #2769

@ppkarwasz

Description

@ppkarwasz

As issue #2766 shows, there are still some Log4j plugin builders that don't have setters for all their configuration attributes.

Since field injection becomes more problematic in newer Java version, I believe we should add the missing setters and make sure all new attributes come with a public setter.

Therefore I propose:

  • to modify the annotation processor in 2.x to fail if a plugin builder attribute does not have a public setter (or at least a wither).
  • fix the compilation errors in 2.x.

Regarding 3.x I would prefer to remove field injection completely from log4j-plugins and use builders and setter injection everywhere. IMHO our DI subsystem does not need to have all the features of a fully-fledged DI.
Obviously we might still need field injection if we want to support all the existing 2.x plugins, but I would still love a 200 KiB dependency injection system.

Metadata

Metadata

Labels

Type

No type

Projects

Status

To triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions