int (final ThreadLocalRandom current) { for (int i = 0; i < 1024; i++) { final int key = current.nextInt(); if (!generatedKeyValues.containsKey(key)) { return key; } } //avoid test hangs in pathological cases: throw new IllegalStateException("Something is wrong with 1024 random ints all contained in generatedKeyValues"); }