File tree 1 file changed +24
-1
lines changed
spring-core/src/test/java/org/springframework/core
1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ void blockHoundIsInstalled() {
66
66
}
67
67
68
68
@ Test
69
- void concurrentReferenceHashMap () {
69
+ void concurrentReferenceHashMapSegmentDoTask () {
70
70
int size = 10000 ;
71
71
Map <String , String > map = new ConcurrentReferenceHashMap <>(size );
72
72
@@ -88,6 +88,29 @@ void concurrentReferenceHashMap() {
88
88
assertThat (map ).hasSize (size );
89
89
}
90
90
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
+
91
114
private void testNonBlockingTask (NonBlockingTask task ) {
92
115
CompletableFuture <Object > future = new CompletableFuture <>();
93
116
testNonBlockingTask (task , future );
You can’t perform that action at this time.
0 commit comments