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 2019/02/01 07:00:23 UTC

[GitHub] willard-kali opened a new issue #1086: 【求助】edge service自定义返回302进行重定向报错

willard-kali opened a new issue #1086: 【求助】edge service自定义返回302进行重定向报错
URL: https://github.com/apache/servicecomb-java-chassis/issues/1086
 
 
   应用场景:
   edgeservice作为边缘服务,实现路由到非微服务的https的web服务请求,并在登陆成功后完成重定向到首页。
   实现:
   写了一个dispatcher,匹配/login的请求,在onRequest中,override sendResponse方法,在方法中增加如下代码:
   `context.response().headers().add("Location", "/login.html");
   response.setStatus(Response.create(302, "", "").getStatus());
   super.sendResponse(response);`
   上述方式确实能实现跳转,但是对应到后端日志却报了异常:
   _[ERROR] Failed to execute HttpServerFilters, operation:login-service.login, request uri:/login org.apache.servicecomb.common.rest.AbstractRestInvocation.onExecuteHttpServerFiltersFinish(AbstractRestInvocation.java:296)
   java.lang.ClassCastException: com.test.porter.user.entity.UserInfo cannot be cast to org.apache.servicecomb.swagger.invocation.exception.InvocationException
   	at org.apache.servicecomb.common.rest.filter.inner.ServerRestArgsFilter.beforeSendResponseAsync(ServerRestArgsFilter.java:72)
   	at org.apache.servicecomb.common.rest.filter.HttpServerFilterBeforeSendResponseExecutor.safeInvoke(HttpServerFilterBeforeSendResponseExecutor.java:52)
   	at org.apache.servicecomb.common.rest.filter.HttpServerFilterBeforeSendResponseExecutor.doRun(HttpServerFilterBeforeSendResponseExecutor.java:74)
   	at org.apache.servicecomb.common.rest.filter.HttpServerFilterBeforeSendResponseExecutor.run(HttpServerFilterBeforeSendResponseExecutor.java:44)
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.executeHttpServerFilters(AbstractRestInvocation.java:284)
   	at org.apache.servicecomb.common.rest.AbstractRestInvocation.sendResponse(AbstractRestInvocation.java:278)_
   查看了ServerRestArgsFilter.java:72,发现源码中,针对response会做检查,判断如果非2XX的响应码,会强制转换成InvocationException用来获取错误信息。
   针对我这种场景,这个情况算不算是一个BUG?是否有其他推荐用法?

----------------------------------------------------------------
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