int index = Integer.valueOf(hash) % connections.size();
will yield a negative value and trigger a IndexOutOfBoundsException in the following line:
return connections.subList(index, index+1);
Also, when we have multiple fieldNames we will probably get errors on Integer.valueOf(hash) as the string may not be a valid Integer. This can occur either by overflow (multiple positive hashs concatenated) or invalid numbers (imagine "1000000000" and "-1000000000" hashes).
Finally, if you are going to concatenate Strings on a loop, it's better to use a StringBuilder instead of the += operator. StringBuilder doesn't need to keep creating new String objects every time you append a new String to it.
For
when value.hashCode() < 0
will yield a negative value and trigger a IndexOutOfBoundsException in the following line:
Also, when we have multiple fieldNames we will probably get errors on Integer.valueOf(hash) as the string may not be a valid Integer. This can occur either by overflow (multiple positive hashs concatenated) or invalid numbers (imagine "1000000000" and "-1000000000" hashes).
Finally, if you are going to concatenate Strings on a loop, it's better to use a StringBuilder instead of the += operator. StringBuilder doesn't need to keep creating new String objects every time you append a new String to it.