Remove `netty-all` dependency (#10818)

This commit is contained in:
earthchen 2022-11-07 16:15:16 +08:00 committed by GitHub
parent a204f61839
commit 0876d8af1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 86 additions and 51 deletions

View File

@ -14,7 +14,9 @@
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.
--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -193,6 +195,18 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>${netty4_version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty4_version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
@ -203,11 +217,6 @@
<artifactId>netty</artifactId>
<version>${netty_version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty4_version}</version>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>

View File

@ -49,11 +49,6 @@
<artifactId>dubbo-metadata-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>

View File

@ -70,9 +70,5 @@
<artifactId>dubbo-serialization-fastjson2</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -42,7 +42,41 @@
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<artifactId>netty-codec</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-classes-epoll</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<classifier>osx-x86_64</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<classifier>osx-aarch_64</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>

View File

@ -40,9 +40,11 @@
<artifactId>dubbo-remoting-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<artifactId>netty-handler-proxy</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>

View File

@ -83,11 +83,6 @@
<artifactId>resteasy-jaxb-provider</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<!-- swagger -->
<dependency>
<groupId>io.swagger</groupId>

View File

@ -45,6 +45,10 @@
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>

View File

@ -83,7 +83,7 @@ public class TriRpcStatus {
return new TriRpcStatus(code, throwable, description);
}
if (throwable instanceof TimeoutException) {
return new TriRpcStatus(TriRpcStatus.Code.DEADLINE_EXCEEDED, throwable, description);
return new TriRpcStatus(Code.DEADLINE_EXCEEDED, throwable, description);
}
return new TriRpcStatus(Code.UNKNOWN, throwable, description);
}
@ -165,27 +165,27 @@ public class TriRpcStatus {
return encoder.toString().substring(2);
}
public static TriRpcStatus.Code httpStatusToGrpcCode(int httpStatusCode) {
public static Code httpStatusToGrpcCode(int httpStatusCode) {
if (httpStatusCode >= 100 && httpStatusCode < 200) {
return TriRpcStatus.Code.INTERNAL;
return Code.INTERNAL;
}
if (httpStatusCode == HttpResponseStatus.BAD_REQUEST.code() ||
httpStatusCode == HttpResponseStatus.REQUEST_HEADER_FIELDS_TOO_LARGE.code()
) {
return TriRpcStatus.Code.INTERNAL;
return Code.INTERNAL;
} else if (httpStatusCode == HttpResponseStatus.UNAUTHORIZED.code()) {
return TriRpcStatus.Code.UNAUTHENTICATED;
return Code.UNAUTHENTICATED;
} else if (httpStatusCode == HttpResponseStatus.FORBIDDEN.code()) {
return TriRpcStatus.Code.PERMISSION_DENIED;
return Code.PERMISSION_DENIED;
} else if (httpStatusCode == HttpResponseStatus.NOT_FOUND.code()) {
return TriRpcStatus.Code.UNIMPLEMENTED;
return Code.UNIMPLEMENTED;
} else if (httpStatusCode == HttpResponseStatus.BAD_GATEWAY.code()
|| httpStatusCode == HttpResponseStatus.TOO_MANY_REQUESTS.code()
|| httpStatusCode == HttpResponseStatus.SERVICE_UNAVAILABLE.code()
|| httpStatusCode == HttpResponseStatus.GATEWAY_TIMEOUT.code()) {
return Code.UNAVAILABLE;
} else {
return TriRpcStatus.Code.UNKNOWN;
return Code.UNKNOWN;
}
}

View File

@ -25,7 +25,7 @@ import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.model.ConsumerModel;
import org.apache.dubbo.rpc.model.MethodDescriptor;
import org.apache.dubbo.rpc.model.ServiceDescriptor;
import org.apache.dubbo.rpc.support.DemoService;
import org.apache.dubbo.rpc.protocol.tri.support.IGreeter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -43,7 +43,7 @@ class StubInvocationUtilTest {
@Test
void unaryCall() throws Throwable {
Invoker<DemoService> invoker = Mockito.mock(Invoker.class);
Invoker<IGreeter> invoker = Mockito.mock(Invoker.class);
URL url = Mockito.mock(URL.class);
ConsumerModel consumerModel = Mockito.mock(ConsumerModel.class);
ServiceDescriptor serviceDescriptor = Mockito.mock(ServiceDescriptor.class);
@ -51,13 +51,13 @@ class StubInvocationUtilTest {
when(url.getServiceModel())
.thenReturn(consumerModel);
when(url.getServiceInterface())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(url.getProtocolServiceKey())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(invoker.getUrl())
.thenReturn(url);
when(invoker.getInterface())
.thenReturn(DemoService.class);
.thenReturn(IGreeter.class);
Result result = Mockito.mock(Result.class);
when(invoker.invoke(any(Invocation.class)))
.thenReturn(result);
@ -75,7 +75,7 @@ class StubInvocationUtilTest {
@Test
void unaryCall2() throws Throwable {
Invoker<DemoService> invoker = Mockito.mock(Invoker.class);
Invoker<IGreeter> invoker = Mockito.mock(Invoker.class);
URL url = Mockito.mock(URL.class);
ConsumerModel consumerModel = Mockito.mock(ConsumerModel.class);
ServiceDescriptor serviceDescriptor = Mockito.mock(ServiceDescriptor.class);
@ -83,13 +83,13 @@ class StubInvocationUtilTest {
when(url.getServiceModel())
.thenReturn(consumerModel);
when(url.getServiceInterface())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(url.getProtocolServiceKey())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(invoker.getUrl())
.thenReturn(url);
when(invoker.getInterface())
.thenReturn(DemoService.class);
.thenReturn(IGreeter.class);
Result result = Mockito.mock(Result.class);
when(invoker.invoke(any(Invocation.class)))
.thenThrow(new RuntimeException("a"))
@ -118,7 +118,7 @@ class StubInvocationUtilTest {
@Test
void testUnaryCall() throws Throwable {
Invoker<DemoService> invoker = Mockito.mock(Invoker.class);
Invoker<IGreeter> invoker = Mockito.mock(Invoker.class);
URL url = Mockito.mock(URL.class);
ConsumerModel consumerModel = Mockito.mock(ConsumerModel.class);
ServiceDescriptor serviceDescriptor = Mockito.mock(ServiceDescriptor.class);
@ -126,13 +126,13 @@ class StubInvocationUtilTest {
when(url.getServiceModel())
.thenReturn(consumerModel);
when(url.getServiceInterface())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(url.getProtocolServiceKey())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(invoker.getUrl())
.thenReturn(url);
when(invoker.getInterface())
.thenReturn(DemoService.class);
.thenReturn(IGreeter.class);
Result result = Mockito.mock(Result.class);
String response = "response";
when(invoker.invoke(any(Invocation.class)))
@ -168,7 +168,7 @@ class StubInvocationUtilTest {
@Test
void biOrClientStreamCall() throws InterruptedException {
Invoker<DemoService> invoker = Mockito.mock(Invoker.class);
Invoker<IGreeter> invoker = Mockito.mock(Invoker.class);
URL url = Mockito.mock(URL.class);
ConsumerModel consumerModel = Mockito.mock(ConsumerModel.class);
ServiceDescriptor serviceDescriptor = Mockito.mock(ServiceDescriptor.class);
@ -176,13 +176,13 @@ class StubInvocationUtilTest {
when(url.getServiceModel())
.thenReturn(consumerModel);
when(url.getServiceInterface())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(url.getProtocolServiceKey())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(invoker.getUrl())
.thenReturn(url);
when(invoker.getInterface())
.thenReturn(DemoService.class);
.thenReturn(IGreeter.class);
Result result = Mockito.mock(Result.class);
String response = "response";
@ -243,7 +243,7 @@ class StubInvocationUtilTest {
@Test
void serverStreamCall() throws InterruptedException {
Invoker<DemoService> invoker = Mockito.mock(Invoker.class);
Invoker<IGreeter> invoker = Mockito.mock(Invoker.class);
URL url = Mockito.mock(URL.class);
ConsumerModel consumerModel = Mockito.mock(ConsumerModel.class);
ServiceDescriptor serviceDescriptor = Mockito.mock(ServiceDescriptor.class);
@ -251,13 +251,13 @@ class StubInvocationUtilTest {
when(url.getServiceModel())
.thenReturn(consumerModel);
when(url.getServiceInterface())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(url.getProtocolServiceKey())
.thenReturn(DemoService.class.getName());
.thenReturn(IGreeter.class.getName());
when(invoker.getUrl())
.thenReturn(url);
when(invoker.getInterface())
.thenReturn(DemoService.class);
.thenReturn(IGreeter.class);
Result result = Mockito.mock(Result.class);
String response = "response";
when(invoker.invoke(any(Invocation.class)))