Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Challenge: Spot the Bug

DZone's Guide to

Challenge: Spot the Bug

· Agile Zone
Free Resource

The Agile Zone is brought to you in partnership with Techtown Training. Learn how DevOps and SAFe® can be used either separately or in unison as a way to make your organization more efficient, more effective, and more successful in our SAFe® vs DevOps eBook.

Speaking 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?



Adopting a DevOps practice starts with understanding where you are in the implementation journey. Download the DevOps Transformation Roadmap, brought to you in partnership with Techtown Training

Topics:

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}