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 @@ -35,10 +35,9 @@
/**
* Memory mapped file buffer allocation service.
* Main purpose of this utility class is to overcome a Java issue on Windows with memory mapped file.
* Once Random access file is closed, file cannot be delete until buffer has been garbage collected.
* Once Random access file is closed, file cannot be deleted until buffer has been garbage collected.
* The workaround used here is to start a "cleaner" thread that try to delete the file every minute.
*/
/**
*
* @author Paul Bui-Quang {@literal <paul.buiquang at rte-france.com>}
*/

Expand Down Expand Up @@ -119,11 +118,13 @@ public ByteBuffer create(String fileName, int size) {

private boolean tryToDelete(BufferContext context) {
try {
Files.delete(context.file.toPath());
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Buffer {} deleted", context.file);
if (context.file != null) {
Files.delete(context.file.toPath());
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Buffer {} deleted", context.file);
}
context.file = null;
}
context.file = null;
} catch (IOException e) {
LOGGER.trace(e.toString(), e);
}
Expand Down
Loading