Package ch.qos.logback.core.net
Class AutoFlushingObjectWriter
- java.lang.Object
-
- ch.qos.logback.core.net.AutoFlushingObjectWriter
-
- All Implemented Interfaces:
ObjectWriter
public class AutoFlushingObjectWriter extends java.lang.Object implements ObjectWriter
Automatically flushes the underlyingObjectOutputStream
immediately after calling it'sObjectOutputStream.writeObject(Object)
method.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.ObjectOutputStream
objectOutputStream
private int
resetFrequency
private int
writeCounter
-
Constructor Summary
Constructors Constructor Description AutoFlushingObjectWriter(java.io.ObjectOutputStream objectOutputStream, int resetFrequency)
Creates a new instance for the givenObjectOutputStream
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
preventMemoryLeak()
Failing to reset the object output stream every now and then creates a serious memory leak which is why the underlying stream will be reset according to theresetFrequency
.void
write(java.lang.Object object)
Writes an object to an output.
-
-
-
Constructor Detail
-
AutoFlushingObjectWriter
public AutoFlushingObjectWriter(java.io.ObjectOutputStream objectOutputStream, int resetFrequency)
Creates a new instance for the givenObjectOutputStream
.- Parameters:
objectOutputStream
- the stream to write toresetFrequency
- the frequency with which the given stream will be automatically reset to prevent a memory leak
-
-
Method Detail
-
write
public void write(java.lang.Object object) throws java.io.IOException
Description copied from interface:ObjectWriter
Writes an object to an output.- Specified by:
write
in interfaceObjectWriter
- Parameters:
object
- theObject
to write- Throws:
java.io.IOException
- in case input/output fails, details are defined by the implementation
-
preventMemoryLeak
private void preventMemoryLeak() throws java.io.IOException
Failing to reset the object output stream every now and then creates a serious memory leak which is why the underlying stream will be reset according to theresetFrequency
.- Throws:
java.io.IOException
-
-