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 07:54:33 UTC

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

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


##########
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:
   The osstream and fw is referenced by the qwWriter, which will be released via coseFile().



-- 
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