[技术干货] ClientPoolManager java.lang.ArithmeticException: / by zero

有些业务经常出现下面的错误:


Caused by: org.apache.servicecomb.core.exception.CseException: This is a fallback call from circuit breaker.
 You can add fallback logic by catching this exception.
 info: operation=xxxl.
        at org.apache.servicecomb.bizkeeper.BizkeeperExceptionUtils.createBizkeeperException(BizkeeperExceptionUtils.java:37)
        at org.apache.servicecomb.bizkeeper.FallbackPolicyManager.getFallbackResponse(FallbackPolicyManager.java:46)
        ... 134 common frames omitted
Caused by: java.lang.ArithmeticException: / by zero
        at org.apache.servicecomb.foundation.vertx.client.ClientPoolManager.findThreadBindClientPool(ClientPoolManager.java:116)
        at org.apache.servicecomb.foundation.vertx.client.ClientPoolManager.findClientPool(ClientPoolManager.java:76)
        at org.apache.servicecomb.foundation.vertx.client.ClientPoolManager.findClientPool(ClientPoolManager.java:71)
        at org.apache.servicecomb.transport.rest.client.RestTransportClient.findHttpClientPool(RestTransportClient.java:126)
        at org.apache.servicecomb.transport.rest.client.RestTransportClient.send(RestTransportClient.java:113)
        at org.apache.servicecomb.transport.rest.vertx.VertxRestTransport.send(VertxRestTransport.java:86)
        at org.apache.servicecomb.core.handler.impl.TransportClientHandler.handle(TransportClientHandler.java:42)
        at org.apache.servicecomb.core.Invocation.next(Invocation.java:204)
        at org.apache.servicecomb.bizkeeper.BizkeeperCommand.lambda$construct$2(BizkeeperCommand.java:79)
        ... 109 common frames omitted


这个不是熔断,只是调用出错了, 执行 fallback 的日志。 https://docs.servicecomb.io/java-chassis/zh_CN/references-handlers/bizkeeper/ 错误原因是 / by zero 。 通常可能是服务启动就已经出错了,导致的,可以往前面看下是否有启动失败日志。 或者是在服务启动还没就绪,业务就调用接口,比如在 spring bean 初始化过程中调用接口等。


从 java-chassis 2.1.1 开始, 增对这种场景打印了错误提示。 https://github.com/apache/servicecomb-java-chassis/pull/1905/files