Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileStore.setSeqNum() not disposing StreamWriter #277

Closed
josephlam opened this issue Sep 16, 2014 · 0 comments · Fixed by #918
Closed

FileStore.setSeqNum() not disposing StreamWriter #277

josephlam opened this issue Sep 16, 2014 · 0 comments · Fixed by #918

Comments

@josephlam
Copy link

    private void setSeqNum()
    {
        seqNumsFile_.Seek(0, System.IO.SeekOrigin.Begin);
        System.IO.StreamWriter writer = new System.IO.StreamWriter(seqNumsFile_);

        writer.Write(GetNextSenderMsgSeqNum().ToString("D10") + " : " + GetNextTargetMsgSeqNum().ToString("D10") + "  ");
        writer.Flush();
    }

writer isn't closed/disposed. Should wrap in a using() block.
Since .Net 4.5 it's possible to dispose StreamWriter without closing the underlying stream:
https://connect.microsoft.com/VisualStudio/feedback/details/164680/streamwriter-incorrectly-disposes-underlying-stream
Or maybe it should be keeping the StreamWriter in the seqNumsFile instance variable instead of the underlying FileStream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant