diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 9116a5751..77e2da0b2 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -63,11 +63,11 @@ jobs: - name: Build latest run: ./gha_build.sh springboot2 true true - name: Build Spring Boot 2.0 - run: ./gha_build.sh springboot2 false false -Dspringboot.version=2.0.9.RELEASE -Dspring.version=5.0.13.RELEASE -Dspringsecurity.version=5.0.12.RELEASE + run: ./gha_build.sh springboot2 false false -Dspringboot.version=2.0.9.RELEASE -Dspring.version=5.0.16.RELEASE -Dspringsecurity.version=5.0.14.RELEASE - name: Build Spring Boot 2.1 - run: ./gha_build.sh springboot2 false false -Dspringboot.version=2.1.10.RELEASE -Dspring.version=5.1.11.RELEASE -Dspringsecurity.version=5.1.7.RELEASE + run: ./gha_build.sh springboot2 false false -Dspringboot.version=2.1.12.RELEASE -Dspring.version=5.1.13.RELEASE -Dspringsecurity.version=5.1.8.RELEASE - name: Build Spring Boot 2.2 - run: ./gha_build.sh springboot2 false false -Dspringboot.version=2.2.1.RELEASE -Dspring.version=5.2.1.RELEASE -Dspringsecurity.version=5.2.1.RELEASE + run: ./gha_build.sh springboot2 false false -Dspringboot.version=2.2.3.RELEASE -Dspring.version=5.2.3.RELEASE -Dspringsecurity.version=5.2.2.RELEASE build_struts2: name: Build and test Struts 2 diff --git a/aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsHttpServletResponse.java b/aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsHttpServletResponse.java index da695c509..153cdb91e 100644 --- a/aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsHttpServletResponse.java +++ b/aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsHttpServletResponse.java @@ -419,7 +419,13 @@ public void flushBuffer() throws IOException { if (null != writer) { writer.flush(); } - responseBody = new String(bodyOutputStream.toByteArray(), LambdaContainerHandler.getContainerConfig().getDefaultContentCharset()); + String charset = characterEncoding; + + if(charset == null) { + charset = LambdaContainerHandler.getContainerConfig().getDefaultContentCharset(); + } + + responseBody = new String(bodyOutputStream.toByteArray(), charset); log.debug("Response buffer flushed with {} bytes, latch={}", responseBody.length(), writersCountDownLatch.getCount()); isCommitted = true; writersCountDownLatch.countDown(); diff --git a/aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringAwsProxyTest.java b/aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringAwsProxyTest.java index b9cb728d6..ebd0f2fd3 100644 --- a/aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringAwsProxyTest.java +++ b/aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringAwsProxyTest.java @@ -45,6 +45,7 @@ public class SpringAwsProxyTest { private static final String CUSTOM_HEADER_KEY = "x-custom-header"; private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; private static final String AUTHORIZER_PRINCIPAL_ID = "test-principal-" + UUID.randomUUID().toString(); + private static final String UNICODE_VALUE = "שלום לכולם"; @Autowired private ObjectMapper objectMapper; @@ -249,6 +250,21 @@ public void responseBody_responseWriter_validBody() throws JsonProcessingExcepti validateSingleValueModel(output, CUSTOM_HEADER_VALUE); } + @Test + public void responseBody_responseWriter_validBody_UTF() throws JsonProcessingException { + SingleValueModel singleValueModel = new SingleValueModel(); + singleValueModel.setValue(UNICODE_VALUE); + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") + .header("Content-Type", "application/json; charset=UTF-8") + .body(objectMapper.writeValueAsString(singleValueModel)) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + assertNotNull(output.getBody()); + validateSingleValueModel(output, UNICODE_VALUE); + } + @Test public void statusCode_responseStatusCode_customStatusCode() { AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "GET") diff --git a/aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringBootAppTest.java b/aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringBootAppTest.java index d453dfe43..2e029e921 100644 --- a/aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringBootAppTest.java +++ b/aws-serverless-java-container-spring/src/test/java/com/amazonaws/serverless/proxy/spring/SpringBootAppTest.java @@ -160,6 +160,19 @@ public void utf8_returnUtf8String_expectCorrectHeaderMediaAndCharset() { assertTrue(output.getMultiValueHeaders().getFirst(HttpHeaders.CONTENT_TYPE).contains("charset=UTF-8")); } + @Test + public void utf8_returnUtf8String_expectCorrectHeaderMediaAndCharsetNoDefault() { + + AwsProxyRequest request = new AwsProxyRequestBuilder("/test/utf8", "GET") + .header("Content-Type", "application/json; charset=UTF-8") + .build(); + AwsProxyResponse output = handler.handleRequest(request, context); + validateSingleValueModel(output, TestController.UTF8_TEST_STRING); + assertTrue(output.getMultiValueHeaders().containsKey(HttpHeaders.CONTENT_TYPE)); + assertTrue(output.getMultiValueHeaders().getFirst(HttpHeaders.CONTENT_TYPE).contains(";")); + assertTrue(output.getMultiValueHeaders().getFirst(HttpHeaders.CONTENT_TYPE).contains("charset=UTF-8")); + } + private void validateSingleValueModel(AwsProxyResponse output, String value) { try { diff --git a/aws-serverless-spring-archetype/src/main/resources/archetype-resources/build.gradle b/aws-serverless-spring-archetype/src/main/resources/archetype-resources/build.gradle index e67eb52e4..6447fe4e8 100644 --- a/aws-serverless-spring-archetype/src/main/resources/archetype-resources/build.gradle +++ b/aws-serverless-spring-archetype/src/main/resources/archetype-resources/build.gradle @@ -7,8 +7,8 @@ repositories { dependencies { compile ( - 'org.springframework:spring-webmvc:5.1.9.RELEASE', - 'org.springframework:spring-context:5.1.9.RELEASE', + 'org.springframework:spring-webmvc:5.1.13.RELEASE', + 'org.springframework:spring-context:5.1.13.RELEASE', 'com.amazonaws.serverless:aws-serverless-java-container-spring:[1.0,)', 'org.apache.logging.log4j:log4j-core:2.8.2', 'org.apache.logging.log4j:log4j-api:2.8.2', diff --git a/aws-serverless-spring-archetype/src/main/resources/archetype-resources/pom.xml b/aws-serverless-spring-archetype/src/main/resources/archetype-resources/pom.xml index a6a574c8b..2f6d386d7 100644 --- a/aws-serverless-spring-archetype/src/main/resources/archetype-resources/pom.xml +++ b/aws-serverless-spring-archetype/src/main/resources/archetype-resources/pom.xml @@ -16,7 +16,7 @@ 1.8 1.8 - 5.1.9.RELEASE + 5.1.13.RELEASE 4.12 2.8.2 diff --git a/aws-serverless-springboot2-archetype/src/main/resources/archetype-resources/build.gradle b/aws-serverless-springboot2-archetype/src/main/resources/archetype-resources/build.gradle index e85ac40d8..9d9d17af1 100644 --- a/aws-serverless-springboot2-archetype/src/main/resources/archetype-resources/build.gradle +++ b/aws-serverless-springboot2-archetype/src/main/resources/archetype-resources/build.gradle @@ -11,7 +11,7 @@ repositories { dependencies { compile ( - 'org.springframework.boot:spring-boot-starter-web:2.1.8.RELEASE', + 'org.springframework.boot:spring-boot-starter-web:2.1.12.RELEASE', 'com.amazonaws.serverless:aws-serverless-java-container-springboot2:[1.0,)', 'io.symphonia:lambda-logging:1.0.1' ) diff --git a/aws-serverless-springboot2-archetype/src/main/resources/archetype-resources/pom.xml b/aws-serverless-springboot2-archetype/src/main/resources/archetype-resources/pom.xml index 3dfaa1235..8d1fc100c 100644 --- a/aws-serverless-springboot2-archetype/src/main/resources/archetype-resources/pom.xml +++ b/aws-serverless-springboot2-archetype/src/main/resources/archetype-resources/pom.xml @@ -16,7 +16,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.8.RELEASE + 2.1.12.RELEASE diff --git a/samples/micronaut/pet-store/build.gradle b/samples/micronaut/pet-store/build.gradle index 94f3d1b5f..8ed45b3d7 100644 --- a/samples/micronaut/pet-store/build.gradle +++ b/samples/micronaut/pet-store/build.gradle @@ -3,7 +3,7 @@ plugins { id "com.github.johnrengelman.shadow" version "5.0.0" id "application" id "net.ltgt.apt-eclipse" version "0.21" - id "org.springframework.boot" version "2.1.8.RELEASE" + id "org.springframework.boot" version "2.1.12.RELEASE" id "io.spring.dependency-management" version "1.0.6.RELEASE" } diff --git a/samples/spring/pet-store/build.gradle b/samples/spring/pet-store/build.gradle index 7d7a74c44..a8e815fbb 100644 --- a/samples/spring/pet-store/build.gradle +++ b/samples/spring/pet-store/build.gradle @@ -7,8 +7,8 @@ repositories { dependencies { compile ( - 'org.springframework:spring-webmvc:5.1.9.RELEASE', - 'org.springframework:spring-context:5.1.9.RELEASE', + 'org.springframework:spring-webmvc:5.1.13.RELEASE', + 'org.springframework:spring-context:5.1.13.RELEASE', 'com.amazonaws.serverless:aws-serverless-java-container-spring:[1.0,)', 'org.apache.logging.log4j:log4j-core:2.8.2', 'org.apache.logging.log4j:log4j-api:2.8.2', diff --git a/samples/springboot2/pet-store/build.gradle b/samples/springboot2/pet-store/build.gradle index 65826e900..fd4e81817 100644 --- a/samples/springboot2/pet-store/build.gradle +++ b/samples/springboot2/pet-store/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'org.springframework.boot' version '2.1.8.RELEASE' + id 'org.springframework.boot' version '2.1.12.RELEASE' } apply plugin: 'java' @@ -11,7 +11,7 @@ repositories { dependencies { compile ( - implementation('org.springframework.boot:spring-boot-starter-web:2.1.8.RELEASE') { + implementation('org.springframework.boot:spring-boot-starter-web:2.1.12.RELEASE') { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat' }, 'com.amazonaws.serverless:aws-serverless-java-container-springboot2:[1.0,)', diff --git a/samples/springboot2/pet-store/pom.xml b/samples/springboot2/pet-store/pom.xml index 547a7ead1..15bf3e671 100644 --- a/samples/springboot2/pet-store/pom.xml +++ b/samples/springboot2/pet-store/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.8.RELEASE + 2.1.12.RELEASE