You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "jonasrutishauser (via GitHub)" <gi...@apache.org> on 2024/10/14 20:28:57 UTC
[PR] Avoid levels like `INFO#org.apache.log4j.Level` (logging-log4j2)
jonasrutishauser opened a new pull request, #3085:
URL: https://github.com/apache/logging-log4j2/pull/3085
If somebody (for example an external library) uses the deprecated `Priority` class there will be a custom level created even though there already exists a corresponding level.
--
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
Re: [PR] Avoid levels like `INFO#org.apache.log4j.Level` (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #3085:
URL: https://github.com/apache/logging-log4j2/pull/3085#issuecomment-2413199879
@jonasrutishauser,
Nice catch!
Looking at the `o.a.l.Priority` class there are other things that can go wrong:
1. `Priority.version2Level` can be `null`. This might lead to incorrect filtering of `Priority` instances (possibly even an NPE). Can you create a new package-private constructor that always sets this field to a non-`null` value:
```java
this.version2Level = version2Equivalent != null ? version2Equivalent : OptionConverter.createLevel(this);
```
1. The `Priority.FATAL`, `Priority.ERROR` and so on fields reference the `Level` subclass, which might lead to class loading deadlocks on some JVMs (or they might just be `null` on others). Can you create them using the new constructor instead?
--
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
Re: [PR] Avoid levels like `INFO#org.apache.log4j.Level` (logging-log4j2)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3085:
URL: https://github.com/apache/logging-log4j2/pull/3085#issuecomment-2412338531
<table>
<tr>
<th>Job</th>
<th>Requested goals</th>
<th>Build Tool Version</th>
<th>Build Outcome</th>
<th>Build ScanĀ®</th>
</tr>
<tr>
<td>build-macos-latest</td>
<td>clean install</td>
<td align='center'>3.9.8</td>
<td align='center'>:white_check_mark:</td>
<td><a href="https://ge.apache.org/s/m2btbv5w643wm" rel="nofollow"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td>
</tr>
<tr>
<td>build-ubuntu-latest</td>
<td>clean install</td>
<td align='center'>3.9.8</td>
<td align='center'>:white_check_mark:</td>
<td><a href="https://ge.apache.org/s/ibbiig55hpyue" rel="nofollow"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td>
</tr>
<tr>
<td>build-windows-latest</td>
<td>clean install</td>
<td align='center'>3.9.8</td>
<td align='center'>:white_check_mark:</td>
<td><a href="https://ge.apache.org/s/3hik5h4lcbpdi" rel="nofollow"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td>
</tr>
</table>
###### Generated by gradle/develocity-actions
--
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
Re: [PR] Avoid levels like `INFO#org.apache.log4j.Level` (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #3085:
URL: https://github.com/apache/logging-log4j2/pull/3085#issuecomment-2434469644
@jonasrutishauser,
Thank You for your contribution!
--
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
Re: [PR] Avoid levels like `INFO#org.apache.log4j.Level` (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #3085:
URL: https://github.com/apache/logging-log4j2/pull/3085#discussion_r1802454822
##########
log4j-1.2-api/src/test/java/org/apache/log4j/LevelTest.java:
##########
@@ -205,6 +207,70 @@ public void testALL() {
assertTrue(Level.ALL instanceof Level);
}
+ /**
+ * Tests Level.OFF version2Level.
+ */
+ @Test
+ public void testOffVersion2Level() {
+ assertEquals(org.apache.logging.log4j.Level.OFF, Level.OFF.getVersion2Level());
+ }
+
+ /**
+ * Tests Level.FATAL version2Level.
+ */
+ @Test
+ public void testFatalVersion2Level() {
+ assertEquals(org.apache.logging.log4j.Level.FATAL, Level.FATAL.getVersion2Level());
+ }
Review Comment:
The test class uses unfortunately JUnit 4, but it should be easy to convert it to a JUnit 5 test class with a `@ParameterizedTest` instead of multiple single tests.
--
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
Re: [PR] Avoid levels like `INFO#org.apache.log4j.Level` (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz merged PR #3085:
URL: https://github.com/apache/logging-log4j2/pull/3085
--
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