Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public final class ZeroCopyFileWriter extends AuditFileWriter implements Seriali
/** The path. */
private final String path;

/** To track last opened random access file **/
String lastRealPath;

/**
* Instantiates a new zero copy file writer.
*
Expand Down Expand Up @@ -89,11 +92,15 @@ public ZeroCopyFileWriter write(String event) {
FileHandlerUtil.generateAuditFileName());

try {
if (FileHandlerUtil.isFileAlreadyExists(realPath)) {
randomAccessFile = new RandomAccessFile(realPath, CoreConstants.READ_WRITE);
} else {
randomAccessFile = new RandomAccessFile(new File(realPath), CoreConstants.READ_WRITE);
}
/** Close last instance for random access file. **/
if (randomAccessFile != null && !realPath.equals(lastRealPath)) {
this.stop();
}

if (randomAccessFile == null) {
lastRealPath = realPath;
randomAccessFile = new RandomAccessFile(new File(realPath), CoreConstants.READ_WRITE);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down