You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2019/05/13 05:20:44 UTC

[logging-log4j2] branch master updated (619707e -> 05fb297)

This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.


    from 619707e  LOG4J2-2602 - Update file time when size based triggering policy is used without a time-based triggering policy
     new f722142  LOG4J2-1103 remove used nodes when child is of list type
     new 05fb297  LOG4J2-1103 - FailoverAppender was failing with ERROR appender Failover has no parameter that matches element Failovers

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../plugins/visitors/PluginElementVisitor.java     |  1 +
 .../ValidatingPluginWithFailoverTest.java          | 99 ++++++++++++++++++++++
 src/changes/changes.xml                            |  3 +
 3 files changed, 103 insertions(+)
 create mode 100644 log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithFailoverTest.java


[logging-log4j2] 01/02: LOG4J2-1103 remove used nodes when child is of list type

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit f722142b34bbb132df4189fa7ef79ed731db136e
Author: Seán Dunne <se...@gmail.com>
AuthorDate: Thu Apr 4 19:55:12 2019 +0100

    LOG4J2-1103 remove used nodes when child is of list type
---
 .../plugins/visitors/PluginElementVisitor.java     |  1 +
 .../ValidatingPluginWithFailoverTest.java          | 99 ++++++++++++++++++++++
 2 files changed, 100 insertions(+)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginElementVisitor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginElementVisitor.java
index 95b3ae6..2e6e6ef 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginElementVisitor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginElementVisitor.java
@@ -63,6 +63,7 @@ public class PluginElementVisitor extends AbstractPluginVisitor<PluginElement> {
                     }
                     if (childObject.getClass().isArray()) {
                         log.append(Arrays.toString((Object[]) childObject)).append('}');
+                        node.getChildren().removeAll(used);
                         return childObject;
                     }
                     log.append(child.toString());
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithFailoverTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithFailoverTest.java
new file mode 100644
index 0000000..e52a545
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithFailoverTest.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.config.plugins.validation.validators;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Core;
+import org.apache.logging.log4j.core.appender.FailoverAppender;
+import org.apache.logging.log4j.core.appender.FailoversPlugin;
+import org.apache.logging.log4j.core.config.AppenderRef;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.NullConfiguration;
+import org.apache.logging.log4j.core.config.plugins.util.PluginBuilder;
+import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
+import org.apache.logging.log4j.core.config.plugins.util.PluginType;
+import org.apache.logging.log4j.status.StatusData;
+import org.apache.logging.log4j.status.StatusListener;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.hamcrest.Matchers.emptyCollectionOf;
+import static org.junit.Assert.*;
+
+public class ValidatingPluginWithFailoverTest {
+
+    private PluginType<FailoverAppender> plugin;
+    private Node node;
+
+    @SuppressWarnings("unchecked")
+    @Before
+    public void setUp() throws Exception {
+        final PluginManager manager = new PluginManager(Core.CATEGORY_NAME);
+        manager.collectPlugins();
+        plugin = (PluginType<FailoverAppender>) manager.getPluginType("failover");
+        assertNotNull("Rebuild this module to make sure annotation processing kicks in.", plugin);
+
+        AppenderRef appenderRef = AppenderRef.createAppenderRef("List", Level.ALL, null);
+        node = new Node(null, "failover", plugin);
+        Node failoversNode = new Node(node, "Failovers", manager.getPluginType("Failovers"));
+        Node appenderRefNode  = new Node(failoversNode, "appenderRef", manager.getPluginType("appenderRef"));
+        appenderRefNode.getAttributes().put("ref", "file");
+        appenderRefNode.setObject(appenderRef);
+        failoversNode.getChildren().add(appenderRefNode);
+        failoversNode.setObject(FailoversPlugin.createFailovers(appenderRef));
+        node.getAttributes().put("primary", "CONSOLE");
+        node.getAttributes().put("name", "Failover");
+        node.getChildren().add(failoversNode);
+    }
+
+    @Test
+    public void testDoesNotLog_NoParameterThatMatchesElement_message() {
+        final StoringStatusListener listener = new StoringStatusListener();
+        // @formatter:off
+        final PluginBuilder builder = new PluginBuilder(plugin).
+                withConfiguration(new NullConfiguration()).
+                withConfigurationNode(node);
+        // @formatter:on
+        StatusLogger.getLogger().registerListener(listener);
+
+        final FailoverAppender failoverAppender = (FailoverAppender) builder.build();
+
+        assertThat(listener.logs, emptyCollectionOf(StatusData.class));
+        assertNotNull(failoverAppender);
+        assertEquals("Failover", failoverAppender.getName());
+    }
+
+    private static class StoringStatusListener implements StatusListener {
+        private final List<StatusData> logs = new ArrayList<>();
+        @Override
+        public void log(StatusData data) {
+            logs.add(data);
+        }
+
+        @Override
+        public Level getStatusLevel() {
+            return Level.WARN;
+        }
+
+        @Override
+        public void close() {}
+    }
+}


[logging-log4j2] 02/02: LOG4J2-1103 - FailoverAppender was failing with ERROR appender Failover has no parameter that matches element Failovers

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 05fb29723a674ba2501eae0909b1a71a7c352e01
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun May 12 22:20:28 2019 -0700

    LOG4J2-1103 - FailoverAppender was failing with ERROR appender Failover has no parameter that matches element Failovers
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 53de4b5..fb20d48 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -390,6 +390,9 @@
       </action>
     </release>
     <release version="2.12.0" date="2019-MM-DD" description="GA Release 2.12.0">
+      <action issue="LOG4J2-1103" dev="rgoers" type="fix" due-to="Seán Dunne">
+        FailoverAppender was failing with ERROR appender Failover has no parameter that matches element Failovers.
+      </action>
       <action issue="LOG4J2-2602" dev="rgoers" type="fix">
         Update file time when size based triggering policy is used without a time-based triggering policy.
       </action>