Source:
<code>private void putAllInternal(@Nonnull Map<? extends K, ? extends V> map, @Nullable SimpleCompletableFuture<Void> future) { checkNotNull(map, "Null argument map is not allowed"); ClientPartitionService partitionService = getContext().getPartitionService(); int partitionCount = partitionService.getPartitionCount(); Map<Integer, List<Map.Entry<Data, Data>>> entryMap = new HashMap<>(partitionCount); for (Entry<? extends K, ? extends V> entry : map.entrySet()) { checkNotNull(entry.getKey(), NULL_KEY_IS_NOT_ALLOWED); checkNotNull(entry.getValue(), NULL_VALUE_IS_NOT_ALLOWED); Data keyData = toData(entry.getKey()); int partitionId = partitionService.getPartitionId(keyData); List<Map.Entry<Data, Data>> partition = entryMap.get(partitionId); if (partition == null) { partition = new ArrayList<>(); entryMap.put(partitionId, partition); } partition.add(new AbstractMap.SimpleEntry<>(keyData, toData(entry.getValue()))); } List<Future<?>> futures = new ArrayList<>(entryMap.size()); AtomicInteger counter = new AtomicInteger(entryMap.size()); ExecutionCallback<ClientMessage> callback = new ExecutionCallback<ClientMessage>() { @Override public void onResponse(ClientMessage response) { if (counter.decrementAndGet() == 0) { finalizePutAll(map, entryMap); if (future != null) { future.setResult(null); } } } @Override public void onFailure(Throwable t) { if (future != null) { future.setResult(t); } onResponse(null); } }; for (Entry<Integer, List<Map.Entry<Data, Data>>> entry : entryMap.entrySet()) { Integer partitionId = entry.getKey(); ClientMessage request = MapPutAllCodec.encodeRequest(name, entry.getValue()); ClientInvocationFuture f = new ClientInvocation(getClient(), request, getName(), partitionId).invoke(); f.andThen(callback); futures.add(f); } if (future == null) { <START> try { <END> for (Future<?> f : futures) { f.get(); } } catch (Exception e) { throw rethrow(e); } } }</code><technical_language>FutureUtil.waitForever(futures, RETHROW_EVERYTHING); instead</technical_language>

Target:
private void putAllInternal(@Nonnull Map<? extends K, ? extends V> map, @Nullable SimpleCompletableFuture<Void> future) { if (map.isEmpty()) { if (future != null) { future.setResult(null); } return; } checkNotNull(map, "Null argument map is not allowed"); ClientPartitionService partitionService = getContext().getPartitionService(); int partitionCount = partitionService.getPartitionCount(); Map<Integer, List<Map.Entry<Data, Data>>> entryMap = new HashMap<>(partitionCount); for (Entry<? extends K, ? extends V> entry : map.entrySet()) { checkNotNull(entry.getKey(), NULL_KEY_IS_NOT_ALLOWED); checkNotNull(entry.getValue(), NULL_VALUE_IS_NOT_ALLOWED); Data keyData = toData(entry.getKey()); int partitionId = partitionService.getPartitionId(keyData); List<Map.Entry<Data, Data>> partition = entryMap.get(partitionId); if (partition == null) { partition = new ArrayList<>(); entryMap.put(partitionId, partition); } partition.add(new AbstractMap.SimpleEntry<>(keyData, toData(entry.getValue()))); } assert entryMap.size() > 0; AtomicInteger counter = new AtomicInteger(entryMap.size()); SimpleCompletableFuture<Void> resultFuture = future != null ? future : new SimpleCompletableFuture<>( getClient().getClientExecutionService().getUserExecutor(), getClient().getLoggingService().getLogger(ClientMapProxy.class)); ExecutionCallback<ClientMessage> callback = new ExecutionCallback<ClientMessage>() { @Override public void onResponse(ClientMessage response) { if (counter.decrementAndGet() == 0) { finalizePutAll(map, entryMap); resultFuture.setResult(null); } } @Override public void onFailure(Throwable t) { resultFuture.setResult(t); onResponse(null); } }; for (Entry<Integer, List<Map.Entry<Data, Data>>> entry : entryMap.entrySet()) { Integer partitionId = entry.getKey(); ClientMessage request = MapPutAllCodec.encodeRequest(name, entry.getValue()); new ClientInvocation(getClient(), request, getName(), partitionId) .invoke() .andThen(callback); } if (future == null) { try { resultFuture.get(); } catch (Throwable e) { throw rethrow(e); } } }