Skip to content

Commit

Permalink
Upgrade to Netty 4.1.25.Final
Browse files Browse the repository at this point in the history
This commit upgrades us to Netty 4.1.25. This upgrade is more
challenging than past upgrades, all because of a new object cleaner
thread that they have added. This thread requires an additional security
permission (set context class loader, needed to avoid leaks in certain
scenarios). Additionally, there is not a clean way to shutdown this
thread which means that the thread can fail thread leak control during
tests. As such, we have to filter this thread from thread leak control.
  • Loading branch information
jasontedor committed Jun 9, 2018
1 parent aa8aa0d commit 92fa76a
Show file tree
Hide file tree
Showing 61 changed files with 221 additions and 79 deletions.
16 changes: 8 additions & 8 deletions modules/transport-netty4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-tr

dependencies {
// network stack
compile "io.netty:netty-buffer:4.1.16.Final"
compile "io.netty:netty-codec:4.1.16.Final"
compile "io.netty:netty-codec-http:4.1.16.Final"
compile "io.netty:netty-common:4.1.16.Final"
compile "io.netty:netty-handler:4.1.16.Final"
compile "io.netty:netty-resolver:4.1.16.Final"
compile "io.netty:netty-transport:4.1.16.Final"
compile "io.netty:netty-buffer:4.1.25.Final"
compile "io.netty:netty-codec:4.1.25.Final"
compile "io.netty:netty-codec-http:4.1.25.Final"
compile "io.netty:netty-common:4.1.25.Final"
compile "io.netty:netty-handler:4.1.25.Final"
compile "io.netty:netty-resolver:4.1.25.Final"
compile "io.netty:netty-transport:4.1.25.Final"
}

dependencyLicenses {
Expand Down Expand Up @@ -161,6 +161,6 @@ thirdPartyAudit.excludes = [

'org.conscrypt.AllocatedBuffer',
'org.conscrypt.BufferAllocator',
'org.conscrypt.Conscrypt$Engines',
'org.conscrypt.Conscrypt',
'org.conscrypt.HandshakeListener'
]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f366d0cc87b158ca064d27507127e3cc4eb2f089

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3e465c75bead40d06b5b9c0612b37cf77c548887

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
70888d3f2a829541378f68503ddd52c3193df35a

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e17d5c05c101fe14536ce3fb34b36c54e04791f6

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ecdfb8fe93a8b75db3ea8746d3437eed845c24bd

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dc0965d00746b782b33f419b005cbc130973030d

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19a6f1f649894b6705aa9d8cbcced188dff133b0
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ grant codeBase "${codebase.netty-common}" {
// for reading the system-wide configuration for the backlog of established sockets
permission java.io.FilePermission "/proc/sys/net/core/somaxconn", "read";

permission java.lang.RuntimePermission "setContextClassLoader";

// netty makes and accepts socket connections
permission java.net.SocketPermission "*", "accept,connect";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.http.netty4;

import io.netty.handler.codec.http.FullHttpResponse;
import org.elasticsearch.test.Netty4TestCase;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -33,7 +34,6 @@
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.After;
Expand All @@ -48,7 +48,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;

public class Netty4BadRequestTests extends ESTestCase {
public class Netty4BadRequestTests extends Netty4TestCase {

private NetworkService networkService;
private MockBigArrays bigArrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.netty.handler.codec.http.HttpVersion;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import org.elasticsearch.test.Netty4TestCase;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.bytes.ReleasablePagedBytesReference;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
Expand All @@ -64,7 +65,6 @@
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.netty4.Netty4Utils;
Expand All @@ -90,7 +90,7 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;

public class Netty4HttpChannelTests extends ESTestCase {
public class Netty4HttpChannelTests extends Netty4TestCase {

private NetworkService networkService;
private ThreadPool threadPool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.handler.codec.http.QueryStringDecoder;
import org.elasticsearch.test.Netty4TestCase;
import org.elasticsearch.common.Randomness;
import org.elasticsearch.http.HttpPipelinedRequest;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;

import java.nio.channels.ClosedChannelException;
Expand All @@ -61,7 +61,7 @@
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
import static org.hamcrest.core.Is.is;

public class Netty4HttpPipeliningHandlerTests extends ESTestCase {
public class Netty4HttpPipeliningHandlerTests extends Netty4TestCase {

private final ExecutorService handlerService = Executors.newFixedThreadPool(randomIntBetween(4, 8));
private final ExecutorService eventLoopService = Executors.newFixedThreadPool(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
package org.elasticsearch.http.netty4;

import io.netty.handler.codec.http.FullHttpResponse;
import org.elasticsearch.ESNetty4IntegTestCase;
import org.elasticsearch.test.Netty4IntegTestCase;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.ByteSizeUnit;
Expand All @@ -46,7 +45,7 @@
* a single node "cluster". We also force test infrastructure to use the node client instead of the transport client for the same reason.
*/
@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numClientNodes = 0, numDataNodes = 1, transportClientRatio = 0)
public class Netty4HttpRequestSizeLimitIT extends ESNetty4IntegTestCase {
public class Netty4HttpRequestSizeLimitIT extends Netty4IntegTestCase {

private static final ByteSizeValue LIMIT = new ByteSizeValue(2, ByteSizeUnit.KB);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import org.elasticsearch.test.Netty4TestCase;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
Expand All @@ -42,7 +43,6 @@
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.http.NullDispatcher;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.After;
Expand All @@ -61,7 +61,7 @@
/**
* This test just tests, if he pipelining works in general with out any connection the Elasticsearch handler
*/
public class Netty4HttpServerPipeliningTests extends ESTestCase {
public class Netty4HttpServerPipeliningTests extends Netty4TestCase {
private NetworkService networkService;
private ThreadPool threadPool;
private MockBigArrays bigArrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpUtil;
import io.netty.handler.codec.http.HttpVersion;
import org.elasticsearch.test.Netty4TestCase;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
Expand All @@ -59,7 +60,6 @@
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.After;
Expand Down Expand Up @@ -94,7 +94,7 @@
/**
* Tests for the {@link Netty4HttpServerTransport} class.
*/
public class Netty4HttpServerTransportTests extends ESTestCase {
public class Netty4HttpServerTransportTests extends Netty4TestCase {

private NetworkService networkService;
private ThreadPool threadPool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.elasticsearch.http.netty4;

import io.netty.handler.codec.http.FullHttpResponse;
import org.elasticsearch.ESNetty4IntegTestCase;
import org.elasticsearch.test.Netty4IntegTestCase;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
Expand All @@ -33,7 +33,7 @@
import static org.hamcrest.Matchers.is;

@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1)
public class Netty4PipeliningIT extends ESNetty4IntegTestCase {
public class Netty4PipeliningIT extends Netty4IntegTestCase {

@Override
protected boolean addMockHttpTransport() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch;

package org.elasticsearch.test;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.transport.Netty4Plugin;
import org.elasticsearch.transport.netty4.Netty4Transport;

import java.util.Arrays;
import java.util.Collection;

public abstract class ESNetty4IntegTestCase extends ESIntegTestCase {
@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
public abstract class Netty4IntegTestCase extends ESIntegTestCase {

@Override
protected boolean ignoreExternalCluster() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.elasticsearch.test;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;

@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
public abstract class Netty4TestCase extends ESTestCase {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.elasticsearch.test;

import com.carrotsearch.randomizedtesting.ThreadFilter;

/**
* The Netty object cleaner thread is not closeable and it does not terminate in a timely manner. This means that thread leak control in
* tests will fail test suites when the object cleaner thread has not terminated. Since there is not a reliable way to terminate this thread
* we instead filter it out of thread leak control.
*/
public class ObjectCleanerThreadThreadFilter implements ThreadFilter {

@Override
public boolean reject(final Thread t) {
return "ObjectCleanerThread".equals(t.getName());
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
*/
package org.elasticsearch.transport.netty4;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.test.ObjectCleanerThreadThreadFilter;
import org.elasticsearch.common.bytes.AbstractBytesReferenceTestCase;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.ReleasableBytesStreamOutput;

import javax.net.ssl.SSLEngine;
import java.io.IOException;
import java.nio.ByteBuffer;

@ThreadLeakFilters(filters = {ObjectCleanerThreadThreadFilter.class})
public class ByteBufBytesReferenceTests extends AbstractBytesReferenceTestCase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.elasticsearch.transport.netty4;

import org.apache.logging.log4j.Level;
import org.elasticsearch.ESNetty4IntegTestCase;
import org.elasticsearch.test.Netty4IntegTestCase;
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsRequest;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESIntegTestCase;
Expand All @@ -29,7 +29,7 @@

@ESIntegTestCase.ClusterScope(numDataNodes = 2)
@TestLogging(value = "org.elasticsearch.transport.netty4.ESLoggingHandler:trace")
public class ESLoggingHandlerIT extends ESNetty4IntegTestCase {
public class ESLoggingHandlerIT extends Netty4IntegTestCase {

private MockLogAppender appender;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.elasticsearch.transport.netty4;

import org.elasticsearch.test.Netty4TestCase;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.lease.Releasables;
Expand All @@ -26,7 +27,6 @@
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
Expand All @@ -47,7 +47,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;

public class Netty4ScheduledPingTests extends ESTestCase {
public class Netty4ScheduledPingTests extends Netty4TestCase {
public void testScheduledPing() throws Exception {
ThreadPool threadPool = new TestThreadPool(getClass().getName());

Expand Down
Loading

0 comments on commit 92fa76a

Please sign in to comment.