Skip to content

[Improve][Core] Avoid relying on index alignment between keySet and values in getSinkTables() #10658

@dybyte

Description

@dybyte

Search before asking

  • I had searched in the feature and found no similar feature requirement.

Description

public List<TablePath> getSinkTables() {
List<TablePath> tablePaths = new ArrayList<>();
List<SeaTunnelSink> values = new ArrayList<>(sinks.values());
for (int i = 0; i < values.size(); i++) {
if (values.get(i).getWriteCatalogTable().isPresent()) {
tablePaths.add(
((CatalogTable) values.get(i).getWriteCatalogTable().get()).getTablePath());
} else {
tablePaths.add(sinks.keySet().toArray(new TablePath[0])[i]);
}
}
return tablePaths;
}

It would be safer and clearer to iterate over entrySet() directly to ensure correct key-value association.

Usage Scenario

No response

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions