Skip to content

Fix for issue #317 #323

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

Merged
merged 5 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.version>5.1.9.RELEASE</spring.version>
<spring.version>5.1.13.RELEASE</spring.version>
<junit.version>4.12</junit.version>
<log4j.version>2.8.2</log4j.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<version>2.1.12.RELEASE</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion samples/micronaut/pet-store/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
4 changes: 2 additions & 2 deletions samples/spring/pet-store/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions samples/springboot2/pet-store/build.gradle
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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,)',
Expand Down
2 changes: 1 addition & 1 deletion samples/springboot2/pet-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<version>2.1.12.RELEASE</version>
</parent>

<properties>
Expand Down