Skip to content

Commit

Permalink
Close conn if it is open, regardless of exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
SwitchyTheCoder committed Jul 9, 2018
1 parent 9c484f8 commit a3d8acb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions neo-cli/Shell/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ private static void WriteToPsql(SmartContractEvent contractEvent)
try
{
conn.Open();
Console.WriteLine(String.Format("Connection state={0}", conn.State));
Console.WriteLine(String.Format("Connection {0}", conn.State));

WriteToEventTable(contractEvent, conn);

Expand All @@ -1100,18 +1100,18 @@ private static void WriteToPsql(SmartContractEvent contractEvent)
{
WriteToTradeTable(contractEvent, conn);
}

conn.Close();
Console.WriteLine(String.Format("Connection state={0}", conn.State));
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (conn != null && conn.State == System.Data.ConnectionState.Open)
{
Console.WriteLine(String.Format("Connection state={0}", conn.State));
conn.Close();
Console.WriteLine(String.Format("Connection {0}", conn.State));
}
throw ex;
}
}

Expand Down

0 comments on commit a3d8acb

Please sign in to comment.