Skip to content

Misleading exception message for invalid MethodParameter instance [SPR-14466] #19035

@spring-projects-issues

Description

@spring-projects-issues

Oliver Drotbohm opened SPR-14466 and commented

public class MethodParameterTests {

	@Test
	public void testname() throws Exception {
		new MethodParameter(MethodParameterTests.class.getMethod("testname"), 0);
	}
}

On Spring 5.0 snapshots, the code above results in an exception with the following message:

Parameter index needs to be between 0 and -1

This is misleading as 0 was indeed passed into the constructor. However, throwing exception is perfectly fine, but only -1 is a valid value as the method doesn't take any parameters in the first place.


Affects: 5.0 M1

Referenced from: commits e2c7653

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions