Skip to content

Commit c9fb1ee

Browse files
authored
Remove Log4j 1.2 API as a dependency (#42702)
We had this as a dependency for legacy dependencies that still needed the Log4j 1.2 API. This appears to no longer be necessary, so this commit removes this artifact as a dependency. To remove this dependency, we had to fix a few places where we were accidentally relying on Log4j 1.2 instead of Log4j 2 (easy to do, since both APIs were on the compile-time classpath). Finally, we can remove our custom Netty logger factory. This was needed when we were on Log4j 1.2 and handled logging in our own unique way. When we migrated to Log4j 2 we could have dropped this dependency. However, even then Netty would still pick up Log4j 1.2 since it was on the classpath, thus the advantage to removing this as a dependency now.
1 parent e586a21 commit c9fb1ee

File tree

43 files changed

+1284
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1284
-227
lines changed

modules/transport-netty4/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ thirdPartyAudit {
7676
'org.apache.commons.logging.Log',
7777
'org.apache.commons.logging.LogFactory',
7878

79+
// from Log4j (deliberate, Netty will fallback to Log4j 2)
80+
'org.apache.log4j.Level',
81+
'org.apache.log4j.Logger',
82+
7983
// from io.netty.handler.ssl.OpenSslEngine (netty)
8084
'io.netty.internal.tcnative.Buffer',
8185
'io.netty.internal.tcnative.Library',

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@
9696
public class Netty4HttpServerTransport extends AbstractHttpServerTransport {
9797
private static final Logger logger = LogManager.getLogger(Netty4HttpServerTransport.class);
9898

99-
static {
100-
Netty4Utils.setup();
101-
}
102-
10399
/*
104100
* Size in bytes of an individual message received by io.netty.handler.codec.MessageAggregator which accumulates the content for an
105101
* HTTP request. This number is used for estimating the maximum number of allowed buffers before the MessageAggregator's internal

modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4InternalESLogger.java

Lines changed: 0 additions & 187 deletions
This file was deleted.

modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@
7878
public class Netty4Transport extends TcpTransport {
7979
private static final Logger logger = LogManager.getLogger(Netty4Transport.class);
8080

81-
static {
82-
Netty4Utils.setup();
83-
}
84-
8581
public static final Setting<Integer> WORKER_COUNT =
8682
new Setting<>("transport.netty.worker_count",
8783
(s) -> Integer.toString(EsExecutors.numberOfProcessors(s) * 2),

modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Utils.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import io.netty.buffer.CompositeByteBuf;
2424
import io.netty.buffer.Unpooled;
2525
import io.netty.util.NettyRuntime;
26-
import io.netty.util.internal.logging.InternalLogger;
27-
import io.netty.util.internal.logging.InternalLoggerFactory;
2826
import org.apache.lucene.util.BytesRef;
2927
import org.apache.lucene.util.BytesRefIterator;
3028
import org.elasticsearch.common.Booleans;
@@ -38,21 +36,6 @@
3836

3937
public class Netty4Utils {
4038

41-
static {
42-
InternalLoggerFactory.setDefaultFactory(new InternalLoggerFactory() {
43-
44-
@Override
45-
public InternalLogger newInstance(final String name) {
46-
return new Netty4InternalESLogger(name);
47-
}
48-
49-
});
50-
}
51-
52-
public static void setup() {
53-
54-
}
55-
5639
private static AtomicBoolean isAvailableProcessorsSet = new AtomicBoolean();
5740

5841
/**

plugins/discovery-azure-classic/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies {
3535
compile "org.apache.httpcomponents:httpclient:${versions.httpclient}"
3636
compile "org.apache.httpcomponents:httpcore:${versions.httpcore}"
3737
compile "commons-logging:commons-logging:${versions.commonslogging}"
38+
compile "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
3839
compile "commons-codec:commons-codec:${versions.commonscodec}"
3940
compile "commons-lang:commons-lang:2.6"
4041
compile "commons-io:commons-io:2.4"

plugins/discovery-ec2/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies {
3232
compile "org.apache.httpcomponents:httpclient:${versions.httpclient}"
3333
compile "org.apache.httpcomponents:httpcore:${versions.httpcore}"
3434
compile "commons-logging:commons-logging:${versions.commonslogging}"
35+
compile "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
3536
compile "commons-codec:commons-codec:${versions.commonscodec}"
3637
compile 'com.fasterxml.jackson.core:jackson-databind:2.8.11.3'
3738
compile "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3aba3398fe064a3eab4331f88161c7480e848418

0 commit comments

Comments
 (0)