public void resize(long newSize) throws IOException {
    long oldSize;

    if (Files.exists(myFile)) {
      oldSize = Files.size(myFile);
    }
    else {
      Files.createDirectories(myFile.getParent());
      oldSize = 0;
    }
    if (oldSize == newSize && oldSize == length()) {
      return;
    }

    // FileChannel.truncate doesn't modify file if the given size is greater than or equal to the file's current size,
    // and it is not guaranteed that new partition will consist of null after truncate, so we should fill it manually
    long delta = newSize - oldSize;
    mySize = -1;
    if (delta > 0) {
      myStorageLockContext.executeOp(myFile, channel -> {
        channel.write(ByteBuffer.allocate(1), newSize - 1);
        return null;
      }, false);

      mySize = newSize;
      fillWithZeros(oldSize, delta);
    }
    else {
      myStorageLockContext.executeOp(myFile, channel -> {
        channel.truncate(newSize);
        return null;
      }, false);
      mySize = newSize;
    }
  }
public void resize(long newSize)