You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/05/13 22:07:27 UTC

[GitHub] [accumulo] ctubbsii commented on a diff in pull request #2701: Use constant for keyword name in KeywordExecutable sub-classes.

ctubbsii commented on code in PR #2701:
URL: https://github.com/apache/accumulo/pull/2701#discussion_r872867422


##########
test/src/main/java/org/apache/accumulo/test/start/KeywordStartIT.java:
##########
@@ -109,34 +109,35 @@ public void testCheckDuplicates() {
   public void testExpectedClasses() {
     assumeTrue(new File(System.getProperty("user.dir") + "/src").exists());
     TreeMap<String,Class<? extends KeywordExecutable>> expectSet = new TreeMap<>();
-    expectSet.put("admin", Admin.class);
-    expectSet.put("check-compaction-config", CheckCompactionConfig.class);
-    expectSet.put("check-server-config", CheckServerConfig.class);
-    expectSet.put("compaction-coordinator", CoordinatorExecutable.class);
-    expectSet.put("compactor", CompactorExecutable.class);
-    expectSet.put("config-upgrade", ConfigPropertyUpgrader.class);
-    expectSet.put("convert-config", ConvertConfig.class);
-    expectSet.put("create-token", CreateToken.class);
-    expectSet.put("ec-admin", ECAdmin.class);
-    expectSet.put("gc", GCExecutable.class);
-    expectSet.put("generate-splits", GenerateSplits.class);
-    expectSet.put("help", Help.class);
-    expectSet.put("info", Info.class);
-    expectSet.put("init", Initialize.class);
-    expectSet.put("login-info", LoginProperties.class);
-    expectSet.put("manager", ManagerExecutable.class);
-    expectSet.put("master", org.apache.accumulo.manager.MasterExecutable.class);
-    expectSet.put("minicluster", MiniClusterExecutable.class);
-    expectSet.put("monitor", MonitorExecutable.class);
-    expectSet.put("rfile-info", PrintInfo.class);
-    expectSet.put("wal-info", LogReader.class);
-    expectSet.put("shell", Shell.class);
-    expectSet.put("tserver", TServerExecutable.class);
-    expectSet.put("version", Version.class);
-    expectSet.put("zookeeper", ZooKeeperMain.class);
-    expectSet.put("create-empty", CreateEmpty.class);
-    expectSet.put("split-large", SplitLarge.class);
-    expectSet.put("zoo-zap", ZooZap.class);
+    expectSet.put(Admin.EXE_NAME, Admin.class);
+    expectSet.put(CheckCompactionConfig.EXE_NAME, CheckCompactionConfig.class);

Review Comment:
   The whole point of the checks here is to ensure that the string isn't changed. By doing this level of indirection, if the value of the constant `EXE_NAME` is changed, then this test will pass, even if it shouldn't have been changed. This test no longer guards against such changes.
   This is now effectively just checking that `SomeClass.EXE_NAME == SomeClass.keyword()` for every `SomeClass`. But, that's basically tautological the way all the classes have changed.



##########
core/src/main/java/org/apache/accumulo/core/file/rfile/CreateEmpty.java:
##########
@@ -83,7 +84,7 @@ public static void main(String[] args) throws Exception {
 
   @Override
   public String keyword() {
-    return "create-empty";
+    return EXE_NAME;

Review Comment:
   I'm not sure I see the benefit of this... it seems to just relocate the constant from an inline literal to a new line that's really only ever needed once (see my subsequent comment about why it's not needed for the test).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org