wuyunfeng opened a new issue #4970: URL: https://github.com/apache/incubator-doris/issues/4970
**Describe the bug** ``` public TNetworkAddress randomAddress(Map<String, EsNodeInfo> nodesInfo) { int seed = new Random().nextInt() % nodesInfo.size(); EsNodeInfo[] nodeInfos = (EsNodeInfo[]) nodesInfo.values().toArray(); return nodeInfos[seed].getPublishAddress(); } ``` 1. Random().nextInt() would return negative int number resulting in `java.lang.ArrayIndexOutOfBoundsException` 2. (EsNodeInfo[]) nodesInfo.values().toArray() this would lead `java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lorg.apache.doris.external.elasticsearch.EsNodeInfo` **To Reproduce** Has something to do with some `incredible` environment **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: [e.g. iOS] - Browser [e.g. chrome, safari] - Version [e.g. 22] **Smartphone (please complete the following information):** - Device: [e.g. iPhone6] - OS: [e.g. iOS8.1] - Browser [e.g. stock browser, safari] - Version [e.g. 22] **Additional context** ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org