adutra commented on code in PR #3755:
URL: https://github.com/apache/polaris/pull/3755#discussion_r2821736311


##########
polaris-core/src/main/java/org/apache/polaris/core/config/PolarisConfiguration.java:
##########
@@ -55,33 +59,33 @@ public abstract class PolarisConfiguration<T> {
    * configs.
    */
   private static void registerConfiguration(PolarisConfiguration<?> 
configuration) {
-    for (PolarisConfiguration<?> existingConfiguration : allConfigurations) {
-      if (existingConfiguration.key.equals(configuration.key)) {
+    if (ALL_CONFIGURATIONS.putIfAbsent(configuration.key(), configuration) != 
null) {
+      throw new IllegalArgumentException(
+          String.format("Config '%s' is already in use", configuration.key));
+    }
+    if (configuration.hasCatalogConfig()) {
+      if (!ALL_CATALOG_CONFIGS.add(configuration.catalogConfig())) {
         throw new IllegalArgumentException(
-            String.format("Config '%s' is already in use", configuration.key));
-      } else {
-        var configs =
-            Stream.of(
-                    configuration.catalogConfigImpl,
-                    configuration.catalogConfigUnsafeImpl,
-                    existingConfiguration.catalogConfigImpl,
-                    existingConfiguration.catalogConfigUnsafeImpl)
-                .flatMap(Optional::stream)
-                .collect(Collectors.groupingBy(Function.identity(), 
Collectors.counting()));
-        for (var entry : configs.entrySet()) {
-          if (entry.getValue() > 1) {
-            throw new IllegalArgumentException(
-                String.format("Catalog config %s is already in use", 
entry.getKey()));
-          }
-        }
+            String.format("Catalog config '%s' is already in use", 
configuration.catalogConfig()));
+      }
+    }
+    if (configuration.hasCatalogConfigUnsafe()) {
+      if (!ALL_CATALOG_CONFIGS.add(configuration.catalogConfigUnsafe())) {
+        throw new IllegalArgumentException(
+            String.format(
+                "Catalog config '%s' is already in use", 
configuration.catalogConfigUnsafe()));
       }
     }
-    allConfigurations.add(configuration);
   }
 
-  /** Returns a list of all PolarisConfigurations that have been registered */
+  /** Returns a list of all PolarisConfigurations that have been registered. */
   public static List<PolarisConfiguration<?>> getAllConfigurations() {

Review Comment:
   Now unused.



-- 
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]

Reply via email to