Remove hard dependency on Gson from FCF adapter in favor of SCF proivided configurable JsonMapper

This commit is contained in:
Oleg Zhurakousky
2020-04-21 14:48:14 +02:00
parent 8da506d8fe
commit cfe534660e
2 changed files with 5 additions and 5 deletions

View File

@@ -26,7 +26,6 @@ import com.google.cloud.functions.HttpFunction;
import com.google.cloud.functions.HttpRequest;
import com.google.cloud.functions.HttpResponse;
import com.google.cloud.functions.RawBackgroundFunction;
import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -53,8 +52,6 @@ public class FunctionInvoker extends AbstractSpringFunctionAdapterInitializer<Ht
private String functionName = "";
private static final Gson gson = new Gson();
public FunctionInvoker() {
super();
init();
@@ -124,7 +121,7 @@ public class FunctionInvoker extends AbstractSpringFunctionAdapterInitializer<Ht
// If the input type is not PubSubMessage, use the PubSubMessage.data field as
// payload, and put the full PubSubMessage and Context into message headers.
PubSubMessage pubSubMessage = gson.fromJson(json, PubSubMessage.class);
PubSubMessage pubSubMessage = this.jsonMapper.fromJson(json, PubSubMessage.class);
message = getInputType() == Void.class ? null : MessageBuilder.withPayload(pubSubMessage.getData())
.setHeader("gcf_context", context).setHeader("gcf_message", pubSubMessage).build();
@@ -139,7 +136,6 @@ public class FunctionInvoker extends AbstractSpringFunctionAdapterInitializer<Ht
if (result != null) {
log.info("Dropping background function result: " + new String(result.getPayload()));
}
}
}