dongeforever commented on code in PR #4590:
URL: https://github.com/apache/rocketmq/pull/4590#discussion_r923062757
##########
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 ostream and fw cannot be closed here, otherwise, the logger appender
will fail to write the log.
--
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]