@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE")
    public List<Shard> shards(String... indices) {
        Map<String, String> idToAddress = nodes().stream().collect(toMap(Node::getId, Node::getHttpAddress));

        try {
            Request r = new Request("GET", "/_cat/shards/" + String.join(",", indices));
            r.addParameter("format", "json");
            r.addParameter("h", "id,index,shard,prirep,docs,state,ip,node");
            Response res = withRetry(() -> client.performRequest(r), retries);

            try (InputStreamReader reader = new InputStreamReader(res.getEntity().getContent(), UTF_8)) {
                JsonArray array = Json.parse(reader).asArray();
                List<Shard> shards = new ArrayList<>(array.size());
                for (JsonValue value : array) {
                    Optional<Shard> shard = convertToShard(value, idToAddress);
                    shard.ifPresent(shards::add);
                }

                LOG.log(FINE, "Shards " + shards);
                return shards;
            }
        } catch (IOException e) {
            throw new JetException("Could not get ES shards", e);
        }
    }
@Test
    public void shouldFailAfterFiveAttemptsShards() throws IOException {
        ElasticCatClient catClient = new ElasticCatClient(restClient, 2);

        when(restClient.performRequest(any()))
                .thenThrow(new IOException("Could not connect"));

        assertThatThrownBy(() -> catClient.shards("my-index"))
                .isInstanceOf(JetException.class)
                .hasRootCauseInstanceOf(IOException.class)
                .hasRootCauseMessage("Could not connect");
    }