Source:
<code>public CompletableFuture<Void> reindex(Object... keys) { List<CompletableFuture<Void>> futures = new ArrayList<>(); Set<Object> everywhereSet = new HashSet<>(); Set<Object> primeownerSet = new HashSet<>(); for (Object key : keys) { <START> Class<?> indexedType = cache.get(key).getClass(); <END> EntityIndexBinding indexBinding = searchIntegrator.getIndexBinding(indexedType); MassIndexStrategy strategy = calculateStrategy(indexBinding, cache.getCacheConfiguration()); IndexingExecutionMode indexingStrategy = strategy.getIndexingStrategy(); switch (indexingStrategy) { case ALL: everywhereSet.add(key); break; case PRIMARY_OWNER: primeownerSet.add(key); break; } } if (everywhereSet.size() > 0) { IndexWorker indexWorkEverywhere = new IndexWorker(null, false, false, false, everywhereSet); DistributedTask<Void> taskEverywhere = executor .createDistributedTaskBuilder(indexWorkEverywhere) .timeout(0, TimeUnit.NANOSECONDS) .build(); List<CompletableFuture<Void>> futureList = executor.submitEverywhere(taskEverywhere); addFutureListToFutures(futures, futureList); } if (primeownerSet.size() > 0) { IndexWorker indexWorkEverywhere = new IndexWorker(null, false, false, false, null); DistributedTask<Void> taskEverywhere = executor .createDistributedTaskBuilder(indexWorkEverywhere) .timeout(0, TimeUnit.NANOSECONDS) .build(); List<CompletableFuture<Void>> futureList = executor.submitEverywhere(taskEverywhere, primeownerSet.toArray()); addFutureListToFutures(futures, futureList); } CompletableFuture<Void> compositeFuture = CompletableFuture.allOf(futures.toArray( new CompletableFuture[futures.size()])); return compositeFuture; }</code><technical_language>If key is there, this NPE</technical_language>

Target:
public CompletableFuture<Void> reindex(Object... keys) { List<CompletableFuture<Void>> futures = new ArrayList<>(); Set<Object> everywhereSet = new HashSet<>(); Set<Object> primeownerSet = new HashSet<>(); for (Object key : keys) { if (cache.containsKey(key)) { Class<?> indexedType = cache.get(key).getClass(); EntityIndexBinding indexBinding = searchIntegrator.getIndexBinding(indexedType); MassIndexStrategy strategy = calculateStrategy(indexBinding, cache.getCacheConfiguration()); IndexingExecutionMode indexingStrategy = strategy.getIndexingStrategy(); switch (indexingStrategy) { case ALL: everywhereSet.add(key); break; case PRIMARY_OWNER: primeownerSet.add(key); break; } } else { LOG.warn("cache contains no mapping for the key"); } } if (everywhereSet.size() > 0) { IndexWorker indexWorkEverywhere = new IndexWorker(null, false, false, false, everywhereSet); DistributedTask<Void> taskEverywhere = executor .createDistributedTaskBuilder(indexWorkEverywhere) .timeout(0, TimeUnit.NANOSECONDS) .build(); List<CompletableFuture<Void>> futureList = executor.submitEverywhere(taskEverywhere); addFutureListToFutures(futures, futureList); } if (primeownerSet.size() > 0) { IndexWorker indexWorkEverywhere = new IndexWorker(null, false, false, false, null); DistributedTask<Void> taskEverywhere = executor .createDistributedTaskBuilder(indexWorkEverywhere) .timeout(0, TimeUnit.NANOSECONDS) .build(); List<CompletableFuture<Void>> futureList = executor.submitEverywhere(taskEverywhere, primeownerSet.toArray()); addFutureListToFutures(futures, futureList); } CompletableFuture<Void> compositeFuture = CompletableFuture.allOf(futures.toArray( new CompletableFuture[futures.size()])); return compositeFuture; }