java.lang.ArithmeticException: / by zero

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Hi, I'm having trouble using capabilities with the java compat libraries. An isolated test case below gives the following stack trace: {noformat} java.lang.ArithmeticException: / by zero at com.linkedin.norbert.network.client.loadbalancer.LoadBalancerHelpers$class.chooseNext(LoadBalancerFactory.scala:76) at com.linkedin.norbert.network.client.loadbalancer.RoundRobinLoadBalancerFactory.chooseNext(RoundRobinLoadBalancerFactory.scala:26) at com.linkedin.norbert.network.client.loadbalancer.RoundRobinLoadBalancerFactory$$anon$1.nextNode(RoundRobinLoadBalancerFactory.scala:36) at com.linkedin.norbert.javacompat.network.RoundRobinLoadBalancerFactory$1.nextNode(RoundRobinLoadBalancerFactory.java:44) {noformat} The same exception can be triggered by sendRequest(..capability..) via underlying(). This is somewhat hacky, but sendRequest(..capability..) is not available in the java interface (maybe intentional?) {code} ClusterClient cc = new InMemoryClusterClient(null, "unittest"); cc.awaitConnectionUninterruptibly(); cc.addNode(1, "localhost:12340"); NetworkServerConfig srvCfg = new NetworkServerConfig(); srvCfg.setClusterClient(cc); NettyNetworkServer ns = new NettyNetworkServer(srvCfg); ns.bind(1, true, 1L); // capability 1 NetworkClientConfig cliCfg = new NetworkClientConfig(); cliCfg.setClusterClient(cc); NettyNetworkClient nc = new NettyNetworkClient(cliCfg, new RoundRobinLoadBalancerFactory()); System.out.println("cc.getNodes() : "+cc.getNodes()); Either eitherLb =(Either) nc.underlying().com$linkedin$norbert$network$client$NetworkClient$$loadBalancer().get(); Object r = eitherLb.right().get(); LoadBalancer lb = (LoadBalancer)r; System.out.println("lb.nextNode : "+lb.nextNode()); System.out.println("lb.nextNode(0) : "+lb.nextNode(Option.apply(0L))); System.out.println("lb.nextNode(1) : "+lb.nextNode(Option.apply(1L))); {code} The output is: {noformat} cc.getNodes() : [JavaNode(1,localhost:12340,true,[],Some(1))] lb.nextNode : Some(Node(1,localhost:12340,[],true,0x00000000)) lb.nextNode(0) : Some(Node(1,localhost:12340,[],true,0x00000000)) {noformat} The last code line fails with the exception above. Note that the cc.getNodes() (which gives the java-version of the node) indicates the right capabilities, but the Scala node from nextNode version doesn't seem to have the capabilities? This is on current HEAD (69c3a7ccbaf22d751f6282e7b6eb9dab19b04954), but the problem occurs on 0.6.29-SNAPSHOT as well. A patch for RoundRobinLoadBalancerFactory.scala is attached, but this only fixes the divide-by-zero bug.. I still don't get any nodes, and my scala/norbert internals experience is not that high-level, so any pointers/patches/suggestions are welcome! Thanks
    via by Johan Ström,
  • Hi, I'm having trouble using capabilities with the java compat libraries. An isolated test case below gives the following stack trace: {noformat} java.lang.ArithmeticException: / by zero at com.linkedin.norbert.network.client.loadbalancer.LoadBalancerHelpers$class.chooseNext(LoadBalancerFactory.scala:76) at com.linkedin.norbert.network.client.loadbalancer.RoundRobinLoadBalancerFactory.chooseNext(RoundRobinLoadBalancerFactory.scala:26) at com.linkedin.norbert.network.client.loadbalancer.RoundRobinLoadBalancerFactory$$anon$1.nextNode(RoundRobinLoadBalancerFactory.scala:36) at com.linkedin.norbert.javacompat.network.RoundRobinLoadBalancerFactory$1.nextNode(RoundRobinLoadBalancerFactory.java:44) {noformat} The same exception can be triggered by sendRequest(..capability..) via underlying(). This is somewhat hacky, but sendRequest(..capability..) is not available in the java interface (maybe intentional?) {code} ClusterClient cc = new InMemoryClusterClient(null, "unittest"); cc.awaitConnectionUninterruptibly(); cc.addNode(1, "localhost:12340"); NetworkServerConfig srvCfg = new NetworkServerConfig(); srvCfg.setClusterClient(cc); NettyNetworkServer ns = new NettyNetworkServer(srvCfg); ns.bind(1, true, 1L); // capability 1 NetworkClientConfig cliCfg = new NetworkClientConfig(); cliCfg.setClusterClient(cc); NettyNetworkClient nc = new NettyNetworkClient(cliCfg, new RoundRobinLoadBalancerFactory()); System.out.println("cc.getNodes() : "+cc.getNodes()); Either eitherLb =(Either) nc.underlying().com$linkedin$norbert$network$client$NetworkClient$$loadBalancer().get(); Object r = eitherLb.right().get(); LoadBalancer lb = (LoadBalancer)r; System.out.println("lb.nextNode : "+lb.nextNode()); System.out.println("lb.nextNode(0) : "+lb.nextNode(Option.apply(0L))); System.out.println("lb.nextNode(1) : "+lb.nextNode(Option.apply(1L))); {code} The output is: {noformat} cc.getNodes() : [JavaNode(1,localhost:12340,true,[],Some(1))] lb.nextNode : Some(Node(1,localhost:12340,[],true,0x00000000)) lb.nextNode(0) : Some(Node(1,localhost:12340,[],true,0x00000000)) {noformat} The last code line fails with the exception above. Note that the cc.getNodes() (which gives the java-version of the node) indicates the right capabilities, but the Scala node from nextNode version doesn't seem to have the capabilities? This is on current HEAD (69c3a7ccbaf22d751f6282e7b6eb9dab19b04954), but the problem occurs on 0.6.29-SNAPSHOT as well. A patch for RoundRobinLoadBalancerFactory.scala is attached, but this only fixes the divide-by-zero bug.. I still don't get any nodes, and my scala/norbert internals experience is not that high-level, so any pointers/patches/suggestions are welcome! Thanks
    via by Johan Ström,
    • java.lang.ArithmeticException: / by zero at com.linkedin.norbert.network.client.loadbalancer.LoadBalancerHelpers$class.chooseNext(LoadBalancerFactory.scala:76) at com.linkedin.norbert.network.client.loadbalancer.RoundRobinLoadBalancerFactory.chooseNext(RoundRobinLoadBalancerFactory.scala:26) at com.linkedin.norbert.network.client.loadbalancer.RoundRobinLoadBalancerFactory$$anon$1.nextNode(RoundRobinLoadBalancerFactory.scala:36) at com.linkedin.norbert.javacompat.network.RoundRobinLoadBalancerFactory$1.nextNode(RoundRobinLoadBalancerFactory.java:44)
    No Bugmate found.