SPRNET-961 - Exception handling advice throws NullReferenceException when using swallow action on methods that return value types

(introduced error when handling method with void return type
This commit is contained in:
markpollack
2008-06-14 12:28:37 +00:00
parent 41f41e3902
commit 24020e0f1b
2 changed files with 3 additions and 3 deletions

View File

@@ -185,7 +185,7 @@ namespace Spring.Aspects.Exceptions
else
{
Type returnType = invocation.Method.ReturnType;
return returnType.IsValueType ? Activator.CreateInstance(returnType) : null;
return returnType.IsValueType && !returnType.Equals(typeof(void))? Activator.CreateInstance(returnType) : null;
}
}
}

View File

@@ -309,9 +309,9 @@ namespace Spring.Aspects.Exceptions
try
{
to.Exceptional(new ArithmeticException("Bad Math"));
} catch (Exception)
} catch (Exception e)
{
Assert.Fail("Should not have thrown exception");
Assert.Fail("Should not have thrown exception" + e);
}
}