From 29a4614529bbda02b9c690d2d1812be1d1e7bbae Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 4 Oct 2009 13:57:51 -0700 Subject: * MySQL data tests now pass by fixing a bad fix for a bad cast on the asset Local member in MySQLAssetData * First pass at applying the using(){} pattern to IDisposable objects. Always use the using pattern on IDisposable objects whenever possible, do not manually call .Close() or .Dispose() unless there is no other way to write the code. This pass mostly covers OpenSim.Data.MySQL, and should have no functional change (tests still pass) --- OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs | 15 +++------------ OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 2 -- OpenSim/Data/MSSQL/MSSQLManager.cs | 4 ---- OpenSim/Data/MSSQL/MSSQLMigration.cs | 1 - 4 files changed, 3 insertions(+), 19 deletions(-) (limited to 'OpenSim/Data/MSSQL') diff --git a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs index 93e48cd..0e21880 100644 --- a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs +++ b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs @@ -197,20 +197,11 @@ namespace OpenSim.Data.MSSQL public void Dispose() { SqlConnection conn = realCommand.Connection; - try - { - realCommand.Dispose(); - } + try { realCommand.Dispose(); } finally { - try - { - conn.Close(); - } - finally - { - conn.Dispose(); - } + try { conn.Dispose(); } + finally { } } } diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs index 1482184..d49c2b3 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs @@ -348,8 +348,6 @@ namespace OpenSim.Data.MSSQL //Delete the actual row DeleteOneFolder(folderID, connection); DeleteItemsInFolder(folderID, connection); - - connection.Close(); } } diff --git a/OpenSim/Data/MSSQL/MSSQLManager.cs b/OpenSim/Data/MSSQL/MSSQLManager.cs index 3d7a768..992ce02 100644 --- a/OpenSim/Data/MSSQL/MSSQLManager.cs +++ b/OpenSim/Data/MSSQL/MSSQLManager.cs @@ -340,8 +340,6 @@ namespace OpenSim.Data.MSSQL MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore); migration.Update(); - - connection.Close(); } } @@ -385,9 +383,7 @@ namespace OpenSim.Data.MSSQL m_log.Error(e.ToString()); } } - tables.Close(); } - } /// diff --git a/OpenSim/Data/MSSQL/MSSQLMigration.cs b/OpenSim/Data/MSSQL/MSSQLMigration.cs index aea31c9..549bcb3 100644 --- a/OpenSim/Data/MSSQL/MSSQLMigration.cs +++ b/OpenSim/Data/MSSQL/MSSQLMigration.cs @@ -56,7 +56,6 @@ namespace OpenSim.Data.MSSQL { version = Convert.ToInt32(reader["version"]); } - reader.Close(); } } catch -- cgit v1.1