@@ -105,29 +105,28 @@ void mergeAndSaveIsConcurrencySafe(@TempDir Path tmp) throws Exception {
105105 int entriesPerThread = 25 ;
106106
107107 CountDownLatch start = new CountDownLatch (1 );
108- try (ExecutorService pool = Executors .newFixedThreadPool (threads )) {
109- List <Future <?>> futures = new ArrayList <>();
110-
111- for (int t = 0 ; t < threads ; t ++) {
112- final int tid = t ;
113- futures .add (
114- pool .submit (
115- () -> {
116- start .await ();
117- Map <String , Set <String >> entries = new HashMap <>();
118- for (int i = 0 ; i < entriesPerThread ; i ++) {
119- String testId = "module" + tid + ".T" + i + "#go" ;
120- entries .put (testId , new HashSet <>(List .of ("c/C" + tid + "_" + i )));
121- }
122- CoverageMapStore .mergeAndSave (file , entries , "h" + tid );
123- return null ;
124- }));
125- }
126-
127- start .countDown ();
128- for (Future <?> f : futures ) f .get (30 , TimeUnit .SECONDS );
108+ ExecutorService pool = Executors .newFixedThreadPool (threads );
109+ List <Future <?>> futures = new ArrayList <>();
110+
111+ for (int t = 0 ; t < threads ; t ++) {
112+ final int tid = t ;
113+ futures .add (
114+ pool .submit (
115+ () -> {
116+ start .await ();
117+ Map <String , Set <String >> entries = new HashMap <>();
118+ for (int i = 0 ; i < entriesPerThread ; i ++) {
119+ String testId = "module" + tid + ".T" + i + "#go" ;
120+ entries .put (testId , new HashSet <>(List .of ("c/C" + tid + "_" + i )));
121+ }
122+ CoverageMapStore .mergeAndSave (file , entries , "h" + tid );
123+ return null ;
124+ }));
129125 }
130126
127+ start .countDown ();
128+ for (Future <?> f : futures ) f .get (30 , TimeUnit .SECONDS );
129+
131130 CoverageMap loaded = CoverageMapStore .load (file );
132131 assertNotNull (loaded );
133132 assertEquals (threads * entriesPerThread , loaded .size ());
0 commit comments