This is an automated email from the ASF dual-hosted git repository. cshannon pushed a commit to branch 3.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/3.1 by this push: new 4368f98bd0 Update Table Id validator to accept all Accumulo tables (#5065) 4368f98bd0 is described below commit 4368f98bd0b21d2c4bd7d17a2040720ce4084436 Author: Christopher L. Shannon <cshan...@apache.org> AuthorDate: Fri Nov 15 09:47:37 2024 -0500 Update Table Id validator to accept all Accumulo tables (#5065) Fixes validation for table ids by making sure all tables in the accumulo namespace are considered and not just root and metadata This closes #5059 --- core/src/main/java/org/apache/accumulo/core/util/Validators.java | 2 +- .../test/java/org/apache/accumulo/core/util/ValidatorsTest.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/util/Validators.java b/core/src/main/java/org/apache/accumulo/core/util/Validators.java index 084c912653..6bc4564528 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/Validators.java +++ b/core/src/main/java/org/apache/accumulo/core/util/Validators.java @@ -192,7 +192,7 @@ public class Validators { if (id == null) { return Optional.of("Table id must not be null"); } - if (AccumuloTable.ROOT.tableId().equals(id) || AccumuloTable.METADATA.tableId().equals(id) + if (AccumuloTable.allTableIds().contains(id) || VALID_ID_PATTERN.matcher(id.canonical()).matches()) { return Validator.OK; } diff --git a/core/src/test/java/org/apache/accumulo/core/util/ValidatorsTest.java b/core/src/test/java/org/apache/accumulo/core/util/ValidatorsTest.java index 9bc5c7d6aa..87920d1b91 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/ValidatorsTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/ValidatorsTest.java @@ -23,8 +23,10 @@ import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.Arrays; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.apache.accumulo.core.clientImpl.Namespace; import org.apache.accumulo.core.data.TableId; @@ -140,8 +142,9 @@ public class ValidatorsTest { public void test_VALID_TABLE_ID() { Validator<TableId> v = Validators.VALID_TABLE_ID; checkNull(v::validate); - assertAllValidate(v, List.of(AccumuloTable.ROOT.tableId(), AccumuloTable.METADATA.tableId(), - TableId.of("111"), TableId.of("aaaa"), TableId.of("r2d2"))); + assertAllValidate(v, Arrays.stream(AccumuloTable.values()).map(AccumuloTable::tableId) + .collect(Collectors.toList())); + assertAllValidate(v, List.of(TableId.of("111"), TableId.of("aaaa"), TableId.of("r2d2"))); assertAllThrow(v, List.of(TableId.of(""), TableId.of("#0(U!$"), TableId.of(" #0(U!$. "), TableId.of("."), TableId.of(" "), TableId.of("C3P0"))); }