Permalink
Browse files

added some disposed exceptions to the connection. hopefully this will…

… help diagnose if his problem occurs in the future. issue #40
  • Loading branch information...
1 parent a6ba523 commit 38b124372bcc0e8df6e9f703704a89e8137ca9a3 @nberardi nberardi committed Jun 20, 2012
Showing with 18 additions and 1 deletion.
  1. +18 −1 src/Connections/Connection.cs
@@ -96,6 +96,8 @@ public bool IsOpen
/// </summary>
public void Open()
{
+ CheckWasDisposed();
+
if (IsOpen)
return;
@@ -108,6 +110,8 @@ public void Open()
/// </summary>
public void Close()
{
+ CheckWasDisposed();
+
if (!IsOpen)
return;
@@ -138,7 +142,11 @@ public void SetCqlVersion(string cqlVersion)
/// </summary>
public Cassandra.Client Client
{
- get { return _client; }
+ get
+ {
+ CheckWasDisposed();
+ return _client;
+ }
}
/// <summary>
@@ -154,6 +162,15 @@ public override string ToString()
/// <summary>
///
/// </summary>
+ private void CheckWasDisposed()
+ {
+ if (WasDisposed)
+ throw new ObjectDisposedException("connection has been disposed of");
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
public bool WasDisposed
{
get;

3 comments on commit 38b1243

Doesn't compile. _transport, _protocol and _client now must be non-readonly.

Contributor

Sorry, thought after you closed an issue there is no need for that. Added comment with description.

Please sign in to comment.