Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix namemapping #11643

Merged
merged 3 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,6 +31,12 @@
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;
Expand Down Expand Up @@ -87,17 +87,23 @@ public boolean map(URL url) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void doSendMessage(Object message) {
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",
Expand Down Expand Up @@ -188,12 +188,12 @@ public final void onMessage(byte[] message) {
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);
}
Expand Down Expand Up @@ -391,10 +391,10 @@ protected ServerCall.Listener startInternalCall(
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public void invoke() {
}
onReturn(r.getValue());
});
} catch (Throwable t) {
responseObserver.onError(t);
} catch (Exception e) {
responseObserver.onError(e);
} finally {
RpcContext.removeCancellationContext();
RpcContext.removeContext();
Expand Down