You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/12/12 06:00:15 UTC

[GitHub] gdouyang opened a new issue #1031: 关于jackson自定Serializer中调用ContextUtils.getInvocationContext()返回null问题

gdouyang opened a new issue #1031: 关于jackson自定Serializer中调用ContextUtils.getInvocationContext()返回null问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1031
 
 
   请问目前我有一个场景需要根据当前语言对字段做国际化,在自定义Serializer中调用ContextUtils.getInvocationContext()来获取里面所存放的语言,但这个一直返回null,跟踪调用发现使用了SwaggerProducerOperation#syncInvoke这个方法,在Controller返回结束时将removeInvocationContext,这个是不是可以跟completableFutureInvoke方法一样把ContextUtils.removeInvocationContext();放到最后一行?
   ```
     public void completableFutureInvoke(SwaggerInvocation invocation, AsyncResponse asyncResp) {
       ContextUtils.setInvocationContext(invocation);
       doCompletableFutureInvoke(invocation, asyncResp);
       ContextUtils.removeInvocationContext();
     }
   
     public void syncInvoke(SwaggerInvocation invocation, AsyncResponse asyncResp) {
       ContextUtils.setInvocationContext(invocation);
       Response response = doInvoke(invocation);
       ContextUtils.removeInvocationContext();
       asyncResp.handle(response);// 这个是不是可以向上移动一行
     }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services