Bug in SimpleDataProtal

Bug in SimpleDataProtal

Old forum URL: forums.lhotka.net/forums/t/12778.aspx


Sander posted on Monday, October 20, 2014

I'm working with CSLA 4.5.601 and recently found out a bug in the Create of SimpleDataPortal. (I did something wrong but exception was hard to track because of this)

Exception was catched as expected to line 91:
catch (Exception ex) {
  ...
  throw 
DataPortal.NewDataPortalException(...

And after that run the finally:
finally{
    ApplicationContext
.DataPortalActivator.FinalizeInstance(obj.Instance);
}

But because obj was null exception was thrown from the finally block and the exception from the try/catch was 'lost'.

I've added a null check in the finally block which could prevent an issue like this in the future
finally{
  if (obj != null)
  ApplicationContext
.DataPortalActivator.FinalizeInstance(obj.Instance);
}

Would this be a nice fix?

Copyright (c) Marimer LLC