Skip to content

Commit

Permalink
Fix null reference issue in Database Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
gfs committed Oct 7, 2019
2 parents 4215dcc + 2ddc801 commit a6782cc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Lib/Utils/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,12 @@ public static void Commit()
if (_transaction != null)
{
_transaction.Commit();
_transaction = null;
}
}
catch (Exception)
{
Log.Debug("Commit collision");
Log.Information("Failed to commit data to database.");
}

_transaction = null;
}

Expand Down Expand Up @@ -399,7 +397,14 @@ public static string SqliteFilename
public static void CloseDatabase()
{
Commit();
Connection.Close();
try
{
Connection.Close();
}
catch (NullReferenceException)
{
// That's fine. We want Connection to be null.
}
Connection = null;
}

Expand Down Expand Up @@ -428,6 +433,10 @@ public static void WriteNext()
{
Log.Debug($"Error writing {objIn.ColObj.Identity} to database.");
}
catch (NullReferenceException)
{
Log.Debug($"Was this a valid WriteObject. It looked null. {JsonConvert.SerializeObject(objIn)}");
}
}

public static List<RawCollectResult> GetMissingFromFirst(string firstRunId, string secondRunId)
Expand Down

0 comments on commit a6782cc

Please sign in to comment.