Skip to content

Request parts not found when using Spring Framework 5.3 without nio-multipart-parser #703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrej-urvantsev opened this issue Nov 13, 2020 · 1 comment
Labels
Milestone

Comments

@andrej-urvantsev
Copy link

After upgrading Spring Boot to 2.4.0 my tests started to fail:

Request parts with the following names were not found in the request: [data, media]
org.springframework.restdocs.snippet.SnippetException: Request parts with the following names were not found in the request: [data, media]
	at org.springframework.restdocs.request.RequestPartsSnippet.verificationFailed(RequestPartsSnippet.java:189)
	at org.springframework.restdocs.request.RequestPartsSnippet.verifyRequestPartDescriptors(RequestPartsSnippet.java:165)

Reason is this code in org.springframework.restdocs.webtestclient.WebTestClientRequestConverter:

	private List<OperationRequestPart> extractRequestParts(ExchangeResult result) {
		if (!ClassUtils.isPresent("org.synchronoss.cloud.nio.multipart.NioMultipartParserListener",
				getClass().getClassLoader())) {
			return Collections.emptyList();
		}
		return new MultipartHttpMessageReader(new SynchronossPartHttpMessageReader())
				.readMono(ResolvableType.forClass(Part.class), new ExchangeResultReactiveHttpInputMessage(result),
						Collections.emptyMap())
				.onErrorReturn(new LinkedMultiValueMap<>()).block().values().stream()
				.flatMap((parts) -> parts.stream().map(this::createOperationRequestPart)).collect(Collectors.toList());
	}

Spring Boot 2.4.0 does not depend on org.synchronoss.cloud:nio-multipart-parser anymore, so method always returns empty list.

As a workaround this dependency should be added explicitly to the project:

testImplementation("org.synchronoss.cloud:nio-multipart-parser:1.1.0")
@wilkinsona
Copy link
Member

Thanks for the report. We have compatibility tests for Spring Framework 5.3 but they didn't catch this as the tests always have nio-multipart-parser on the classpath. We'll need to make use of Framework 5.3's built-in parser when it's available.

@wilkinsona wilkinsona added type: bug A bug and removed status: waiting-for-triage Untriaged issue labels Nov 13, 2020
@wilkinsona wilkinsona added this to the 2.0.6.RELEASE milestone Nov 13, 2020
@wilkinsona wilkinsona changed the title Request parts not found in Spring Boot 2.4.0 project Request parts not found when using Spring Framework 5.3 without nio-multipart-parser Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants