merlimat commented on code in PR #3848:
URL: https://github.com/apache/bookkeeper/pull/3848#discussion_r1131230075


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java:
##########
@@ -503,17 +513,18 @@ public void run() {
                     // responses
                     for (int i = 0; i < requestsCount; i++) {
                         ForceWriteRequest req = localRequests.get(i);
-                        numReqInLastForceWrite += req.process();
+                        numReqInLastForceWrite += req.process(writeHandlers);
                         req.recycle();
                     }
 
                     journalStats.getForceWriteGroupingCountStats()
                             .registerSuccessfulValue(numReqInLastForceWrite);
-
-                    if (requestProcessor != null) {
-                        requestProcessor.flushPendingResponses();
+                    if (writeHandlers.size() > 0) {
+                        for (ObjectCursor<BookieRequestHandler> writeHandler : 
writeHandlers) {
+                            writeHandler.value.flushPendingResponse();
+                        }
+                        writeHandlers.clear();
                     }

Review Comment:
   In this case it would efficient to use the lambda approach because it would 
be non-capturing and `ObjectHashSet` is not going to create an iterator either.
   
   ```suggestion
                       writeHandlers.forEach(wh -> wh.flushPendingResponse());
                       writeHandlers.clear();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to