Merge branch '6.1.x'
This commit is contained in:
@@ -441,10 +441,13 @@ public class ReactiveAdapterRegistry {
|
||||
public void applyTo(BlockHound.Builder builder) {
|
||||
// Avoid hard references potentially anywhere in spring-core (no need for structural dependency)
|
||||
|
||||
String className = "org.springframework.util.ConcurrentReferenceHashMap$Segment";
|
||||
builder.allowBlockingCallsInside(className, "doTask");
|
||||
builder.allowBlockingCallsInside(className, "clear");
|
||||
builder.allowBlockingCallsInside(className, "restructure");
|
||||
String segmentClassName = "org.springframework.util.ConcurrentReferenceHashMap$Segment";
|
||||
builder.allowBlockingCallsInside(segmentClassName, "doTask");
|
||||
builder.allowBlockingCallsInside(segmentClassName, "clear");
|
||||
builder.allowBlockingCallsInside(segmentClassName, "restructure");
|
||||
|
||||
String referenceManagerClassName = "org.springframework.util.ConcurrentReferenceHashMap$ReferenceManager";
|
||||
builder.allowBlockingCallsInside(referenceManagerClassName, "pollForPurge");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class SpringCoreBlockHoundIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void concurrentReferenceHashMap() {
|
||||
void concurrentReferenceHashMapSegmentDoTask() {
|
||||
int size = 10000;
|
||||
Map<String, String> map = new ConcurrentReferenceHashMap<>(size);
|
||||
|
||||
@@ -88,6 +88,29 @@ class SpringCoreBlockHoundIntegrationTests {
|
||||
assertThat(map).hasSize(size);
|
||||
}
|
||||
|
||||
@Test
|
||||
void concurrentReferenceHashMapSegmentClear() {
|
||||
int size = 10000;
|
||||
Map<String, String> map = new ConcurrentReferenceHashMap<>(size);
|
||||
|
||||
CompletableFuture<Object> future1 = new CompletableFuture<>();
|
||||
testNonBlockingTask(() -> {
|
||||
for (int i = 0; i < size / 2; i++) {
|
||||
map.put("a" + i, "bar");
|
||||
}
|
||||
}, future1);
|
||||
|
||||
CompletableFuture<Object> future2 = new CompletableFuture<>();
|
||||
testNonBlockingTask(() -> {
|
||||
for (int i = 0; i < size; i++) {
|
||||
map.clear();
|
||||
}
|
||||
}, future2);
|
||||
|
||||
CompletableFuture.allOf(future1, future2).join();
|
||||
assertThat(map).isEmpty();
|
||||
}
|
||||
|
||||
private void testNonBlockingTask(NonBlockingTask task) {
|
||||
CompletableFuture<Object> future = new CompletableFuture<>();
|
||||
testNonBlockingTask(task, future);
|
||||
|
||||
Reference in New Issue
Block a user