You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2020/02/03 23:58:07 UTC

[logging-log4j2] branch master updated: [LOG4J2-2770] NullPointerException after reconfiguring via JMX.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 91f041e  [LOG4J2-2770] NullPointerException after reconfiguring via JMX.
91f041e is described below

commit 91f041e40c68042ffe422bff0b90d329e49c7b36
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Feb 3 18:58:02 2020 -0500

    [LOG4J2-2770] NullPointerException after reconfiguring via JMX.
---
 .../log4j/core/config/ConfigurationSource.java     |  2 +-
 .../log4j/core/config/ConfigurationSourceTest.java | 33 ++++++++++++++++++++++
 src/changes/changes.xml                            |  3 ++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
index bbbb483..180043d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java
@@ -141,7 +141,7 @@ public class ConfigurationSource {
     }
 
     private ConfigurationSource(final byte[] data, final URL url, long lastModified) {
-        Objects.requireNonNull(data, "data is null");
+        this.data = Objects.requireNonNull(data, "data is null");
         this.stream = new ByteArrayInputStream(data);
         this.file = null;
         this.url = url;
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationSourceTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationSourceTest.java
new file mode 100644
index 0000000..5ca42f2
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationSourceTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+import java.io.ByteArrayInputStream;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ConfigurationSourceTest {
+
+    @Test
+    public void testJira_LOG4J2_2770_byteArray() throws Exception {
+        ConfigurationSource configurationSource = new ConfigurationSource(
+                new ByteArrayInputStream(new byte[] { 'a', 'b' }));
+        Assert.assertNotNull(configurationSource.resetInputStream());
+    }
+}
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0323958..68449fb 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -205,6 +205,9 @@
       <action issue="LOG4J2-2762" dev="ggregory" type="fix" due-to="Gary Gregory">
         [JDBC] MS-SQL Server JDBC driver throws SQLServerException when inserting a null value for a VARBINARY column.
       </action>
+      <action issue="LOG4J2-2770" dev="ggregory" type="fix" due-to="Bill Kuker">
+        NullPointerException after reconfiguring via JMX.
+      </action>
     </release>
     <release version="2.13.0" date="2019-12-11" description="GA Release 2.13.0">
       <action issue="LOG4J2-2058" dev="rgoers" type="fix">