core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALSegmentCache.java
public void close(boolean flush) {

    closer.shutdown();
    try {
      if (!closer.awaitTermination(CLOSER_TIMEOUT_MIN, TimeUnit.MINUTES)) {
        OLogManager.instance().error(this, "Can not close file " + path.getFileName(), null);
      } else {
        synchronized (lockObject) {
          try {
            if (segChannel != null) {
              closeFile(flush);
            }
          } catch (IOException ioe) {
            OLogManager.instance().error(this, "Can not close file " + path.getFileName(), ioe);
          }
        }
      }
    } catch (InterruptedException ie) {
      OLogManager.instance().warn(this, "WAL file " + path.getFileName() + " close was interrupted", ie);
    }

  }
public void close(boolean flush) {

    closer.shutdown();
    try {
      if (!closer.awaitTermination(CLOSER_TIMEOUT_MIN, TimeUnit.MINUTES)) {
        OLogManager.instance().error(this, "Can not close file " + path.getFileName(), null);
      } else {
        synchronized (lockObject) {
          try {
            if (segChannel != null) {
              closeFile(flush);
            }
          } catch (IOException ioe) {
            OLogManager.instance().error(this, "Can not close file " + path.getFileName(), ioe);
          }
        }
      }
    } catch (InterruptedException ie) {
      OLogManager.instance().warn(this, "WAL file " + path.getFileName() + " close was interrupted", ie);
    }

  }
Writes cache content to the file and closes it.
Calls <code>fsync</code> if needed.