yhs0092 opened a new issue, #4074:
URL: https://github.com/apache/servicecomb-java-chassis/issues/4074
## 问题现象
业务配置错误的 cors pattern, 如下:
```yaml
servicecomb:
cors:
enabled: true
origin: '\*\' # 这个值不对
```
将会导致 Java-Chassis 初始化 Vert.x server 端的时候在
`RestServerVerticle#mountCorsHandler` 方法中报错, 日志如下:
```
2023-12-02 09:50:31.561 [transport-vert.x-eventloop-thread-0] ERROR -
[VertxUtils.java:lambda$blockDeploy$0:98] - [] - deploy vertx failed, cause
java.lang.IllegalStateException: Invalid Origin, expected
<protocol>://<domain>[:<port>][</resource>]
at io.vertx.ext.web.impl.Origin.parse(Origin.java:195)
~[vertx-web-4.4.1.jar!/:4.4.1]
at
io.vertx.ext.web.handler.impl.CorsHandlerImpl.addOrigin(CorsHandlerImpl.java:85)
~[vertx-web-4.4.1.jar!/:4.4.1]
at
org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.getCorsHandler(RestServerVerticle.java:215)
~[transport-rest-vertx-2.8.9.jar!/:2.8.9]
at
org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.mountCorsHandler(RestServerVerticle.java:192)
~[transport-rest-vertx-2.8.9.jar!/:2.8.9]
at
org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.start(RestServerVerticle.java:94)
~[transport-rest-vertx-2.8.9.jar!/:2.8.9]
at
io.vertx.core.impl.DeploymentManager.lambda$doDeploy$5(DeploymentManager.java:196)
~[vertx-core-4.4.1.jar!/:4.4.1]
at
io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:264)
~[vertx-core-4.4.1.jar!/:4.4.1]
at
io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:246)
~[vertx-core-4.4.1.jar!/:4.4.1]
at
io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:43)
~[vertx-core-4.4.1.jar!/:4.4.1]
at
io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
[netty-common-4.1.100.Final.jar!/:4.1.100.Final]
at
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
[netty-common-4.1.100.Final.jar!/:4.1.100.Final]
at
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
[netty-common-4.1.100.Final.jar!/:4.1.100.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
[netty-transport-4.1.100.Final.jar!/:4.1.100.Final]
at
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
[netty-common-4.1.100.Final.jar!/:4.1.100.Final]
at
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
[netty-common-4.1.100.Final.jar!/:4.1.100.Final]
at
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[netty-common-4.1.100.Final.jar!/:4.1.100.Final]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_372]
```
问题在于, `org.apache.servicecomb.foundation.vertx.VertxUtils#blockDeploy` 方法部署
`RestServerVerticle` 的时候, 没有将异常信息返回给 main 线程抛出, 仅仅是返回一个 boolean 值表示是否部署成功. 这个
boolean 值结果也不会在 **main线程** 后面中断 Java-Chassis 的启动流程, 抛出异常之类的.
于是在业务开发者看来(通常他们只通过标准输出有没有异常来判断启动是否OK), 就是启动好像成功了, 但 Java-Chassis
存在网络传输模块未初始化等等问题.
## 建议
`org.apache.servicecomb.foundation.vertx.VertxUtils#blockDeploy` 方法的
`result` 不能只传递是否部署成功的 boolean 值, 而是应该把异常信息也传递过来. 如果 Server Verticle 部署失败,
则在main启动线程将原始异常包装后抛出, 这样可以让业务更容易意识到问题出在哪里.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]