The warning itself explains why you're getting the warning.
You're calling Math.abs()
on a hashcode. Integers go from −2,147,483,648 to 2,147,483,647. Since the maximum is 2,147,483,647, Math.abs(-2,147,483,648)
returns -2,147,483,648 because there is no 2,147,483,648. If your String hashcodes to -2,147,483,648, then the server
variable will be assigned to a negative value, which may cause the query to be dropped or your service to crash.
Rather than do it that way, just do the modulus first and then call Math.abs()
.
int server = Math.abs(q.hashCode() % solrLoadBalanceNumOfServers) + 1;