|
26 | 26 | import io.debezium.relational.TableId; |
27 | 27 | import io.debezium.relational.history.TableChanges; |
28 | 28 |
|
| 29 | +import java.util.ArrayList; |
| 30 | +import java.util.HashMap; |
| 31 | +import java.util.LinkedHashMap; |
29 | 32 | import java.util.List; |
30 | 33 | import java.util.Map; |
31 | 34 | import java.util.Objects; |
@@ -89,17 +92,19 @@ public SnapshotPendingSplitsState( |
89 | 92 | boolean isRemainingTablesCheckpointed, |
90 | 93 | Map<String, Long> splitFinishedCheckpointIds, |
91 | 94 | ChunkSplitterState chunkSplitterState) { |
92 | | - this.alreadyProcessedTables = alreadyProcessedTables; |
93 | | - this.remainingSplits = remainingSplits; |
94 | | - this.assignedSplits = assignedSplits; |
95 | | - this.splitFinishedOffsets = splitFinishedOffsets; |
| 95 | + // FLINK-38061: make defensive copy to avoid potential concurrent modification of the |
| 96 | + // collections. |
| 97 | + this.alreadyProcessedTables = new ArrayList<>(alreadyProcessedTables); |
| 98 | + this.remainingSplits = new ArrayList<>(remainingSplits); |
| 99 | + this.assignedSplits = new LinkedHashMap<>(assignedSplits); |
| 100 | + this.splitFinishedOffsets = new HashMap<>(splitFinishedOffsets); |
96 | 101 | this.assignerStatus = assignerStatus; |
97 | | - this.remainingTables = remainingTables; |
| 102 | + this.remainingTables = new ArrayList<>(remainingTables); |
98 | 103 | this.isTableIdCaseSensitive = isTableIdCaseSensitive; |
99 | 104 | this.isRemainingTablesCheckpointed = isRemainingTablesCheckpointed; |
100 | | - this.tableSchemas = tableSchemas; |
| 105 | + this.tableSchemas = new HashMap<>(tableSchemas); |
101 | 106 | this.chunkSplitterState = chunkSplitterState; |
102 | | - this.splitFinishedCheckpointIds = splitFinishedCheckpointIds; |
| 107 | + this.splitFinishedCheckpointIds = new HashMap<>(splitFinishedCheckpointIds); |
103 | 108 | } |
104 | 109 |
|
105 | 110 | public Map<String, Long> getSplitFinishedCheckpointIds() { |
|
0 commit comments