-
Notifications
You must be signed in to change notification settings - Fork 615
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
Accepting and configuring JSON in a HTTP-triggered GCP function doesn't work #1083
Comments
Without seeing a full stack trace or example that reproduces the issue there is nothing to go by |
Hi, Please see a reproduction here: I'm using the following HTTP call (in the Intellij .http file format):
When you clone the repo, GSON stacktrace
|
Hi @olegz , is this enough for you to go on? |
…nd manually serializing to JSON using Jackson. spring-cloud/spring-cloud-function#1083
@mijgame I've been able to locate the source of this bug: The value of property Line 185 in a731b93
However, it will always have the value Lines 89 to 91 in a731b93
The reason for that is the property's key is only searched for in the system environment, where you would usually set it using an environment variable called So it doesn't matter whether you already have set the property using Spring's usual configuration options, the only way you can currently achieve using Jackson is to set the environment variable A fix for this would be highly appreciated 🙂 |
Describe the bug
I'm trying to develop a HTTP-triggered serverless function that accepts a relatively simple HTTP POST request with a JSON payload. I'm having trouble configuring and working with the JSON mappers. I feel like I'm both running into a bug and missing something; it would be great if you could provide some insights. I'm using version
4.0.5
.Sample
I want to receive this HTTP request:
And deserialize it into the following class:
As you can see I'm using
JsonProperty
here, which is a Jackson property. I've tried to useGson
(which seems to be the default) withSerializedName
. This does not work at all for some reason. It simply does not deserialize into these properties, leaving themnull
if the name in the request doesn't match the property name. Note I'm also providing theapplication/json
content-type header.Switching from GSON to Jackson does not work
According to the documentation, setting
spring.cloud.function.preferred-json-mapper
tojackson
in the application configuration (application.properties
in my case) should work. This does not seem to have any effect however. It is still using GSON. I've verified this by checking the value ofSystem.getProperty(ContextFunctionCatalogAutoConfiguration.JSON_MAPPER_PROPERTY)
. Other properties configured in theapplication.properties
file are picked up as expected. The only way I can instruct the system to use Jackson is by usingSystem.setProperty(ContextFunctionCatalogAutoConfiguration.JSON_MAPPER_PROPERTY, "jackson")
in theinit
method of the application class.Handler with Jackson configured doesn't work
I've defined the following handler:
With
gson
as the JSON-mapper, this code runs just fine (although Signal contains nulls as mentioned before). When usingjackson
, calling the handler fails with the following error:Please let me know if you need more information.
The text was updated successfully, but these errors were encountered: