|
33 | 33 | class CategorySyncIT { |
34 | 34 | private CategorySync categorySync; |
35 | 35 |
|
36 | | - private List<String> callBackErrorResponses = new ArrayList<>(); |
37 | | - private List<Throwable> callBackExceptions = new ArrayList<>(); |
38 | | - private List<String> callBackWarningResponses = new ArrayList<>(); |
| 36 | + // Use thread-safe lists because callbacks are called from parallel threads |
| 37 | + private List<String> callBackErrorResponses = |
| 38 | + java.util.Collections.synchronizedList(new ArrayList<>()); |
| 39 | + private List<Throwable> callBackExceptions = |
| 40 | + java.util.Collections.synchronizedList(new ArrayList<>()); |
| 41 | + private List<String> callBackWarningResponses = |
| 42 | + java.util.Collections.synchronizedList(new ArrayList<>()); |
39 | 43 | private ReferenceIdToKeyCache referenceIdToKeyCache; |
40 | 44 |
|
41 | 45 | /** |
@@ -68,9 +72,9 @@ void setupTest() { |
68 | 72 | CategoryITUtils.ensureCategories( |
69 | 73 | TestClientUtils.CTP_TARGET_CLIENT, CategoryITUtils.getCategoryDrafts(null, 2, true)); |
70 | 74 |
|
71 | | - callBackErrorResponses = new ArrayList<>(); |
72 | | - callBackExceptions = new ArrayList<>(); |
73 | | - callBackWarningResponses = new ArrayList<>(); |
| 75 | + callBackErrorResponses = java.util.Collections.synchronizedList(new ArrayList<>()); |
| 76 | + callBackExceptions = java.util.Collections.synchronizedList(new ArrayList<>()); |
| 77 | + callBackWarningResponses = java.util.Collections.synchronizedList(new ArrayList<>()); |
74 | 78 | categorySync = new CategorySync(buildCategorySyncOptions(50)); |
75 | 79 | referenceIdToKeyCache = new CaffeineReferenceIdToKeyCacheImpl(); |
76 | 80 | } |
|
0 commit comments