Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

调用接口传递@TarsContext java.util.Map<String, String> ctx 参数无效 #224

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

Open
szr123 wants to merge 2 commits into TarsCloud:v1.7.x
base: v1.7.x
Choose a base branch
Loading
from szr123:v1.7.x
Open
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
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected void doRealInvoke(Request request, Response response) throws Throwable
BeanAccessor.setBeanValue(tarsServantResponse, "result", result.getResult());
BeanAccessor.setBeanValue(tarsServantResponse, "ret", result.getRet());
BeanAccessor.setBeanValue(tarsServantResponse, "remark", result.getRemark());
BeanAccessor.setBeanValue(tarsServantResponse, "context", result.getContext());
} catch (Exception e) {
BeanAccessor.setBeanValue(tarsServantResponse, "cause", e);
throw e;
Expand Down
19 changes: 12 additions & 7 deletions core/src/main/java/com/qq/tars/rpc/protocol/tars/TarsCodec.java
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,20 @@ public void decodeResponseBody(ServantResponse resp) throws ProtocolException {
response.setResult(results[i++]);
}

response.setContext((HashMap<String, String>) is.read(TarsHelper.STAMP_MAP, 9, false));
List<TarsMethodParameterInfo> list = methodInfo.getParametersList();
for (TarsMethodParameterInfo info : list) {
if (!TarsHelper.isHolder(info.getAnnotations())) {
continue;
}
try {
TarsHelper.setHolderValue(request.getMethodParameters()[info.getOrder() - 1], results[i++]);
} catch (Exception e) {
throw new ProtocolException(e);
if (TarsHelper.isHolder(info.getAnnotations())) {
try {
TarsHelper.setHolderValue(request.getMethodParameters()[info.getOrder() - 1], results[i++]);
} catch (Exception e) {
throw new ProtocolException(e);
}
} else if (TarsHelper.isContext(info.getAnnotations()) && response.getContext() != null) {
Map<String, String> context = (HashMap<String, String>) request.getMethodParameters()[info.getOrder() - 1];
if (context != null) {
context.putAll(response.getContext());
}
}
}
response.setStatus((HashMap<String, String>) is.read(TarsHelper.STAMP_MAP, 7, false));
Expand Down

AltStyle によって変換されたページ (->オリジナル) /