Skip to content

Commit e575220

Browse files
committed
Fix LogLevelsCondition for NullAway
* Replace `JUnit 5` in the docs with an official `JUnit Jupiter`
1 parent ca7e844 commit e575220

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

spring-integration-test-support/src/main/java/org/springframework/integration/test/condition/LogLevelsCondition.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
* JUnit condition that adjusts and reverts log levels before/after each test.
4040
*
4141
* @author Gary Russell
42+
* @author Artem Bilan
43+
*
4244
* @since 5.2
4345
*
4446
*/
@@ -67,7 +69,6 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
6769
}
6870

6971
@Override
70-
@SuppressWarnings("NullAway") // Dataflow analysis limitation
7172
public void beforeEach(ExtensionContext context) {
7273
Store store = context.getStore(Namespace.create(getClass(), context));
7374
LogLevels logLevels = store.get(STORE_ANNOTATION_KEY, LogLevels.class);
@@ -76,14 +77,15 @@ public void beforeEach(ExtensionContext context) {
7677
store = parent.getStore(Namespace.create(getClass(), parent));
7778
logLevels = store.get(STORE_ANNOTATION_KEY, LogLevels.class);
7879
}
79-
store.put(STORE_CONTAINER_KEY, TestUtils.adjustLogLevels(context.getDisplayName(),
80-
Arrays.asList((logLevels.classes())),
81-
Arrays.asList(logLevels.categories()),
82-
Level.toLevel(logLevels.level())));
80+
if (logLevels != null) {
81+
store.put(STORE_CONTAINER_KEY, TestUtils.adjustLogLevels(context.getDisplayName(),
82+
Arrays.asList((logLevels.classes())),
83+
Arrays.asList(logLevels.categories()),
84+
Level.toLevel(logLevels.level())));
85+
}
8386
}
8487

8588
@Override
86-
@SuppressWarnings("NullAway") // Dataflow analysis limitation
8789
public void afterEach(ExtensionContext context) {
8890
Store store = context.getStore(Namespace.create(getClass(), context));
8991
LevelsContainer container = store.get(STORE_CONTAINER_KEY, LevelsContainer.class);
@@ -94,7 +96,9 @@ public void afterEach(ExtensionContext context) {
9496
container = store.get(STORE_CONTAINER_KEY, LevelsContainer.class);
9597
parentStore = true;
9698
}
97-
TestUtils.revertLogLevels(context.getDisplayName(), container);
99+
if (container != null) {
100+
TestUtils.revertLogLevels(context.getDisplayName(), container);
101+
}
98102
store.remove(STORE_CONTAINER_KEY);
99103
if (!parentStore) {
100104
store.remove(STORE_ANNOTATION_KEY);

src/reference/antora/modules/ROOT/pages/changes-5.0-5.1.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ See xref:functions-support.adoc[`java.util.function` Interfaces Support].
2424
[[x5.1-LongRunningTest]]
2525
=== `@LongRunningTest`
2626

27-
A JUnit 5 `@LongRunningTest` conditional annotation is provided to check the environment or system properties for the `RUN_LONG_INTEGRATION_TESTS` entry with the value of `true` to determine if test should be run or skipped.
27+
A JUnit Jupiter `@LongRunningTest` conditional annotation is provided to check the environment or system properties for the `RUN_LONG_INTEGRATION_TESTS` entry with the value of `true` to determine if test should be run or skipped.
2828

29-
See xref:testing.adoc#test-junit-rules[JUnit Rules and Conditions].
29+
See xref:testing.adoc#test-junit-conditions[JUnit Conditions].
3030

3131
[[x5.1-general]]
3232
== General Changes

0 commit comments

Comments
 (0)