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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user