Challenge: Spot the Bug
Join the DZone community and get the full member experience.
Join For FreeSpeaking of unfair interview questions, this would be a pretty evil one.
public MemoryMapPager(string file, FlushMode flushMode = FlushMode.Full) { _flushMode = flushMode; var fileInfo = new FileInfo(file); if (fileInfo.Exists == false || file.Length == 0) { _allocatedPages = 0; fileInfo.Create().Close(); } else { _allocatedPages = file.Length / PageSize; } _fileStream = fileInfo.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.Read); }
Can you see the bug? How would you fix it?
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments