logging-log4j2
logging-log4j2 copied to clipboard
Type parameters used only in the return type
As described in TypeParameterUnusedInFormals, these methods provide developers a false sense of type safety, whereas in reality they can cause ClassCastExceptions at runtime:
- [ ] Logger#getMessageFactory,
- [ ] ReadOnlyStringMap#getValue,
- [ ] LoaderUtil#newInstanceOf(String) and similar,
- [ ] ObjectThreadContextMap#getValue.
Changing/removing these methods is a binary compatible, but source incompatible change, hence this must be done in a major release.
This is related to #1850.
Also a few new places in the DI system (some of which is difficult to express within the limitations of the Java type system).
In fact, there are numerous places in the DI system abusing this. I'd be open to cleaning that up as it might also allow for the Key<T> class to be turned into a Key record class instead as only the Type reference is needed.