[release-2.16] Fix concurrent issue during bundle file concurrent generation testing (#6045)

This is an automated cherry-pick of #6043

/assign JohnNiang

```release-note
None
```
pull/6050/head
Halo Dev Bot 2024-06-06 14:28:14 +08:00 committed by GitHub
parent 3836b22090
commit 0bd8611144
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 6 deletions

View File

@ -432,17 +432,20 @@ class PluginServiceImplTest {
var probes = new ArrayList<PublisherProbe<DataBuffer>>(); var probes = new ArrayList<PublisherProbe<DataBuffer>>();
List<? extends Future<?>> futures = IntStream.range(0, 10) List<? extends Future<?>> futures = IntStream.range(0, 10)
.mapToObj(i -> executorService.submit(() -> { .mapToObj(i -> {
var fakeContent = Mono.<DataBuffer>just(sharedInstance.wrap( var fakeContent = Mono.<DataBuffer>just(sharedInstance.wrap(
("fake-content-" + i).getBytes(UTF_8) ("fake-content-" + i).getBytes(UTF_8)
)); ));
var probe = PublisherProbe.of(fakeContent); var probe = PublisherProbe.of(fakeContent);
probes.add(probe); probes.add(probe);
return executorService.submit(
() -> {
cache.computeIfAbsent("fake-version", probe.mono()) cache.computeIfAbsent("fake-version", probe.mono())
.as(StepVerifier::create) .as(StepVerifier::create)
.expectNextCount(1) .expectNextCount(1)
.verifyComplete(); .verifyComplete();
})) });
})
.toList(); .toList();
executorService.shutdown(); executorService.shutdown();
futures.forEach(future -> { futures.forEach(future -> {