public void rollover() throws RolloverFailure {

    // Inside this method it is guaranteed that the hereto active log file is
    // closed.
    // If maxIndex <= 0, then there is no file renaming to be done.
    if (maxIndex >= 0) {
      // Delete the oldest file, to keep Windows happy.
      File file = new File(fileNamePattern.convertInt(maxIndex));

      if (file.exists()) {
        file.delete();
      }

      // Map {(maxIndex - 1), ..., minIndex} to {maxIndex, ..., minIndex+1}
      for (int i = maxIndex - 1; i >= minIndex; i--) {
        String toRenameStr = fileNamePattern.convertInt(i);
        File toRename = new File(toRenameStr);
        // no point in trying to rename an inexistent file
        if (toRename.exists()) {
          util.rename(toRenameStr, fileNamePattern.convertInt(i + 1));
        } else {
          addInfo("Skipping roll-over for inexistent file " + toRenameStr);
        }
      }

      // move active file name to min
      switch (compressionMode) {
        case NONE:
          util.rename(getActiveFileName(), fileNamePattern.convertInt(minIndex));
          break;
        case GZ:
          compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), null);
          break;
        case ZIP:
          compressor.compress(
              getActiveFileName(),
              fileNamePattern.convertInt(minIndex),
              zipEntryFileNamePattern.convert(new Date()));
          break;
      }
    }
  }