You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/07/18 08:19:24 UTC

[GitHub] [rocketmq] Oliverwqcwrw commented on a diff in pull request #4590: [ISSUE #4589] Close stream

Oliverwqcwrw commented on code in PR #4590:
URL: https://github.com/apache/rocketmq/pull/4590#discussion_r923078906


##########
logging/src/main/java/org/apache/rocketmq/logging/inner/LoggingBuilder.java:
##########
@@ -708,17 +708,30 @@ public synchronized void setFile(String fileName, boolean append, boolean buffer
                     throw ex;
                 }
             }
-            Writer fw = createWriter(ostream);
-            if (bufferedIO) {
-                fw = new BufferedWriter(fw, bufferSize);
+            Writer fw = null;
+            try {
+                fw = createWriter(ostream);
+                if (bufferedIO) {
+                    fw = new BufferedWriter(fw, bufferSize);
+                }
+                this.setQWForFiles(fw);
+                this.fileName = fileName;
+                this.fileAppend = append;
+                this.bufferedIO = bufferedIO;
+                this.bufferSize = bufferSize;
+                writeHeader();
+                SysLogger.debug("setFile ended");
+            } catch (Exception e) {
+                throw e;
+            } finally {
+                if (ostream != null) {
+                    ostream.close();
+                }
+                if (fw != null) {

Review Comment:
   Thank you very much for your advice
   
   I tried it and did get an error when printing logs asynchronously, so I turned off pr for now



-- 
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: dev-unsubscribe@rocketmq.apache.org

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