GH-188 Ensured default ObjectMapper is created (AWS)

Ensured that the default instance of ObjectMapper is created in the event ObjectMapper configuration is missing (i.e., JacksonAutoConfiguration) in AWS adapter
Resolves #188
This commit is contained in:
Oleg Zhurakousky
2018-07-11 15:42:58 +02:00
parent 1839635267
commit 20f02c94c2
2 changed files with 35 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-1018 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.
@@ -28,18 +28,18 @@ import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.reactivestreams.Publisher;
import org.springframework.beans.factory.annotation.Autowired;
import reactor.core.publisher.Flux;
/**
* @author Dave Syer
* @author Oleg Zhurakousky
*/
public class SpringBootStreamHandler extends SpringFunctionInitializer
implements RequestStreamHandler {
@Autowired
@Autowired(required=false)
private ObjectMapper mapper;
public SpringBootStreamHandler() {
@@ -50,6 +50,14 @@ public class SpringBootStreamHandler extends SpringFunctionInitializer
super(configurationClass);
}
@Override
protected void initialize() {
super.initialize();
if (this.mapper == null) {
this.mapper = new ObjectMapper();
}
}
@Override
public void handleRequest(InputStream input, OutputStream output, Context context)
throws IOException {