You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/04/07 20:50:58 UTC
[GitHub] [logging-log4j2] ppkarwasz opened a new pull request, #815: [LOG4J2-2872] Normalizes level names
ppkarwasz opened a new pull request, #815:
URL: https://github.com/apache/logging-log4j2/pull/815
Calling `Level.forName` with a non upper case argument, can create a custom level that can not be retrieved using `Level.toLevel`.
This PR fixes to upper case the keys in the `Level.LEVELS` map.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4j2] garydgregory commented on a diff in pull request #815: [LOG4J2-2872] Normalizes level names
Posted by GitBox <gi...@apache.org>.
garydgregory commented on code in PR #815:
URL: https://github.com/apache/logging-log4j2/pull/815#discussion_r845557940
##########
log4j-api/src/main/java/org/apache/logging/log4j/Level.java:
##########
@@ -259,15 +258,23 @@ public String toString() {
* @throws java.lang.IllegalArgumentException if the name is null or intValue is less than zero.
*/
public static Level forName(final String name, final int intValue) {
- final Level level = LEVELS.get(name);
Review Comment:
Above we use Strings.isEmpty(name), shouldn't we use the same here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4j2] ppkarwasz commented on a diff in pull request #815: [LOG4J2-2872] Normalizes level names
Posted by GitBox <gi...@apache.org>.
ppkarwasz commented on code in PR #815:
URL: https://github.com/apache/logging-log4j2/pull/815#discussion_r845563956
##########
log4j-api/src/main/java/org/apache/logging/log4j/Level.java:
##########
@@ -259,15 +258,23 @@ public String toString() {
* @throws java.lang.IllegalArgumentException if the name is null or intValue is less than zero.
*/
public static Level forName(final String name, final int intValue) {
- final Level level = LEVELS.get(name);
Review Comment:
Yes, that make sense, although the main reason for this check is to prevent an NPE in the `ConcurrentHashMap`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4j2] ppkarwasz merged pull request #815: [LOG4J2-2872] Normalizes level names
Posted by GitBox <gi...@apache.org>.
ppkarwasz merged PR #815:
URL: https://github.com/apache/logging-log4j2/pull/815
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [logging-log4j2] garydgregory commented on a diff in pull request #815: [LOG4J2-2872] Normalizes level names
Posted by GitBox <gi...@apache.org>.
garydgregory commented on code in PR #815:
URL: https://github.com/apache/logging-log4j2/pull/815#discussion_r845558255
##########
log4j-api/src/main/java/org/apache/logging/log4j/Level.java:
##########
@@ -276,9 +283,13 @@ public static Level forName(final String name, final int intValue) {
*
* @param name The name of the Level.
* @return The Level or null.
+ * @throws java.lang.IllegalArgumentException if the name is null.
*/
public static Level getLevel(final String name) {
- return LEVELS.get(name);
+ if (name == null) {
Review Comment:
See comment above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org