adoroszlai commented on code in PR #12141:
URL: https://github.com/apache/ozone/pull/12141#discussion_r4716404894


##########
hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigFileGenerator.java:
##########
@@ -130,26 +133,65 @@ private static boolean isTestOutput(Filer filer) throws 
IOException {
   private void writeConfigAnnotations(ConfigGroup configGroup,
       ConfigFileAppender appender,
       TypeElement typeElement) {
-    for (Element element : typeElement.getEnclosedElements()) {
-      if (element.getKind() == ElementKind.FIELD) {
-        if (element.getAnnotation(Config.class) != null) {
-
-          Config configAnnotation = element.getAnnotation(Config.class);
-          String prefix = configGroup.prefix() + ".";
-          String key = configAnnotation.key();
-          if (!key.startsWith(prefix)) {
-            processingEnv.getMessager().printMessage(Kind.ERROR,
-                prefix + " is not a prefix of " + key,
-                typeElement);
-          }
-
-          appender.addConfig(key,
-              configAnnotation.defaultValue(),
-              configAnnotation.description(),
-              configAnnotation.tags());
+    // Collect the key of every @Config field in the class and its
+    // superclass chain, like ConfigurationReflectionUtil does at runtime,
+    // and fail the compilation on a duplicated key.
+    Map<String, String> keyToField = new HashMap<>();
+    for (TypeElement clazz = typeElement; clazz != null;
+        clazz = superclassOf(clazz)) {

Review Comment:
   nit: please don't wrap at 80 chars, use max. line width 120 (everywhere).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to