Violation of IDbConnection contract: NpgsqlConnection.State throws ObjectDisposedException

90 views
Skip to first unread message

Oskar Berggren

unread,
Feb 20, 2014, 11:55:57 AM2/20/14
to npgsq...@googlegroups.com
Hi,


A user reported to NHibernate (https://nhibernate.jira.com/browse/NH-3598) that after an upgrade of npgsql, the NHibernate unit tests fail because npgsql now throws ObjectDisposedException if the NpgsqlConnection.State property is access after the object is disposed. Older versions of npgsql, as well as several other ado.net providers do not exhibit this behavior.

The NHibernate unit tests access this property to do sanity checking (i.e. verify that all connections was properly closed).

From the documentation of IDbConnection.State Property we read that the state goes from Open to Closed in response to either the Close() or Dispose() method being called on the connection. This implies that getting the value of the State property is valid even for a disposed object.

http://msdn.microsoft.com/en-us/library/system.data.idbconnection.state%28v=vs.110%29.aspx

This looks like a bug in npgsql.

/Oskar

Francisco Figueiredo Jr.

unread,
Feb 21, 2014, 11:47:08 AM2/21/14
to npgsq...@googlegroups.com


Hi, Oskar!

This bug is already fixed in our master branch: https://github.com/npgsql/Npgsql/pull/164 

Please give it  a try and let me know if it works ok for you.

Thanks for the heads up!
Reply all
Reply to author
Forward
0 new messages