Skip to content

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

Closed
@andrej-urvantsev

Description

@andrej-urvantsev

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions