diff --git a/build.gradle b/build.gradle index d40731cc..7ce90aab 100644 --- a/build.gradle +++ b/build.gradle @@ -39,8 +39,8 @@ subprojects { subproject -> subproject.apply plugin: "io.spring.javaformat" subproject.apply plugin: "checkstyle" - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + sourceCompatibility = 17 + targetCompatibility = 17 configurations { internal { diff --git a/ci/images/ci-image/Dockerfile b/ci/images/ci-image/Dockerfile index a73b78fc..4e675734 100644 --- a/ci/images/ci-image/Dockerfile +++ b/ci/images/ci-image/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:focal-20210401 ADD setup.sh /setup.sh ADD get-jdk-url.sh /get-jdk-url.sh -RUN ./setup.sh java8 +RUN ./setup.sh java17 ENV JAVA_HOME /opt/openjdk ENV PATH $JAVA_HOME/bin:$PATH diff --git a/ci/images/get-jdk-url.sh b/ci/images/get-jdk-url.sh index 14469df1..a3babd3a 100755 --- a/ci/images/get-jdk-url.sh +++ b/ci/images/get-jdk-url.sh @@ -2,8 +2,8 @@ set -e case "$1" in - java8) - echo "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz" + java17) + echo "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17%2B35/OpenJDK17-jdk_x64_linux_hotspot_17_35.tar.gz" ;; *) echo $"Unknown java version" diff --git a/docs/src/docs/asciidoc/getting-started.adoc b/docs/src/docs/asciidoc/getting-started.adoc index 9e39dce2..8227b94e 100644 --- a/docs/src/docs/asciidoc/getting-started.adoc +++ b/docs/src/docs/asciidoc/getting-started.adoc @@ -76,7 +76,7 @@ If you want to jump straight in, a number of sample applications are available: Spring REST Docs has the following minimum requirements: -* Java 8 +* Java 17 * Spring Framework 5 (5.0.2 or later) Additionally, the `spring-restdocs-restassured` module requires REST Assured 4 (4.4 or later). diff --git a/samples/junit5/build.gradle b/samples/junit5/build.gradle index edce9ca1..cb3c7044 100644 --- a/samples/junit5/build.gradle +++ b/samples/junit5/build.gradle @@ -16,8 +16,8 @@ repositories { group = 'com.example' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 ext { snippetsDir = file('build/generated-snippets') diff --git a/samples/rest-assured/build.gradle b/samples/rest-assured/build.gradle index a2afef45..f7237456 100644 --- a/samples/rest-assured/build.gradle +++ b/samples/rest-assured/build.gradle @@ -16,8 +16,8 @@ repositories { group = 'com.example' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 ext { snippetsDir = file('build/generated-snippets') diff --git a/samples/rest-notes-slate/build.gradle b/samples/rest-notes-slate/build.gradle index 96953f3a..7b7648c1 100644 --- a/samples/rest-notes-slate/build.gradle +++ b/samples/rest-notes-slate/build.gradle @@ -15,8 +15,8 @@ repositories { group = 'com.example' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 ext { snippetsDir = file('build/generated-snippets') diff --git a/samples/rest-notes-spring-data-rest/pom.xml b/samples/rest-notes-spring-data-rest/pom.xml index 71d008cd..67d13cff 100644 --- a/samples/rest-notes-spring-data-rest/pom.xml +++ b/samples/rest-notes-spring-data-rest/pom.xml @@ -17,7 +17,7 @@ UTF-8 - 1.8 + 17 3.0.0-SNAPSHOT diff --git a/samples/rest-notes-spring-hateoas/build.gradle b/samples/rest-notes-spring-hateoas/build.gradle index 1cb6e7fd..52fb3093 100644 --- a/samples/rest-notes-spring-hateoas/build.gradle +++ b/samples/rest-notes-spring-hateoas/build.gradle @@ -16,8 +16,8 @@ repositories { group = 'com.example' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 ext { snippetsDir = file('build/generated-snippets') diff --git a/samples/testng/build.gradle b/samples/testng/build.gradle index 1b981581..5fd0cc4c 100644 --- a/samples/testng/build.gradle +++ b/samples/testng/build.gradle @@ -16,8 +16,8 @@ repositories { group = 'com.example' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 ext { snippetsDir = file('build/generated-snippets') diff --git a/samples/web-test-client/build.gradle b/samples/web-test-client/build.gradle index 27cbc93b..a4dcddd7 100644 --- a/samples/web-test-client/build.gradle +++ b/samples/web-test-client/build.gradle @@ -14,8 +14,8 @@ repositories { group = 'com.example' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 ext { snippetsDir = file('build/generated-snippets') diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java index 2768451b..dd658ce1 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationResponseFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2021 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. @@ -41,6 +41,15 @@ public class OperationResponseFactory { return this.create(status.value(), headers, content); } + /** + * Creates a new {@link OperationResponse}. If the response has any content, the given + * {@code headers} will be augmented to ensure that they include a + * {@code Content-Length} header. + * @param status the status of the response + * @param headers the request's headers + * @param content the content of the request + * @return the {@code OperationResponse} + */ public OperationResponse create(int status, HttpHeaders headers, byte[] content) { return new StandardOperationResponse(status, augmentHeaders(headers, content), content); } diff --git a/spring-restdocs-webtestclient/src/main/java/org/springframework/restdocs/webtestclient/WebTestClientRequestConverter.java b/spring-restdocs-webtestclient/src/main/java/org/springframework/restdocs/webtestclient/WebTestClientRequestConverter.java index fb5be55f..84bf6370 100644 --- a/spring-restdocs-webtestclient/src/main/java/org/springframework/restdocs/webtestclient/WebTestClientRequestConverter.java +++ b/spring-restdocs-webtestclient/src/main/java/org/springframework/restdocs/webtestclient/WebTestClientRequestConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2021 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. @@ -110,7 +110,8 @@ class WebTestClientRequestConverter implements RequestConverter if (ClassUtils.isPresent(DEFAULT_PART_HTTP_MESSAGE_READER, getClass().getClassLoader())) { try { return (HttpMessageReader) Class - .forName(DEFAULT_PART_HTTP_MESSAGE_READER, true, getClass().getClassLoader()).newInstance(); + .forName(DEFAULT_PART_HTTP_MESSAGE_READER, true, getClass().getClassLoader()) + .getDeclaredConstructor().newInstance(); } catch (Exception ex) { // Continue