You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/06/10 06:26:31 UTC

[GitHub] [dubbo] chickenlj commented on a diff in pull request #10040: [3.0] Cherry pick #9978 to 3.0

chickenlj commented on code in PR #10040:
URL: https://github.com/apache/dubbo/pull/10040#discussion_r894191406


##########
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/AccessLogFilter.java:
##########
@@ -148,23 +149,24 @@ private void writeLogSetToFile(String accessLog, Set<AccessLogData> logSet) {
 
     private void writeLogToFile() {
         if (!logEntries.isEmpty()) {
-            for (Map.Entry<String, Set<AccessLogData>> entry : logEntries.entrySet()) {
+            for (Map.Entry<String, Queue<AccessLogData>> entry : logEntries.entrySet()) {
                 String accessLog = entry.getKey();
-                Set<AccessLogData> logSet = entry.getValue();
+                Queue<AccessLogData> logSet = entry.getValue();
                 writeLogSetToFile(accessLog, logSet);
             }
         }
     }
 
-    private void processWithAccessKeyLogger(Set<AccessLogData> logSet, File file) throws IOException {
-        try (FileWriter writer = new FileWriter(file, true)) {
-            for (Iterator<AccessLogData> iterator = logSet.iterator();
-                 iterator.hasNext();
-                 iterator.remove()) {
-                writer.write(iterator.next().getLogMessage());
-                writer.write(System.getProperty("line.separator"));
+    private void processWithAccessKeyLogger(Queue<AccessLogData> logQueue, File file) throws IOException {
+        FileWriter writer = new FileWriter(file, true);
+        try {
+            while (!logQueue.isEmpty()) {
+                writer.write(logQueue.poll().getLogMessage());
+                writer.write(System.getProperty(LINE_SEPARATOR));

Review Comment:
   It's fine for this task will be scheduled in a separate thread.



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org