From 697bc266ce3fca24ce6e3a90578e8858d6147902 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Thu, 31 Aug 2017 09:54:35 -0400 Subject: [PATCH] Upgrade to Log4j 2.9.0 This commit upgrades the Log4j dependency from version 2.8.2 to version 2.9.0. Relates #26450 --- buildSrc/version.properties | 2 +- core/build.gradle | 8 ++++---- core/licenses/log4j-1.2-api-2.8.2.jar.sha1 | 1 - core/licenses/log4j-1.2-api-2.9.0.jar.sha1 | 1 + core/licenses/log4j-api-2.8.2.jar.sha1 | 1 - core/licenses/log4j-api-2.9.0.jar.sha1 | 1 + core/licenses/log4j-core-2.8.2.jar.sha1 | 1 - core/licenses/log4j-core-2.9.0.jar.sha1 | 1 + .../org/elasticsearch/common/logging/ESLoggerFactory.java | 7 ++++++- docs/java-api/index.asciidoc | 4 ++-- 10 files changed, 16 insertions(+), 11 deletions(-) delete mode 100644 core/licenses/log4j-1.2-api-2.8.2.jar.sha1 create mode 100644 core/licenses/log4j-1.2-api-2.9.0.jar.sha1 delete mode 100644 core/licenses/log4j-api-2.8.2.jar.sha1 create mode 100644 core/licenses/log4j-api-2.9.0.jar.sha1 delete mode 100644 core/licenses/log4j-core-2.8.2.jar.sha1 create mode 100644 core/licenses/log4j-core-2.9.0.jar.sha1 diff --git a/buildSrc/version.properties b/buildSrc/version.properties index c03640a3164..96840dfa6f8 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -8,7 +8,7 @@ jts = 1.13 jackson = 2.8.6 snakeyaml = 1.15 # When updating log4j, please update also docs/java-api/index.asciidoc -log4j = 2.8.2 +log4j = 2.9.0 slf4j = 1.6.2 # when updating the JNA version, also update the version in buildSrc/build.gradle diff --git a/core/build.gradle b/core/build.gradle index 5791631df72..fe60cd8b1cf 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -157,12 +157,11 @@ thirdPartyAudit.excludes = [ 'com.fasterxml.jackson.databind.ObjectMapper', // from log4j - 'com.beust.jcommander.IStringConverter', - 'com.beust.jcommander.JCommander', 'com.conversantmedia.util.concurrent.DisruptorBlockingQueue', 'com.conversantmedia.util.concurrent.SpinPolicy', 'com.fasterxml.jackson.annotation.JsonInclude$Include', 'com.fasterxml.jackson.databind.DeserializationContext', + 'com.fasterxml.jackson.databind.DeserializationFeature', 'com.fasterxml.jackson.databind.JsonMappingException', 'com.fasterxml.jackson.databind.JsonNode', 'com.fasterxml.jackson.databind.Module$SetupContext', @@ -203,11 +202,11 @@ thirdPartyAudit.excludes = [ 'javax.jms.Connection', 'javax.jms.ConnectionFactory', 'javax.jms.Destination', + 'javax.jms.JMSException', + 'javax.jms.MapMessage', 'javax.jms.Message', 'javax.jms.MessageConsumer', - 'javax.jms.MessageListener', 'javax.jms.MessageProducer', - 'javax.jms.ObjectMessage', 'javax.jms.Session', 'javax.mail.Authenticator', 'javax.mail.Message$RecipientType', @@ -247,6 +246,7 @@ thirdPartyAudit.excludes = [ 'org.osgi.framework.BundleEvent', 'org.osgi.framework.BundleReference', 'org.osgi.framework.FrameworkUtil', + 'org.osgi.framework.ServiceRegistration', 'org.osgi.framework.SynchronousBundleListener', 'org.osgi.framework.wiring.BundleWire', 'org.osgi.framework.wiring.BundleWiring', diff --git a/core/licenses/log4j-1.2-api-2.8.2.jar.sha1 b/core/licenses/log4j-1.2-api-2.8.2.jar.sha1 deleted file mode 100644 index 39d09bec717..00000000000 --- a/core/licenses/log4j-1.2-api-2.8.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f1543534b8413aac91fa54d1fff65dfff76818cd \ No newline at end of file diff --git a/core/licenses/log4j-1.2-api-2.9.0.jar.sha1 b/core/licenses/log4j-1.2-api-2.9.0.jar.sha1 new file mode 100644 index 00000000000..43b49b4d550 --- /dev/null +++ b/core/licenses/log4j-1.2-api-2.9.0.jar.sha1 @@ -0,0 +1 @@ +7e2f1637394eecdc3c8cd067b3f2cf4801b1bcf6 \ No newline at end of file diff --git a/core/licenses/log4j-api-2.8.2.jar.sha1 b/core/licenses/log4j-api-2.8.2.jar.sha1 deleted file mode 100644 index 7c7c1da835c..00000000000 --- a/core/licenses/log4j-api-2.8.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -e590eeb783348ce8ddef205b82127f9084d82bf3 \ No newline at end of file diff --git a/core/licenses/log4j-api-2.9.0.jar.sha1 b/core/licenses/log4j-api-2.9.0.jar.sha1 new file mode 100644 index 00000000000..e6e9c445ad1 --- /dev/null +++ b/core/licenses/log4j-api-2.9.0.jar.sha1 @@ -0,0 +1 @@ +e0dcd508dfc4864a2f5a1963d6ffad170d970375 \ No newline at end of file diff --git a/core/licenses/log4j-core-2.8.2.jar.sha1 b/core/licenses/log4j-core-2.8.2.jar.sha1 deleted file mode 100644 index 4e6c7b4fcc3..00000000000 --- a/core/licenses/log4j-core-2.8.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -979fc0cf8460302e4ffbfe38c1b66a99450b0bb7 \ No newline at end of file diff --git a/core/licenses/log4j-core-2.9.0.jar.sha1 b/core/licenses/log4j-core-2.9.0.jar.sha1 new file mode 100644 index 00000000000..ecd8fbace67 --- /dev/null +++ b/core/licenses/log4j-core-2.9.0.jar.sha1 @@ -0,0 +1 @@ +052f6548ae1688e126c29b5dc400929dc0128615 \ No newline at end of file diff --git a/core/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java b/core/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java index 16f47f78ddb..1d6fdf9cd2d 100644 --- a/core/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java +++ b/core/src/main/java/org/elasticsearch/common/logging/ESLoggerFactory.java @@ -46,7 +46,12 @@ public final class ESLoggerFactory { } public static Logger getLogger(String prefix, Class clazz) { - return getLogger(prefix, LogManager.getLogger(clazz)); + /* + * Do not use LogManager#getLogger(Class) as this now uses Class#getCanonicalName under the hood; as this returns null for local and + * anonymous classes, any place we create, for example, an abstract component defined as an anonymous class (e.g., in tests) will + * result in a logger with a null name which will blow up in a lookup inside of Log4j. + */ + return getLogger(prefix, LogManager.getLogger(clazz.getName())); } public static Logger getLogger(String prefix, Logger logger) { diff --git a/docs/java-api/index.asciidoc b/docs/java-api/index.asciidoc index bdf85f515e8..af375813d42 100644 --- a/docs/java-api/index.asciidoc +++ b/docs/java-api/index.asciidoc @@ -83,7 +83,7 @@ You need to also include Log4j 2 dependencies: org.apache.logging.log4j log4j-core - 2.8.2 + 2.9.0 -------------------------------------------------- @@ -111,7 +111,7 @@ If you want to use another logger than Log4j 2, you can use http://www.slf4j.org org.apache.logging.log4j log4j-to-slf4j - 2.8.2 + 2.9.0 org.slf4j