Issue 68 in gitsharp: Deciding who is responsible for disposing Repository

3 views
Skip to first unread message

gits...@googlecode.com

unread,
Jan 3, 2011, 10:33:59 AM1/3/11
to gits...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 68 by dvdvorle: Deciding who is responsible for disposing
Repository
http://code.google.com/p/gitsharp/issues/detail?id=68

In the current implementation of Dispose in
GitSharp.Commands.AbstractCommand, _repository.Dispose() is called. The
problem with that is that that field is exposed through the
property "Repository".

So disposing the AbstractCommand(or any derived class) will also dispose of
the repository, while somebody may have gotten a reference to the
repository through the property.

So the general question is; "Who disposes of an IDisposable public
property?".
Here are a few answers:
http://stackoverflow.com/questions/674879/who-disposes-of-an-idisposable-public-property

So, who is responsible for disposing the Repository object, the Command
using the repository, or the consumer of the repository?

What do you guys think?


gits...@googlecode.com

unread,
Jan 5, 2011, 4:35:09 PM1/5/11
to gits...@googlegroups.com

Comment #1 on issue 68 by meinrad.recheis: Deciding who is responsible for
disposing Repository
http://code.google.com/p/gitsharp/issues/detail?id=68

hi,

the user can create a repository instance (which may point to a real repo)
and is responsible for disposing. In my opinion, the commands should not
implement IDisposable unless they are allocating further resources that are
needed to be cleaned up.

Cheers,
-- henon

Reply all
Reply to author
Forward
0 new messages