From a60b87990b5e4535c07f3e34d7bd8bc930a52d33 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 15 Jun 2018 16:00:25 +0100 Subject: [PATCH] Tolerate changes to request body reading in Framework 5.1 Previously, MockHttpServletRequest allowed its body to be ready multiple times using its InputStream. As of recent Spring Framework 5.1 snapshots, this is no longer the case. This commit moves to directly accessing the request's content as a byte array using getContentAsByteArray() which was introduced in Framework 5.0. Closes gh-515 --- spring-restdocs-core/build.gradle | 7 +++++++ spring-restdocs-mockmvc/build.gradle | 7 +++++++ .../restdocs/mockmvc/MockMvcRequestConverter.java | 6 +++--- spring-restdocs-webtestclient/build.gradle | 7 +++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/spring-restdocs-core/build.gradle b/spring-restdocs-core/build.gradle index 9f0977ae..47aa151b 100644 --- a/spring-restdocs-core/build.gradle +++ b/spring-restdocs-core/build.gradle @@ -61,4 +61,11 @@ artifacts { test { jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*,excludes=org.springframework.restdocs.mustache.*" +} + +matrixTest { + springFramework { + group = 'org.springframework' + versions = ['5.1.0.BUILD-SNAPSHOT'] + } } \ No newline at end of file diff --git a/spring-restdocs-mockmvc/build.gradle b/spring-restdocs-mockmvc/build.gradle index 5baca9c2..49c0f19c 100644 --- a/spring-restdocs-mockmvc/build.gradle +++ b/spring-restdocs-mockmvc/build.gradle @@ -16,4 +16,11 @@ dependencies { test { jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*" +} + +matrixTest { + springFramework { + group = 'org.springframework' + versions = ['5.1.0.BUILD-SNAPSHOT'] + } } \ No newline at end of file diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverter.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverter.java index 45e0a9ba..bfaeaaff 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverter.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,8 +81,8 @@ class MockMvcRequestConverter implements RequestConverter