ppkarwasz commented on code in PR #2230: URL: https://github.com/apache/logging-log4j2/pull/2230#discussion_r1465008485
########## 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: IMHO this unexpected condition should be dealt in a uniform way. E.g. if a user adds multiple `<Disruptor>` elements all but one should be ignored and a warning should be issued. This is better than the logic for multiple `<Appenders>` elements, where all but one are ignored **without** a warning. -- 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