Skip to content

Apply @SafeVarargs at MockRestRequestMatchers#header [SPR-14278] #18850

@spring-projects-issues

Description

@spring-projects-issues

Phillip Wirth opened SPR-14278 and commented

The Warning: Unchecked generics Array Creation for varags parameter in .andExpect(header("X-ClientVersion", equalTo("warnings_occurs_here"))) does not seem to be necessary.

Complete test method code:

	@Test
	public void testSomeMethod() {

		this.mockServer.expect(requestTo("http://somthing"))
				.andExpect(method(HttpMethod.POST))
				.andExpect(header("X-ClientName", "gotcha"))
				.andExpect(header("X-ClientVersion", equalTo("warnings_occurs_here")))
				.andExpect(content().string(isEmptyOrNullString()))
				.andRespond(withSuccess());
		this.someClient.someMethod(666, 888);
		this.mockServer.verify();
	}

I guess when @SafeVarargs would be applied to MockRestRequestMatchers#header everything would be fine.

@SafeVarargs exists since Java 7.

Spring Tests do have a targetCompatiblity to 1.8 so this should work too. (If I interpreted that correctly from settings.gradle.)


Affects: 4.3 RC2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions