fix: replace default object mapper due to the serilisation of Json views (#28484)

This commit is contained in:
Anagh Hegde 2023-10-30 21:08:01 +05:30 committed by GitHub
parent 8643a5f284
commit 1983fbe174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,7 @@ import com.appsmith.server.solutions.ReleaseNotesService;
import com.appsmith.util.WebClientUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
@ -343,8 +344,13 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ
String authHeader = "Authorization";
String payload;
try {
ObjectWriter ow = objectMapper.writer().withDefaultPrettyPrinter();
payload = ow.writeValueAsString(communityTemplate);
// Please don't use the default ObjectMapper.
// The default mapper is registered with views.public.class and removes few attributes due to this
// The templates flow has different requirement hence not using the same
ObjectMapper ow = new ObjectMapper();
ow.registerModule(new JavaTimeModule());
ObjectWriter writer = ow.writer().withDefaultPrettyPrinter();
payload = writer.writeValueAsString(communityTemplate);
} catch (Exception e) {
return Mono.error(e);
}