Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
Description
Look at the Leader#processSync method:
public synchronized void processSync(LearnerSyncRequest r) { if (outstandingProposals.isEmpty()) { sendSync(r); } else { List<LearnerSyncRequest> l = pendingSyncs.get(lastProposed); if (l == null) { l = new ArrayList<LearnerSyncRequest>(); } l.add(r); pendingSyncs.put(lastProposed, l); } }
we can use theĀ computeIfAbsent to make the code more clean and elegant. For example(just one line code):
pendingSyncs.computeIfAbsent(lastProposed, k -> new ArrayList<>()).add(r);
Attachments
Issue Links
- links to