Ported from Spring 3.0.6 to 3.1.0