drcrallen closed pull request #6417: Upgrade Netty to 4.1.x
URL: https://github.com/apache/incubator-druid/pull/6417
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/extensions-contrib/druid-rocketmq/pom.xml 
b/extensions-contrib/druid-rocketmq/pom.xml
index 251961ba99e..46d10be4287 100644
--- a/extensions-contrib/druid-rocketmq/pom.xml
+++ b/extensions-contrib/druid-rocketmq/pom.xml
@@ -40,6 +40,13 @@
       <groupId>com.alibaba.rocketmq</groupId>
       <artifactId>rocketmq-client</artifactId>
       <version>${rocketmq.version}</version>
+      <exclusions>
+        <!-- Druid uses its own netty version -->
+        <exclusion>
+          <groupId>io.netty</groupId>
+          <artifactId>netty-all</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.druid</groupId>
diff --git 
a/extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authentication/BasicHTTPAuthenticatorTest.java
 
b/extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authentication/BasicHTTPAuthenticatorTest.java
index 782c9dd2111..07134973e09 100644
--- 
a/extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authentication/BasicHTTPAuthenticatorTest.java
+++ 
b/extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authentication/BasicHTTPAuthenticatorTest.java
@@ -31,7 +31,6 @@
 import 
org.apache.druid.security.basic.authentication.entity.BasicAuthenticatorUser;
 import org.apache.druid.server.security.AuthConfig;
 import org.apache.druid.server.security.AuthenticationResult;
-import org.asynchttpclient.util.Base64;
 import org.easymock.EasyMock;
 import org.junit.Test;
 
@@ -82,9 +81,7 @@ public void handleAuthenticatorUpdate(String 
authenticatorPrefix, byte[] seriali
   @Test
   public void testGoodPassword() throws IOException, ServletException
   {
-    String header = Base64.encode(
-        StringUtils.toUtf8("userA:helloworld")
-    );
+    String header = StringUtils.utf8Base64("userA:helloworld");
     header = StringUtils.format("Basic %s", header);
 
     HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
@@ -113,9 +110,7 @@ public void testGoodPassword() throws IOException, 
ServletException
   @Test
   public void testBadPassword() throws IOException, ServletException
   {
-    String header = Base64.encode(
-        StringUtils.toUtf8("userA:badpassword")
-    );
+    String header = StringUtils.utf8Base64("userA:badpassword");
     header = StringUtils.format("Basic %s", header);
 
     HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
@@ -139,9 +134,7 @@ public void testBadPassword() throws IOException, 
ServletException
   @Test
   public void testUnknownUser() throws IOException, ServletException
   {
-    String header = Base64.encode(
-        StringUtils.toUtf8("userB:helloworld")
-    );
+    String header = StringUtils.utf8Base64("userB:helloworld");
     header = StringUtils.format("Basic %s", header);
 
     HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
@@ -165,9 +158,7 @@ public void testUnknownUser() throws IOException, 
ServletException
   @Test
   public void testRecognizedButMalformedBasicAuthHeader() throws IOException, 
ServletException
   {
-    String header = Base64.encode(
-        StringUtils.toUtf8("malformed decoded header data")
-    );
+    String header = StringUtils.utf8Base64("malformed decoded header data");
     header = StringUtils.format("Basic %s", header);
 
     HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
@@ -214,9 +205,7 @@ public void testRecognizedButNotBase64BasicAuthHeader() 
throws IOException, Serv
   @Test
   public void testUnrecognizedHeader() throws IOException, ServletException
   {
-    String header = Base64.encode(
-        StringUtils.toUtf8("userA:helloworld")
-    );
+    String header = StringUtils.utf8Base64("userA:helloworld");
     header = StringUtils.format("NotBasic %s", header);
 
     HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
diff --git 
a/java-util/src/main/java/org/apache/druid/java/util/common/StringUtils.java 
b/java-util/src/main/java/org/apache/druid/java/util/common/StringUtils.java
index b69f81eff09..e4020990a6a 100644
--- a/java-util/src/main/java/org/apache/druid/java/util/common/StringUtils.java
+++ b/java-util/src/main/java/org/apache/druid/java/util/common/StringUtils.java
@@ -28,6 +28,7 @@
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
+import java.util.Base64;
 import java.util.IllegalFormatException;
 import java.util.Locale;
 
@@ -218,4 +219,16 @@ public static String 
emptyToNullNonDruidDataString(@Nullable String string)
     return Strings.emptyToNull(string);
     //CHECKSTYLE.ON: Regexp
   }
+
+  /**
+   * Convert an input to base 64 and return the utf8 string of that byte array
+   *
+   * @param input The string to convert to base64
+   *
+   * @return the base64 of the input in string form
+   */
+  public static String utf8Base64(String input)
+  {
+    return fromUtf8(Base64.getEncoder().encode(toUtf8(input)));
+  }
 }
diff --git 
a/java-util/src/test/java/org/apache/druid/java/util/emitter/core/EmitterTest.java
 
b/java-util/src/test/java/org/apache/druid/java/util/emitter/core/EmitterTest.java
index c80736313e6..ed85dbcedce 100644
--- 
a/java-util/src/test/java/org/apache/druid/java/util/emitter/core/EmitterTest.java
+++ 
b/java-util/src/test/java/org/apache/druid/java/util/emitter/core/EmitterTest.java
@@ -31,7 +31,6 @@
 import org.apache.druid.java.util.common.StringUtils;
 import org.apache.druid.java.util.common.lifecycle.Lifecycle;
 import org.apache.druid.java.util.emitter.service.UnitEvent;
-import org.asynchttpclient.DefaultAsyncHttpClientConfig;
 import org.asynchttpclient.ListenableFuture;
 import org.asynchttpclient.Request;
 import org.asynchttpclient.Response;
@@ -53,6 +52,7 @@
 import java.util.Properties;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Stream;
 
 /**
  */
@@ -60,25 +60,33 @@
 {
   private static final ObjectMapper jsonMapper = new ObjectMapper();
   public static String TARGET_URL = "http://metrics.foo.bar/";;
-  public static final Response OK_RESPONSE = 
responseBuilder(HttpVersion.HTTP_1_1, HttpResponseStatus.CREATED)
-      .accumulate(new 
EagerResponseBodyPart(Unpooled.wrappedBuffer("Yay".getBytes(StandardCharsets.UTF_8)),
 true))
-      .build();
-
-  public static final Response BAD_RESPONSE = 
responseBuilder(HttpVersion.HTTP_1_1, HttpResponseStatus.FORBIDDEN)
-      .accumulate(new EagerResponseBodyPart(Unpooled.wrappedBuffer("Not 
yay".getBytes(StandardCharsets.UTF_8)), true))
-      .build();
+  public static final Response OK_RESPONSE = Stream
+      .of(responseBuilder(HttpVersion.HTTP_1_1, HttpResponseStatus.CREATED))
+      .map(b -> {
+        b.accumulate(new 
EagerResponseBodyPart(Unpooled.wrappedBuffer("Yay".getBytes(StandardCharsets.UTF_8)),
 true));
+        return b.build();
+      }).findFirst().get();
+
+  public static final Response BAD_RESPONSE = Stream
+      .of(responseBuilder(HttpVersion.HTTP_1_1, HttpResponseStatus.FORBIDDEN))
+      .map(b -> {
+        b.accumulate(new EagerResponseBodyPart(
+            Unpooled.wrappedBuffer("Not yay".getBytes(StandardCharsets.UTF_8)),
+            true
+        ));
+        return b.build();
+      }).findFirst().get();
 
   private static Response.ResponseBuilder responseBuilder(HttpVersion version, 
HttpResponseStatus status)
   {
-    return new Response.ResponseBuilder()
-        .accumulate(
-            new NettyResponseStatus(
-                Uri.create(TARGET_URL),
-                new DefaultAsyncHttpClientConfig.Builder().build(),
-                new DefaultHttpResponse(version, status),
-                null
-            )
-        );
+    final Response.ResponseBuilder builder = new Response.ResponseBuilder();
+    builder.accumulate(
+        new NettyResponseStatus(
+            Uri.create(TARGET_URL),
+            new DefaultHttpResponse(version, status),
+            null
+        ));
+    return builder;
   }
 
 
diff --git a/pom.xml b/pom.xml
index 9d127d7664e..7b54762bf91 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,9 +77,8 @@
         <log4j.version>2.5</log4j.version>
         <!-- HttpClient has not yet been ported to Netty 4.x -->
         <netty3.version>3.10.6.Final</netty3.version>
-        <!-- Update to Netty 4.1 is not possible yet, see 
https://github.com/apache/incubator-druid/issues/4390 and comments
-             in https://github.com/apache/incubator-druid/pull/4973 -->
-        <netty4.version>4.0.52.Final</netty4.version>
+        <!-- Spark updated in https://github.com/apache/spark/pull/19884 -->
+        <netty4.version>4.1.30.Final</netty4.version>
         <slf4j.version>1.7.12</slf4j.version>
         <!-- If compiling with different hadoop version also modify default 
hadoop coordinates in TaskConfig.java -->
         <hadoop.compile.version>2.8.3</hadoop.compile.version>
@@ -680,7 +679,8 @@
             <dependency>
                 <groupId>org.asynchttpclient</groupId>
                 <artifactId>async-http-client</artifactId>
-                <version>2.0.37</version>
+                <!-- Uses Netty 4.1.x -->
+                <version>2.5.3</version>
             </dependency>
             <dependency>
                 <groupId>org.gridkit.lab</groupId>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to