Allow to disable buffering in JULI FileHandler
The previous implementation did not work as expected because of buffering performed by OutputStreamWriter
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@897380
13f79535-47bb-0310-9956-
ffa450edef68
try {
PrintWriter writer = this.writer;
if (writer!=null) {
- writer.write(result);
+ if (bufferSize > 0) {
+ writer.write(result);
+ } else {
+ synchronized (this) {
+ // OutputStreamWriter performs buffering inside its StreamEncoder,
+ // and so to run without a buffer we have to flush explicitly
+ writer.write(result);
+ writer.flush();
+ }
+ }
} else {
reportError("FileHandler is closed or not yet initialized, unable to log ["+result+"]", null, ErrorManager.WRITE_FAILURE);
}