-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
add restful protocol support by integrate jboss resteasy and testcase #458
Conversation
非常赞~我们尽快review 测试。 |
@dongfangshangren 我正在开发 RESTful 的支持(进度约 70%),也是基于 Resteasy, 不过容器我选用的 @rayzhang0603 麻烦在开发者文档中标注一下 Language Level ,不然有些特性不敢用(比如 multi catch)。 |
@smartwjw 要支持undertow、vertx,sunhttp参照NettyEndpointFactory继承AbstractEndpointFactory即可,由于Undertow并未实现EmbeddedJaxrsServer 需要继承RestServer。即可完成对undertow、vertx、sunhttp的支持 另外pom文件maven-compiler-plugin已经指定target,source级别 |
@smartwjw 目前pom中指定编译级别为1.6,后续会考虑升到1.7 |
@dongfangshangren 我在你的代码基础上增加了对 Undertow 的支持,不过我无法编辑这个 PR, 所以给你 fork 出来的仓库发 PR 了, 请帮忙 review. |
|
||
return resp.getValue(); | ||
}catch(Exception e){ | ||
Throwable cause = e.getCause(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provider在invoke时会把业务逻辑中抛出的异常转换为MotanBizException,在client端会对MotanBizException做单独处理,MotanBizException中封装的原始异常会在client端代码中抛出。因此这里还请改成直接抛出异常,这样client端端行为可以与其他协议保持一致。
建议改成:
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new InternalServerErrorException("provider call process error:" + e.getMessage(), e);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
其他没有发现什么问题,测试正常。 |
public Response toResponse(Exception exception){ | ||
HttpRequest httpRequest = ResteasyProviderFactory.getContextData(HttpRequest.class); | ||
// 当为rpc调用时,序列化异常 | ||
if(httpRequest != null & RestfulUtil.isRpcRequest(httpRequest.getMutableHeaders())){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (t != null & RestfulUtil.isRpcRequest(httpRequest.getMutableHeaders())){
...
}
应该是 t != null && RestfulUtil.isRpcRequest(httpRequest.getMutableHeaders())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里还请把&
改成 &&
,单&符所有条件语句都会执行的。 @dongfangshangren
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
手误,已修改
代码中的tab需要替换成4个空格。 |
添加restful协议支持