vy commented on code in PR #2230:
URL: https://github.com/apache/logging-log4j2/pull/2230#discussion_r1464849027


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java:
##########
@@ -1178,4 +1152,28 @@ public NanoClock getNanoClock() {
     public void setNanoClock(final NanoClock nanoClock) {
         instanceFactory.registerBinding(NanoClock.KEY, () -> nanoClock);
     }
+
+    @Override
+    public void addExtension(ConfigurationExtension extension) {
+        Objects.requireNonNull(extension);
+        extensions = Arrays.copyOf(extensions, extensions.length + 1);
+        extensions[extensions.length - 1] = extension;
+    }
+
+    @Override
+    public <T extends ConfigurationExtension> T getExtension(Class<T> 
extensionType) {
+        T result = null;
+        for (final ConfigurationExtension extension : extensions) {
+            if (extensionType.isInstance(extension)) {
+                if (result == null) {
+                    result = (T) extension;
+                } else {
+                    LOGGER.warn(
+                            "Multiple configuration elements found for type 
{}. Only the first will be used.",
+                            extensionType.getName());
+                }
+            }
+        }
+        return result;
+    }

Review Comment:
   > My idea behind this is to prevent plugin implementors from abusing this 
feature by adding a lot of new elements to the `<Configuration>` tag.
   
   I understand the concern. Though my point still stands: suppressing 
unexpected conditions is... unexpected, and, hence, not right. We can also 
address your concern by simply failing, which would be of my preference.
   
   For the record, let's also agree that _"plugin implementors"_ is a handful 
of people around the globe.



-- 
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-unsubscr...@logging.apache.org

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

Reply via email to