static void realFileDelete(FileReadLockKey readLockKey, AdvancedCache<Object, Integer> locksCache,
AdvancedCache<?, ?> chunksCache, AdvancedCache<?, ?> metadataCache) {
final boolean trace = log.isTraceEnabled();
final String indexName = readLockKey.getIndexName();
final String filename = readLockKey.getFileName();
final FileCacheKey key = new FileCacheKey(indexName, filename);
if (trace) log.tracef("deleting metadata: %s", key);
final FileMetadata file = (FileMetadata) metadataCache.remove(key);
final int bufferSize = file.getBufferSize();
if (file != null) { //during optimization of index a same file could be deleted twice, so you could see a null here
for (int i = 0; i < file.getNumberOfChunks(); i++) {