Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for getContainerDataTypeExclusions() to handle case when container has already been deleted #5144

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8564,7 +8564,7 @@ private void removeDataTypeExclusion(Collection<Integer> rowIds, DataTypeForExcl
new SqlExecutor(getExpSchema()).execute(sql);
}

@NotNull private Map<String, Object>[] _getContainerDataTypeExclusions(@Nullable DataTypeForExclusion dataType, @Nullable String excludedContainerIdOrPath, @Nullable Integer dataTypeRowId)
@NotNull private List<Map<String, Object>> _getContainerDataTypeExclusions(@Nullable DataTypeForExclusion dataType, @Nullable String excludedContainerIdOrPath, @Nullable Integer dataTypeRowId)
{
SQLFragment sql = new SQLFragment("SELECT DataTypeRowId, DataType, ExcludedContainer FROM ")
.append(getTinfoDataTypeExclusion())
Expand All @@ -8583,8 +8583,13 @@ private void removeDataTypeExclusion(Collection<Integer> rowIds, DataTypeForExcl
if (!GUID.isGUID(excludedContainerIdOrPath))
{
Container container = ContainerManager.getForPath(excludedContainerIdOrPath);
if (container != null)
excludedContainerId = container.getId();
if (container == null)
{
// container not found, it may have been deleted, return empty array instead of making the DB query
return Collections.emptyList();
}

excludedContainerId = container.getId();
}

sql.append(and);
Expand All @@ -8600,13 +8605,13 @@ private void removeDataTypeExclusion(Collection<Integer> rowIds, DataTypeForExcl
sql.add(dataTypeRowId);
}

return new SqlSelector(getTinfoDataTypeExclusion().getSchema(), sql).getMapArray();
return Arrays.stream(new SqlSelector(getTinfoDataTypeExclusion().getSchema(), sql).getMapArray()).toList();
}

@Override
public @NotNull Map<DataTypeForExclusion, Set<Integer>> getContainerDataTypeExclusions(@NotNull String excludedContainerId)
{
Map<String, Object>[] exclusions = _getContainerDataTypeExclusions(null, excludedContainerId, null);
List<Map<String, Object>> exclusions = _getContainerDataTypeExclusions(null, excludedContainerId, null);

Map<DataTypeForExclusion, Set<Integer>> typeExclusions = new HashMap<>();
for (Map<String, Object> exclusion : exclusions)
Expand All @@ -8624,7 +8629,7 @@ private void removeDataTypeExclusion(Collection<Integer> rowIds, DataTypeForExcl
@Override
public Set<String> getDataTypeContainerExclusions(@NotNull DataTypeForExclusion dataType, @NotNull Integer dataTypeRowId)
{
Map<String, Object>[] exclusions = _getContainerDataTypeExclusions(dataType, null, dataTypeRowId);
List<Map<String, Object>> exclusions = _getContainerDataTypeExclusions(dataType, null, dataTypeRowId);
Set<String> excludedProjects = new HashSet<>();
for (Map<String, Object> exclusion : exclusions)
excludedProjects.add((String) exclusion.get("ExcludedContainer"));
Expand All @@ -8635,7 +8640,7 @@ public Set<String> getDataTypeContainerExclusions(@NotNull DataTypeForExclusion
private Set<Integer> _getContainerDataTypeExclusions(DataTypeForExclusion dataType, String excludedContainerId)
{
Set<Integer> excludedRowIds = new HashSet<>();
Map<String, Object>[] exclusions = _getContainerDataTypeExclusions(dataType, excludedContainerId, null);
List<Map<String, Object>> exclusions = _getContainerDataTypeExclusions(dataType, excludedContainerId, null);
for (Map<String, Object> exclusion : exclusions)
excludedRowIds.add((Integer) exclusion.get("DataTypeRowId"));

Expand Down