Skip to content

Commit

Permalink
Update netty 4.1.60 -> 4.1.63, netty-tcnative 2.0.36 -> 2.0.38 (#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmitch authored Apr 5, 2021
1 parent 58aa4da commit d4037d3
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 26 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
group=io.servicetalk
version=0.39.0-SNAPSHOT

nettyVersion=4.1.60.Final
tcnativeVersion=2.0.36.Final
nettyVersion=4.1.63.Final
tcnativeVersion=2.0.38.Final
jsr305Version=3.0.2

log4jVersion=2.14.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package io.servicetalk.concurrent.api;

import org.hamcrest.Matcher;
import org.junit.Assert;
import org.junit.function.ThrowingRunnable;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -54,4 +56,35 @@ public static void expectThrowable(final Runnable runnable, final Matcher<Throwa
}
fail("Expected AssertionError");
}

@SuppressWarnings("unchecked")
public static <T1 extends Throwable, T2 extends Throwable> T1 assertThrows(
Class<T1> expectedClass, @Nullable Class<T2> optionalWrapperClass, ThrowingRunnable runnable) {
if (optionalWrapperClass == null) {
return Assert.assertThrows(expectedClass, runnable);
}
try {
runnable.run();
} catch (Throwable cause) {
if (expectedClass.isInstance(cause)) {
return (T1) cause;
} else if (optionalWrapperClass.isInstance(cause) && expectedClass.isInstance(cause.getCause())) {
return (T1) cause.getCause();
} else {
throw new AssertionError("expected " + className(expectedClass) + " optionally wrapped by " +
className(optionalWrapperClass) + " but got " + className(cause) + " caused by " +
classNameNullable(cause.getCause()));
}
}
throw new AssertionError("expected " + className(expectedClass) + " optionally wrapped by " +
className(optionalWrapperClass) + " but nothing was thrown");
}

private static String classNameNullable(@Nullable Object o) {
return o == null ? "null" : className(o);
}

private static String className(Object o) {
return o.getClass().getCanonicalName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.concurrent.LinkedBlockingDeque;
import javax.annotation.Nullable;

import static io.servicetalk.concurrent.api.VerificationTestUtils.assertThrows;
import static io.servicetalk.http.api.HttpResponseStatus.OK;
import static io.servicetalk.http.api.HttpSerializationProviders.textDeserializer;
import static io.servicetalk.http.api.HttpSerializationProviders.textSerializer;
Expand All @@ -61,7 +62,6 @@
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThrows;

@RunWith(Parameterized.class)
public class AlpnClientAndServerTest {
Expand All @@ -77,43 +77,49 @@ public class AlpnClientAndServerTest {
private final HttpProtocolVersion expectedProtocol;
@Nullable
private final Class<? extends Throwable> expectedExceptionType;
@Nullable
private final Class<? extends Throwable> optionalExceptionWrapperType;

private final BlockingQueue<HttpServiceContext> serviceContext = new LinkedBlockingDeque<>();
private final BlockingQueue<HttpProtocolVersion> requestVersion = new LinkedBlockingDeque<>();

public AlpnClientAndServerTest(List<String> serverSideProtocols,
List<String> clientSideProtocols,
@Nullable HttpProtocolVersion expectedProtocol,
@Nullable Class<? extends Throwable> expectedExceptionType) throws Exception {
@Nullable Class<? extends Throwable> expectedExceptionType,
@Nullable Class<? extends Throwable> optionalExceptionWrapperType) throws Exception {
serverContext = startServer(serverSideProtocols);
client = startClient(serverHostAndPort(serverContext), clientSideProtocols);
this.expectedProtocol = expectedProtocol;
this.expectedExceptionType = expectedExceptionType;
this.optionalExceptionWrapperType = optionalExceptionWrapperType;
}

@Parameters(name =
"serverAlpnProtocols={0}, clientAlpnProtocols={1}, expectedProtocol={2}, expectedExceptionType={3}")
"serverAlpnProtocols={0}, clientAlpnProtocols={1}, expectedProtocol={2}, expectedExceptionType={3}" +
"optionalExceptionWrapperType={4}")
public static Collection<Object[]> clientExecutors() {
return asList(new Object[][] {
{asList(HTTP_2, HTTP_1_1), asList(HTTP_2, HTTP_1_1), HttpProtocolVersion.HTTP_2_0, null},
{asList(HTTP_2, HTTP_1_1), asList(HTTP_1_1, HTTP_2), HttpProtocolVersion.HTTP_2_0, null},
{asList(HTTP_2, HTTP_1_1), singletonList(HTTP_2), HttpProtocolVersion.HTTP_2_0, null},
{asList(HTTP_2, HTTP_1_1), singletonList(HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null},

{asList(HTTP_1_1, HTTP_2), asList(HTTP_2, HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null},
{asList(HTTP_1_1, HTTP_2), asList(HTTP_1_1, HTTP_2), HttpProtocolVersion.HTTP_1_1, null},
{asList(HTTP_1_1, HTTP_2), singletonList(HTTP_2), HttpProtocolVersion.HTTP_2_0, null},
{asList(HTTP_1_1, HTTP_2), singletonList(HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null},

{singletonList(HTTP_2), asList(HTTP_2, HTTP_1_1), HttpProtocolVersion.HTTP_2_0, null},
{singletonList(HTTP_2), asList(HTTP_1_1, HTTP_2), HttpProtocolVersion.HTTP_2_0, null},
{singletonList(HTTP_2), singletonList(HTTP_2), HttpProtocolVersion.HTTP_2_0, null},
{singletonList(HTTP_2), singletonList(HTTP_1_1), null, DecoderException.class},

{singletonList(HTTP_1_1), asList(HTTP_2, HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null},
{singletonList(HTTP_1_1), asList(HTTP_1_1, HTTP_2), HttpProtocolVersion.HTTP_1_1, null},
{singletonList(HTTP_1_1), singletonList(HTTP_2), null, ClosedChannelException.class},
{singletonList(HTTP_1_1), singletonList(HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null},
{asList(HTTP_2, HTTP_1_1), asList(HTTP_2, HTTP_1_1), HttpProtocolVersion.HTTP_2_0, null, null},
{asList(HTTP_2, HTTP_1_1), asList(HTTP_1_1, HTTP_2), HttpProtocolVersion.HTTP_2_0, null, null},
{asList(HTTP_2, HTTP_1_1), singletonList(HTTP_2), HttpProtocolVersion.HTTP_2_0, null, null},
{asList(HTTP_2, HTTP_1_1), singletonList(HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null, null},

{asList(HTTP_1_1, HTTP_2), asList(HTTP_2, HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null, null},
{asList(HTTP_1_1, HTTP_2), asList(HTTP_1_1, HTTP_2), HttpProtocolVersion.HTTP_1_1, null, null},
{asList(HTTP_1_1, HTTP_2), singletonList(HTTP_2), HttpProtocolVersion.HTTP_2_0, null, null},
{asList(HTTP_1_1, HTTP_2), singletonList(HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null, null},

{singletonList(HTTP_2), asList(HTTP_2, HTTP_1_1), HttpProtocolVersion.HTTP_2_0, null, null},
{singletonList(HTTP_2), asList(HTTP_1_1, HTTP_2), HttpProtocolVersion.HTTP_2_0, null, null},
{singletonList(HTTP_2), singletonList(HTTP_2), HttpProtocolVersion.HTTP_2_0, null, null},
{singletonList(HTTP_2), singletonList(HTTP_1_1), null, DecoderException.class,
ClosedChannelException.class},

{singletonList(HTTP_1_1), asList(HTTP_2, HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null, null},
{singletonList(HTTP_1_1), asList(HTTP_1_1, HTTP_2), HttpProtocolVersion.HTTP_1_1, null, null},
{singletonList(HTTP_1_1), singletonList(HTTP_2), null, ClosedChannelException.class, null},
{singletonList(HTTP_1_1), singletonList(HTTP_1_1), HttpProtocolVersion.HTTP_1_1, null, null},
});
}

Expand Down Expand Up @@ -164,7 +170,7 @@ public void tearDown() throws Exception {
@Test
public void testAlpnConnection() throws Exception {
if (expectedExceptionType != null) {
assertThrows(expectedExceptionType, () -> client.request(client.get("/")));
assertThrows(expectedExceptionType, optionalExceptionWrapperType, () -> client.request(client.get("/")));
return;
}

Expand All @@ -179,7 +185,7 @@ public void testAlpnConnection() throws Exception {
@Test
public void testAlpnClient() throws Exception {
if (expectedExceptionType != null) {
assertThrows(expectedExceptionType, () -> client.request(client.get("/")));
assertThrows(expectedExceptionType, optionalExceptionWrapperType, () -> client.request(client.get("/")));
} else {
assertResponseAndServiceContext(client.request(client.get("/")));
}
Expand Down

0 comments on commit d4037d3

Please sign in to comment.