-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
For some reason GSON is failing in get the GsonBuilder from the applicationContext, this causes the class to return a new GsonBuilder() without my custom Adapters. For example:
@Lazy
private GsonBuilder gsonBuilder = {
GsonBuilder gsonBuilder = applicationContext?.getBean('gsonBuilder', GsonBuilder)
if(gsonBuilder) {
println "**** Using applicationContext GsonBuilder"
} else {
println "**** Not found bean gsonBuilder"
gsonBuilder = new GsonBuilder()
}
return gsonBuilder
}()
In my case it prints "Not found bean gsonBuilder" and by consequence using render model as GSON fails to use my adapters.
The problem goes away if I explicity declare gsonBuilder in my controller and use render contentType: 'application/json', text: gson.toJson(model)
Maybe it's a problem with ApplicationContextAware? I can also see that applicationContext is null in GSON.
Metadata
Metadata
Assignees
Labels
No labels