Skip to content

Commit 6f59e01

Browse files
authored
Refactor hasBlock
1 parent bc938f8 commit 6f59e01

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexStateService.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,19 +1180,8 @@ public static Tuple<ClusterState, List<RemoveBlockResult>> removeIndexBlock(
11801180
final Settings indexSettings = indexMetadata.getSettings();
11811181
final boolean hasBlockSetting = block.setting().get(indexSettings);
11821182

1183-
boolean hasAnyBlock = hasBlockSetting;
1184-
1185-
final Set<ClusterBlock> clusterBlocks = projectState.blocks().indices(projectState.projectId()).get(index.getName());
1186-
if (clusterBlocks != null) {
1187-
for (ClusterBlock clusterBlock : clusterBlocks) {
1188-
if (clusterBlock.id() == block.block.id()) {
1189-
hasAnyBlock = true;
1190-
break;
1191-
}
1192-
}
1193-
}
1194-
1195-
if (hasAnyBlock == false) {
1183+
final boolean hasBlock = projectState.blocks().hasIndexBlock(projectState.projectId(), index.getName(), block.block);
1184+
if (hasBlockSetting == false && hasBlock == false) {
11961185
results.put(index.getName(), new RemoveBlockResult(index));
11971186
continue;
11981187
}

0 commit comments

Comments
 (0)