Skip to content

Commit a3d8acb

Browse files
Close conn if it is open, regardless of exception.
1 parent 9c484f8 commit a3d8acb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

neo-cli/Shell/MainService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ private static void WriteToPsql(SmartContractEvent contractEvent)
10871087
try
10881088
{
10891089
conn.Open();
1090-
Console.WriteLine(String.Format("Connection state={0}", conn.State));
1090+
Console.WriteLine(String.Format("Connection {0}", conn.State));
10911091

10921092
WriteToEventTable(contractEvent, conn);
10931093

@@ -1100,18 +1100,18 @@ private static void WriteToPsql(SmartContractEvent contractEvent)
11001100
{
11011101
WriteToTradeTable(contractEvent, conn);
11021102
}
1103-
1104-
conn.Close();
1105-
Console.WriteLine(String.Format("Connection state={0}", conn.State));
11061103
}
11071104
catch (Exception ex)
1105+
{
1106+
throw ex;
1107+
}
1108+
finally
11081109
{
11091110
if (conn != null && conn.State == System.Data.ConnectionState.Open)
11101111
{
1111-
Console.WriteLine(String.Format("Connection state={0}", conn.State));
11121112
conn.Close();
1113+
Console.WriteLine(String.Format("Connection {0}", conn.State));
11131114
}
1114-
throw ex;
11151115
}
11161116
}
11171117

0 commit comments

Comments
 (0)