Skip to content

Commit 06d240b

Browse files
committed
Merge branch '6.1.x'
2 parents 20bc5ef + de4ff4b commit 06d240b

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,13 @@ public static class SpringCoreBlockHoundIntegration implements BlockHoundIntegra
441441
public void applyTo(BlockHound.Builder builder) {
442442
// Avoid hard references potentially anywhere in spring-core (no need for structural dependency)
443443

444-
String className = "org.springframework.util.ConcurrentReferenceHashMap$Segment";
445-
builder.allowBlockingCallsInside(className, "doTask");
446-
builder.allowBlockingCallsInside(className, "clear");
447-
builder.allowBlockingCallsInside(className, "restructure");
444+
String segmentClassName = "org.springframework.util.ConcurrentReferenceHashMap$Segment";
445+
builder.allowBlockingCallsInside(segmentClassName, "doTask");
446+
builder.allowBlockingCallsInside(segmentClassName, "clear");
447+
builder.allowBlockingCallsInside(segmentClassName, "restructure");
448+
449+
String referenceManagerClassName = "org.springframework.util.ConcurrentReferenceHashMap$ReferenceManager";
450+
builder.allowBlockingCallsInside(referenceManagerClassName, "pollForPurge");
448451
}
449452
}
450453

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

Lines changed: 24 additions & 1 deletion
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)