Skip to content

Commit de4ff4b

Browse files
committed
Polishing tests
This commit adds more test coverage of SpringCoreBlockHoundIntegration. See gh-33450
1 parent f6e96a2 commit de4ff4b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

spring-core/src/test/java/org/springframework/core/SpringCoreBlockHoundIntegrationTests.java

+24-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void blockHoundIsInstalled() {
6666
}
6767

6868
@Test
69-
void concurrentReferenceHashMap() {
69+
void concurrentReferenceHashMapSegmentDoTask() {
7070
int size = 10000;
7171
Map<String, String> map = new ConcurrentReferenceHashMap<>(size);
7272

@@ -88,6 +88,29 @@ void concurrentReferenceHashMap() {
8888
assertThat(map).hasSize(size);
8989
}
9090

91+
@Test
92+
void concurrentReferenceHashMapSegmentClear() {
93+
int size = 10000;
94+
Map<String, String> map = new ConcurrentReferenceHashMap<>(size);
95+
96+
CompletableFuture<Object> future1 = new CompletableFuture<>();
97+
testNonBlockingTask(() -> {
98+
for (int i = 0; i < size / 2; i++) {
99+
map.put("a" + i, "bar");
100+
}
101+
}, future1);
102+
103+
CompletableFuture<Object> future2 = new CompletableFuture<>();
104+
testNonBlockingTask(() -> {
105+
for (int i = 0; i < size; i++) {
106+
map.clear();
107+
}
108+
}, future2);
109+
110+
CompletableFuture.allOf(future1, future2).join();
111+
assertThat(map).isEmpty();
112+
}
113+
91114
private void testNonBlockingTask(NonBlockingTask task) {
92115
CompletableFuture<Object> future = new CompletableFuture<>();
93116
testNonBlockingTask(task, future);

0 commit comments

Comments
 (0)