This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.1 by this push:
new 848edaa80f Fix service name mapping check failed (#11643)
848edaa80f is described below
commit 848edaa80fe4128adb9f8809f776272465b1d18e
Author: aamingaa <[email protected]>
AuthorDate: Sat Feb 25 17:13:44 2023 +0800
Fix service name mapping check failed (#11643)
---
.../metadata/MetadataServiceNameMapping.java | 28 +++++++++++++---------
.../rpc/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();