From eb5b398f7bbf4b53a6384b6cdb37ec9c01fb5bf3 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Sep 2024 03:36:09 +0000
Subject: [PATCH 1/9] Update gradle/actions digest to d156388
---
.github/actions/run-gradle/action.yml | 2 +-
.github/workflows/gradle-dependency-submission.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/actions/run-gradle/action.yml b/.github/actions/run-gradle/action.yml
index e825551ce6f5..f0ba06a50fd0 100644
--- a/.github/actions/run-gradle/action.yml
+++ b/.github/actions/run-gradle/action.yml
@@ -14,7 +14,7 @@ runs:
distribution: temurin
java-version: 21
check-latest: true
- - uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
+ - uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4
- shell: bash
env:
JAVA_HOME: ${{ steps.setup-gradle-jdk.outputs.path }}
diff --git a/.github/workflows/gradle-dependency-submission.yml b/.github/workflows/gradle-dependency-submission.yml
index c867584a5835..a2f98e37c62e 100644
--- a/.github/workflows/gradle-dependency-submission.yml
+++ b/.github/workflows/gradle-dependency-submission.yml
@@ -24,4 +24,4 @@ jobs:
java-version: 21
check-latest: true
- name: Generate and submit dependency graph
- uses: gradle/actions/dependency-submission@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
+ uses: gradle/actions/dependency-submission@d156388eb19639ec20ade50009f3d199ce1e2808 # v4
From c04cdc83bc87d1f579275a6d4c1471a1be56c919 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Sep 2024 08:30:24 +0000
Subject: [PATCH 2/9] Update plugin org.jetbrains.kotlin.jvm to v2
---
.../projects/gradle-kotlin-extensions/build.gradle.kts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/platform-tooling-support-tests/projects/gradle-kotlin-extensions/build.gradle.kts b/platform-tooling-support-tests/projects/gradle-kotlin-extensions/build.gradle.kts
index ac2d236c6663..1811e4793aaf 100644
--- a/platform-tooling-support-tests/projects/gradle-kotlin-extensions/build.gradle.kts
+++ b/platform-tooling-support-tests/projects/gradle-kotlin-extensions/build.gradle.kts
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
- kotlin("jvm") version "1.9.25"
+ kotlin("jvm") version "2.0.20"
}
repositories {
From bd7a374681540ffd00db7fa2c904a67e5b030cba Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Sep 2024 08:30:19 +0000
Subject: [PATCH 3/9] Update dependency
org.apache.maven.plugins:maven-surefire-plugin to v3
---
platform-tooling-support-tests/projects/java-versions/pom.xml | 2 +-
platform-tooling-support-tests/projects/maven-starter/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/platform-tooling-support-tests/projects/java-versions/pom.xml b/platform-tooling-support-tests/projects/java-versions/pom.xml
index f4f3ddfd2cbf..5714dfc34e46 100644
--- a/platform-tooling-support-tests/projects/java-versions/pom.xml
+++ b/platform-tooling-support-tests/projects/java-versions/pom.xml
@@ -41,7 +41,7 @@
maven-surefire-plugin
- 2.22.2
+ 3.5.0
diff --git a/platform-tooling-support-tests/projects/maven-starter/pom.xml b/platform-tooling-support-tests/projects/maven-starter/pom.xml
index b65aec64a043..166263dd1765 100644
--- a/platform-tooling-support-tests/projects/maven-starter/pom.xml
+++ b/platform-tooling-support-tests/projects/maven-starter/pom.xml
@@ -47,7 +47,7 @@
maven-surefire-plugin
- 2.22.2
+ 3.5.0
From 77924aaa92b90926381c0fcb4fd9141eafc2c2eb Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Sep 2024 08:30:15 +0000
Subject: [PATCH 4/9] Update plugin plantuml to v8.10
---
gradle/libs.versions.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 98403b1a3679..b33f2015171b 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -90,7 +90,7 @@ foojayResolver = { id = "org.gradle.toolchains.foojay-resolver", version = "0.8.
gitPublish = { id = "org.ajoberstar.git-publish", version = "4.2.2" }
jmh = { id = "me.champeau.jmh", version = "0.7.2" }
nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }
-plantuml = { id = "io.freefair.plantuml", version = "8.6" }
+plantuml = { id = "io.freefair.plantuml", version = "8.10" }
shadow = { id = "com.gradleup.shadow", version = "8.3.1" }
spotless = { id = "com.diffplug.spotless", version = "7.0.0.BETA2" }
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
From 097adb00acdfae992cb57c55dcb96bed3efd1d82 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Sep 2024 08:30:10 +0000
Subject: [PATCH 5/9] Update dependency
org.eclipse.platform:org.eclipse.platform to v4.33.0
---
gradle/libs.versions.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index b33f2015171b..77092a2b266d 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -6,7 +6,7 @@ asciidoctor-plugins = "4.0.3" # Check if workaround in documentation.gradle.kts
assertj = "3.26.3"
bnd = "7.0.0"
checkstyle = "10.18.1"
-eclipse = "4.32.0"
+eclipse = "4.33.0"
jackson = "2.17.2"
jacoco = "0.8.12"
jmh = "1.37"
From 1d1c6d547293a1556238e814fb7d01e97c09a9c6 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Sep 2024 08:30:04 +0000
Subject: [PATCH 6/9] Update dependency org.apache.groovy:groovy to v4.0.23
---
gradle/libs.versions.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 77092a2b266d..ca393ee6daf4 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -34,7 +34,7 @@ bndlib = { module = "biz.aQute.bnd:biz.aQute.bndlib", version.ref = "bnd" }
checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" }
classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.175" }
commons-io = { module = "commons-io:commons-io", version = "2.16.1" }
-groovy4 = { module = "org.apache.groovy:groovy", version = "4.0.22" }
+groovy4 = { module = "org.apache.groovy:groovy", version = "4.0.23" }
groovy2-bom = { module = "org.codehaus.groovy:groovy-bom", version = "2.5.23" }
hamcrest = { module = "org.hamcrest:hamcrest", version = "3.0" }
jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson" }
From 3e2cc6cac1151ced3286cf0039123dd577e57f12 Mon Sep 17 00:00:00 2001
From: Sam Brannen <104798+sbrannen@users.noreply.github.com>
Date: Fri, 13 Sep 2024 16:11:28 +0200
Subject: [PATCH 7/9] Ensure TestWatchers can access data in the
ExtensionContext.Store
Changes made in conjunction with #3614 resulted in an exception being
thrown if a NamespacedHierarchicalStore was queried after it had been
closed. Consequently, TestWatcher callbacks were no longer able to
access data in the Store.
To fix that regression, this commit revises NamespacedHierarchicalStore
so that it no longer throws an exception after it has been closed if
the store is queried via one of the get(...) or
getOrComputeIfAbsent(...) methods; however, if a
getOrComputeIfAbsent(...) invocation results in the computation of a
new value, an exception will still be thrown. In other words, when
a NamespacedHierarchicalStore is closed, it now effectively switches to
ready-only mode.
See: #3614
Fixes: #3944
---
.../release-notes/release-notes-5.11.1.adoc | 7 ++-
.../store/NamespacedHierarchicalStore.java | 9 ++--
.../engine/extension/TestWatcherTests.java | 51 +++++++++++++++++++
.../NamespacedHierarchicalStoreTests.java | 27 ++++++----
4 files changed, 78 insertions(+), 16 deletions(-)
diff --git a/documentation/src/docs/asciidoc/release-notes/release-notes-5.11.1.adoc b/documentation/src/docs/asciidoc/release-notes/release-notes-5.11.1.adoc
index 80f58d56d747..41114a7b0230 100644
--- a/documentation/src/docs/asciidoc/release-notes/release-notes-5.11.1.adoc
+++ b/documentation/src/docs/asciidoc/release-notes/release-notes-5.11.1.adoc
@@ -18,6 +18,10 @@ on GitHub.
* Fixed potential locking issue with `ExclusiveResource` in the
`HierarchicalTestExecutorService`, which could lead to deadlocks in certain scenarios.
+* `NamespacedHierarchicalStore` no longer throws an exception after it has been closed if
+ the store is queried via one of the `get(...)` or `getOrComputeIfAbsent(...)` methods;
+ however, if a `getOrComputeIfAbsent(...)` invocation results in the computation of a new
+ value, an exception will still be thrown.
[[release-notes-5.11.1-junit-platform-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes
@@ -37,7 +41,8 @@ on GitHub.
[[release-notes-5.11.1-junit-jupiter-bug-fixes]]
==== Bug Fixes
-* ❓
+* `TestWatcher` callback methods can once again access data in the
+ `ExtensionContext.Store`.
[[release-notes-5.11.1-junit-jupiter-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes
diff --git a/junit-platform-engine/src/main/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStore.java b/junit-platform-engine/src/main/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStore.java
index 965eb9b24439..79836ac6f501 100644
--- a/junit-platform-engine/src/main/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStore.java
+++ b/junit-platform-engine/src/main/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStore.java
@@ -139,7 +139,6 @@ public void close() {
* closed
*/
public Object get(N namespace, Object key) {
- rejectIfClosed();
StoredValue storedValue = getStoredValue(new CompositeKey<>(namespace, key));
return StoredValue.evaluateIfNotNull(storedValue);
}
@@ -156,7 +155,6 @@ public Object get(N namespace, Object key) {
* be cast to the required type, or if this store has already been closed
*/
public T get(N namespace, Object key, Class requiredType) throws NamespacedHierarchicalStoreException {
- rejectIfClosed();
Object value = get(namespace, key);
return castToRequiredType(key, value, requiredType);
}
@@ -174,13 +172,15 @@ public T get(N namespace, Object key, Class requiredType) throws Namespac
* closed
*/
public Object getOrComputeIfAbsent(N namespace, K key, Function defaultCreator) {
- rejectIfClosed();
Preconditions.notNull(defaultCreator, "defaultCreator must not be null");
CompositeKey compositeKey = new CompositeKey<>(namespace, key);
StoredValue storedValue = getStoredValue(compositeKey);
if (storedValue == null) {
storedValue = this.storedValues.computeIfAbsent(compositeKey,
- __ -> storedValue(new MemoizingSupplier(() -> defaultCreator.apply(key))));
+ __ -> storedValue(new MemoizingSupplier(() -> {
+ rejectIfClosed();
+ return defaultCreator.apply(key);
+ })));
}
return storedValue.evaluate();
}
@@ -202,7 +202,6 @@ public Object getOrComputeIfAbsent(N namespace, K key, Function def
public V getOrComputeIfAbsent(N namespace, K key, Function defaultCreator, Class requiredType)
throws NamespacedHierarchicalStoreException {
- rejectIfClosed();
Object value = getOrComputeIfAbsent(namespace, key, defaultCreator);
return castToRequiredType(key, value, requiredType);
}
diff --git a/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/TestWatcherTests.java b/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/TestWatcherTests.java
index 27ca3d2d77c9..a8400aa63ba3 100644
--- a/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/TestWatcherTests.java
+++ b/jupiter-tests/src/test/java/org/junit/jupiter/engine/extension/TestWatcherTests.java
@@ -12,6 +12,7 @@
import static java.util.function.Predicate.not;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.entry;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -41,8 +42,11 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+import org.junit.jupiter.api.extension.ExtensionContext.Store;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.extension.TestWatcher;
import org.junit.jupiter.api.fixtures.TrackLogRecords;
@@ -67,6 +71,7 @@ class TestWatcherTests extends AbstractJupiterTestEngineTests {
@BeforeEach
void clearResults() {
TrackingTestWatcher.results.clear();
+ DataRetrievingTestWatcher.results.clear();
}
@Test
@@ -167,6 +172,16 @@ void testWatcherSemanticsWhenRegisteredAtMethodLevel() {
assertThat(TrackingTestWatcher.results.get("testDisabled")).containsExactly("test", "repeatedTest");
}
+ @Test
+ void testWatcherCanRetrieveDataFromTheExtensionContextStore() {
+ Class> testClass = DataRetrievingTestWatcherTestCase.class;
+ EngineExecutionResults results = executeTestsForClass(testClass);
+
+ results.testEvents().assertStatistics(stats -> stats.started(1).succeeded(1).failed(0));
+
+ assertThat(DataRetrievingTestWatcher.results).containsExactly(entry("key", "enigma"));
+ }
+
private void assertCommonStatistics(EngineExecutionResults results) {
results.containerEvents().assertStatistics(stats -> stats.started(3).succeeded(3).failed(0));
results.testEvents().assertStatistics(stats -> stats.skipped(2).started(6).succeeded(2).aborted(2).failed(2));
@@ -414,4 +429,40 @@ public void testFailed(ExtensionContext context, Throwable cause) {
}
+ /**
+ * {@link TestWatcher} that retrieves data from the {@link ExtensionContext.Store}.
+ * @see #3944
+ */
+ static class DataRetrievingTestWatcher implements BeforeTestExecutionCallback, TestWatcher {
+
+ private static final Namespace NAMESPACE = Namespace.create(DataRetrievingTestWatcher.class);
+
+ private static final String KEY = "key";
+
+ private static final Map results = new HashMap<>();
+
+ @Override
+ public void beforeTestExecution(ExtensionContext context) throws Exception {
+ getStore(context).put(KEY, "enigma");
+ }
+
+ @Override
+ public void testSuccessful(ExtensionContext context) {
+ results.put(KEY, getStore(context).get(KEY, String.class));
+ }
+
+ private static Store getStore(ExtensionContext context) {
+ return context.getStore(NAMESPACE);
+ }
+ }
+
+ @ExtendWith(DataRetrievingTestWatcher.class)
+ static class DataRetrievingTestWatcherTestCase {
+
+ @Test
+ public void test() {
+ //no-op
+ }
+ }
+
}
diff --git a/platform-tests/src/test/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStoreTests.java b/platform-tests/src/test/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStoreTests.java
index 9f18083a924c..f234ff11dbe3 100644
--- a/platform-tests/src/test/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStoreTests.java
+++ b/platform-tests/src/test/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStoreTests.java
@@ -519,28 +519,35 @@ void closeIsIdempotent() throws Throwable {
verifyNoMoreInteractions(closeAction);
}
+ /**
+ * @see #3944
+ */
@Test
- void rejectsModificationAfterClose() {
+ void acceptsQueryAfterClose() {
+ store.put(namespace, key, value);
store.close();
assertClosed();
- assertThrows(NamespacedHierarchicalStoreException.class, () -> store.put(namespace, "key1", "value1"));
- assertThrows(NamespacedHierarchicalStoreException.class, () -> store.remove(namespace, "key1"));
- assertThrows(NamespacedHierarchicalStoreException.class,
- () -> store.remove(namespace, "key1", Number.class));
+ assertThat(store.get(namespace, key)).isEqualTo(value);
+ assertThat(store.get(namespace, key, String.class)).isEqualTo(value);
+ assertThat(store.getOrComputeIfAbsent(namespace, key, k -> "new")).isEqualTo(value);
+ assertThat(store.getOrComputeIfAbsent(namespace, key, k -> "new", String.class)).isEqualTo(value);
}
@Test
- void rejectsQueryAfterClose() {
+ void rejectsModificationAfterClose() {
store.close();
assertClosed();
- assertThrows(NamespacedHierarchicalStoreException.class, () -> store.get(namespace, "key1"));
- assertThrows(NamespacedHierarchicalStoreException.class, () -> store.get(namespace, "key1", Integer.class));
+ assertThrows(NamespacedHierarchicalStoreException.class, () -> store.put(namespace, key, value));
+ assertThrows(NamespacedHierarchicalStoreException.class, () -> store.remove(namespace, key));
+ assertThrows(NamespacedHierarchicalStoreException.class, () -> store.remove(namespace, key, int.class));
+
+ // Since key does not exist, an invocation of getOrComputeIfAbsent(...) will attempt to compute a new value.
assertThrows(NamespacedHierarchicalStoreException.class,
- () -> store.getOrComputeIfAbsent(namespace, "key1", k -> "value"));
+ () -> store.getOrComputeIfAbsent(namespace, key, k -> "new"));
assertThrows(NamespacedHierarchicalStoreException.class,
- () -> store.getOrComputeIfAbsent(namespace, "key1", k -> 1337, Integer.class));
+ () -> store.getOrComputeIfAbsent(namespace, key, k -> "new", String.class));
}
private void assertNotClosed() {
From 9e544025b0b1c1064bd83175e1829e8d21875621 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Sep 2024 14:26:28 +0000
Subject: [PATCH 8/9] Update github/codeql-action digest to 8214744
---
.github/workflows/codeql-analysis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 133179e59c25..dd0e5c3f69b9 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -32,7 +32,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Initialize CodeQL
- uses: github/codeql-action/init@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3
+ uses: github/codeql-action/init@8214744c546c1e5c8f03dde8fab3a7353211988d # v3
with:
languages: ${{ matrix.language }}
tools: latest
@@ -44,4 +44,4 @@ jobs:
-Dscan.tag.CodeQL \
allMainClasses
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3
+ uses: github/codeql-action/analyze@8214744c546c1e5c8f03dde8fab3a7353211988d # v3
From da8eb5f18d09d4ca8ba0b87e7fae0160d8c64958 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Sep 2024 15:00:53 +0000
Subject: [PATCH 9/9] Update dependency
org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.9.0
---
gradle/libs.versions.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index ca393ee6daf4..b5a293598d9d 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -47,7 +47,7 @@ jmh-generator-annprocess = { module = "org.openjdk.jmh:jmh-generator-annprocess"
joox = { module = "org.jooq:joox", version = "2.0.1" }
jte = { module = "gg.jte:jte", version = "3.1.12" }
junit4 = { module = "junit:junit", version = { require = "[4.12,)", prefer = "4.13.2" } }
-kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.8.1" }
+kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.9.0" }
log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
log4j-jul = { module = "org.apache.logging.log4j:log4j-jul", version.ref = "log4j" }
maven = { module = "org.apache.maven:apache-maven", version = "3.9.9" }