Source:
<code>public List<ResponseInfo> sendAndPoll(List<RequestInfo> allRequestsToSend, Set<Integer> allRequestsToDrop, int pollTimeoutMs) { Function<ReplicaType, Pair<List<RequestInfo>, Set<Integer>>> pairBuilder = replicaType -> new Pair<>(new ArrayList<>(), new HashSet<>()); EnumMap<ReplicaType, Pair<List<RequestInfo>, Set<Integer>>> requestsToSendAndDropByType = new EnumMap<>(ReplicaType.class); for (RequestInfo requestInfo : allRequestsToSend) { ReplicaType replicaType = requestInfo.getReplicaId().getReplicaType(); requestsToSendAndDropByType.computeIfAbsent(replicaType, pairBuilder).getFirst().add(requestInfo); correlationIdToReplicaType.put(requestInfo.getRequest().getCorrelationId(), replicaType); } for (Integer correlationId : allRequestsToDrop) { ReplicaType replicaType = correlationIdToReplicaType.get(correlationId); if (replicaType != null) { requestsToSendAndDropByType.computeIfAbsent(replicaType, pairBuilder).getSecond().add(correlationId); } } List<ResponseInfo> responses = new ArrayList<>(); requestsToSendAndDropByType.forEach((replicaType, requestsToSendAndDrop) -> { NetworkClient client = childNetworkClients.get(replicaType); if (client == null) { <START> throw new IllegalStateException("No NetworkClient configured for replica type: " + replicaType); <END> } responses.addAll( client.sendAndPoll(requestsToSendAndDrop.getFirst(), requestsToSendAndDrop.getSecond(), pollTimeoutMs)); }); responses.forEach( response -> correlationIdToReplicaType.remove(response.getRequestInfo().getRequest().getCorrelationId())); return responses; }</code><technical_language>This pretty late in method throw exception this. catch earlier</technical_language>

Target:
public List<ResponseInfo> sendAndPoll(List<RequestInfo> allRequestsToSend, Set<Integer> allRequestsToDrop, int pollTimeoutMs) { Function<ReplicaType, Pair<List<RequestInfo>, Set<Integer>>> pairBuilder = replicaType -> { if (!childNetworkClients.containsKey(replicaType)) { throw new IllegalStateException("No NetworkClient configured for replica type: " + replicaType); } return new Pair<>(new ArrayList<>(), new HashSet<>()); }; EnumMap<ReplicaType, Pair<List<RequestInfo>, Set<Integer>>> requestsToSendAndDropByType = new EnumMap<>(ReplicaType.class); for (RequestInfo requestInfo : allRequestsToSend) { ReplicaType replicaType = requestInfo.getReplicaId().getReplicaType(); requestsToSendAndDropByType.computeIfAbsent(replicaType, pairBuilder).getFirst().add(requestInfo); correlationIdToReplicaType.put(requestInfo.getRequest().getCorrelationId(), replicaType); } for (Integer correlationId : allRequestsToDrop) { ReplicaType replicaType = correlationIdToReplicaType.get(correlationId); if (replicaType != null) { requestsToSendAndDropByType.computeIfAbsent(replicaType, pairBuilder).getSecond().add(correlationId); } } List<ResponseInfo> responses = new ArrayList<>(); requestsToSendAndDropByType.forEach((replicaType, requestsToSendAndDrop) -> { NetworkClient client = childNetworkClients.get(replicaType); responses.addAll( client.sendAndPoll(requestsToSendAndDrop.getFirst(), requestsToSendAndDrop.getSecond(), pollTimeoutMs)); }); responses.forEach( response -> correlationIdToReplicaType.remove(response.getRequestInfo().getRequest().getCorrelationId())); return responses; }