From 29d32afd79513330f3cd83a78b405b8b33cc6b91 Mon Sep 17 00:00:00 2001 From: aamingaa <49740762+aamingaa@users.noreply.github.com> Date: Sat, 25 Feb 2023 16:43:22 +0800 Subject: [PATCH 1/4] fix: executor (#11652) --- .../manager/DefaultExecutorRepository.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/manager/DefaultExecutorRepository.java b/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/manager/DefaultExecutorRepository.java index 2a0858a2c4..399567f97d 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/manager/DefaultExecutorRepository.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/manager/DefaultExecutorRepository.java @@ -31,7 +31,6 @@ import org.apache.dubbo.config.ModuleConfig; import org.apache.dubbo.config.ProviderConfig; import org.apache.dubbo.rpc.model.ApplicationModel; import org.apache.dubbo.rpc.model.ModuleModel; -import org.apache.dubbo.rpc.model.ServiceDescriptor; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -47,7 +46,6 @@ import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_EXPORT_T import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_PROTOCOL; import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_REFER_THREAD_NUM; import static org.apache.dubbo.common.constants.CommonConstants.EXECUTOR_SERVICE_COMPONENT_KEY; -import static org.apache.dubbo.common.constants.CommonConstants.INTERNAL_EXECUTOR_SERVICE_COMPONENT_KEY; import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY; import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY; import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY; @@ -122,18 +120,10 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA * @return */ private String getExecutorKey(URL url) { - String executorKey = INTERNAL_EXECUTOR_SERVICE_COMPONENT_KEY; - ServiceDescriptor serviceDescriptor = applicationModel.getInternalModule().getServiceRepository().lookupService(url.getServiceInterface()); - // if not found in internal service repository, then it's biz service defined by user. - if (serviceDescriptor == null) { - executorKey = EXECUTOR_SERVICE_COMPONENT_KEY; - - } - if (CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(SIDE_KEY))) { - executorKey = CONSUMER_SHARED_EXECUTOR_SERVICE_COMPONENT_KEY; + return CONSUMER_SHARED_EXECUTOR_SERVICE_COMPONENT_KEY; } - return executorKey; + return EXECUTOR_SERVICE_COMPONENT_KEY; } private ExecutorService createExecutor(URL url) { From 848edaa80fe4128adb9f8809f776272465b1d18e Mon Sep 17 00:00:00 2001 From: aamingaa <49740762+aamingaa@users.noreply.github.com> Date: Sat, 25 Feb 2023 17:13:44 +0800 Subject: [PATCH 2/4] Fix service name mapping check failed (#11643) --- .../metadata/MetadataServiceNameMapping.java | 28 +++++++++++-------- .../protocol/tri/call/AbstractServerCall.java | 14 +++++----- .../tri/call/AbstractServerCallListener.java | 4 +-- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceNameMapping.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceNameMapping.java index e5925bba8c..3da0d20df1 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceNameMapping.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceNameMapping.java @@ -16,12 +16,6 @@ */ package org.apache.dubbo.registry.client.metadata; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ThreadLocalRandom; - import org.apache.dubbo.common.URL; import org.apache.dubbo.common.config.ConfigurationUtils; import org.apache.dubbo.common.config.configcenter.ConfigItem; @@ -37,6 +31,12 @@ import org.apache.dubbo.metadata.report.MetadataReportInstance; import org.apache.dubbo.registry.client.RegistryClusterIdentifier; import org.apache.dubbo.rpc.model.ApplicationModel; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ThreadLocalRandom; + import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SEPARATOR; import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY; import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_TYPE_MISMATCH; @@ -92,17 +92,23 @@ public class MetadataServiceNameMapping extends AbstractServiceNameMapping { continue; } - boolean succeeded; + boolean succeeded = false; int currentRetryTimes = 1; String newConfigContent = appName; do { ConfigItem configItem = metadataReport.getConfigItem(serviceInterface, DEFAULT_MAPPING_GROUP); String oldConfigContent = configItem.getContent(); if (StringUtils.isNotEmpty(oldConfigContent)) { - boolean contains = StringUtils.isContains(oldConfigContent, appName); - if (contains) { - // From the user's perspective, it means successful when the oldConfigContent has contained the current appName. So we should not throw an Exception to user, it will confuse the user. - succeeded = true; + String[] oldAppNames = oldConfigContent.split(","); + if (oldAppNames.length > 0) { + for (String oldAppName : oldAppNames) { + if (oldAppName.equals(appName)) { + succeeded = true; + break; + } + } + } + if (succeeded) { break; } newConfigContent = oldConfigContent + COMMA_SEPARATOR + appName; diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCall.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCall.java index cd538a7a58..7780579a69 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCall.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCall.java @@ -143,7 +143,7 @@ public abstract class AbstractServerCall implements ServerCall, ServerStream.Lis final byte[] data; try { data = packableMethod.packResponse(message); - } catch (Throwable e) { + } catch (Exception e) { close(TriRpcStatus.INTERNAL.withDescription("Serialize response failed") .withCause(e), null); LOGGER.error(PROTOCOL_FAILED_SERIALIZE_TRIPLE,"","",String.format("Serialize triple response failed, service=%s method=%s", @@ -188,12 +188,12 @@ public abstract class AbstractServerCall implements ServerCall, ServerStream.Lis try { Object instance = parseSingleMessage(message); listener.onMessage(instance); - } catch (Throwable t) { + } catch (Exception e) { final TriRpcStatus status = TriRpcStatus.UNKNOWN.withDescription("Server error") - .withCause(t); + .withCause(e); close(status, null); LOGGER.error(PROTOCOL_FAILED_REQUEST,"","","Process request failed. service=" + serviceName + - " method=" + methodName, t); + " method=" + methodName, e); } finally { ClassLoadUtil.switchContextLoader(tccl); } @@ -391,10 +391,10 @@ public abstract class AbstractServerCall implements ServerCall, ServerStream.Lis throw new IllegalStateException("Can not reach here"); } return listener; - } catch (Throwable t) { - LOGGER.error(PROTOCOL_FAILED_CREATE_STREAM_TRIPLE, "", "", "Create triple stream failed", t); + } catch (Exception e) { + LOGGER.error(PROTOCOL_FAILED_CREATE_STREAM_TRIPLE, "", "", "Create triple stream failed", e); responseErr(TriRpcStatus.INTERNAL.withDescription("Create stream failed") - .withCause(t)); + .withCause(e)); } return null; } diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java index 61de32a9ba..3256cd1731 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java @@ -85,8 +85,8 @@ public abstract class AbstractServerCallListener implements AbstractServerCall.L } onReturn(r.getValue()); }); - } catch (Throwable t) { - responseObserver.onError(t); + } catch (Exception e) { + responseObserver.onError(e); } finally { RpcContext.removeCancellationContext(); RpcContext.removeContext(); From 9e38c48b685b6e47862f697add746b018c745ab0 Mon Sep 17 00:00:00 2001 From: earthchen Date: Sat, 25 Feb 2023 20:12:34 +0800 Subject: [PATCH 3/4] fix tri wrapper pack npe (#11656) --- .../dubbo/rpc/protocol/tri/ReflectionPackableMethod.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java index 39e16fa7cd..8667beb87a 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java @@ -360,6 +360,7 @@ public class ReflectionPackableMethod implements PackableMethod { private final String serialize; private final MultipleSerialization multipleSerialization; private final String[] argumentsType; + private final Class[] actualRequestTypes; private final URL url; private final boolean singleArgument; @@ -371,6 +372,7 @@ public class ReflectionPackableMethod implements PackableMethod { this.url = url; this.serialize = convertHessianToWrapper(serialize); this.multipleSerialization = multipleSerialization; + this.actualRequestTypes = actualRequestTypes; this.argumentsType = Stream.of(actualRequestTypes).map(Class::getName).toArray(String[]::new); this.singleArgument = singleArgument; } @@ -388,9 +390,10 @@ public class ReflectionPackableMethod implements PackableMethod { for (String type : argumentsType) { builder.addArgTypes(type); } - for (Object argument : arguments) { + for (int i = 0; i < arguments.length; i++) { + Object argument = arguments[i]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); - multipleSerialization.serialize(url, serialize, argument.getClass(), argument, bos); + multipleSerialization.serialize(url, serialize, actualRequestTypes[i], argument, bos); builder.addArgs(bos.toByteArray()); } return builder.build().toByteArray(); From 4ee5d0251bcfee4b889359e455e29df671f1c699 Mon Sep 17 00:00:00 2001 From: Albumen Kevin Date: Sun, 26 Feb 2023 11:22:35 +0800 Subject: [PATCH 4/4] Update .licenserc.yaml --- .licenserc.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.licenserc.yaml b/.licenserc.yaml index 651c2f5076..8c08d076f4 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -192,6 +192,8 @@ dependency: license: EPL-2.0 - name: org.glassfish:jakarta.el license: EPL-2.0 + - name: org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec + license: CDDL-1.1 - name: org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec license: EPL-2.0 - name: org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec