apache / apache/logging-log4j2

Type parameters used only in the return type

Open
#1,967 3 comments 0 reactions 0 assignees View on GitHub
api
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

As described in [TypeParameterUnusedInFormals](https://errorprone.info/bugpattern/TypeParameterUnusedInFormals), these methods provide developers a false sense of _type safety_, whereas in reality they can cause `ClassCastException`s at runtime:

- [ ] [Logger#getMessageFactory](https://logging.apache.org/log4j/2.x/javadoc/log4j-api/org/apache/logging/log4j/Logger.html#getMessageFactory()),
- [ ] [ReadOnlyStringMap#getValue](https://logging.apache.org/log4j/2.x/javadoc/log4j-api/org/apache/logging/log4j/util/ReadOnlyStringMap.html#getValue(java.lang.String)),
- [ ] [LoaderUtil#newInstanceOf(String)](https://logging.apache.org/log4j/2.x/javadoc/log4j-api/org/apache/logging/log4j/util/LoaderUtil.html#newInstanceOf(java.lang.String)) and similar,
- [ ] [ObjectThreadContextMap#getValue](https://logging.apache.org/log4j/2.x/javadoc/log4j-api/org/apache/logging/log4j/spi/ObjectThreadContextMap.html#getValue(java.lang.String)).

Changing/removing these methods is a binary compatible, but source incompatible change, hence this must be done in a major release.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.