From e3edb4a3e9a869a4c86e5e41462082016bd75ea2 Mon Sep 17 00:00:00 2001 From: nilansh Date: Wed, 14 Aug 2024 10:57:32 +0530 Subject: [PATCH 1/2] replace gson usage with jackson --- .../ce/ActionExecutionSolutionCEImpl.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java index 5f62d3371745..170649a541e1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java @@ -53,7 +53,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; import io.micrometer.observation.ObservationRegistry; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.ArrayUtils; @@ -771,6 +770,19 @@ protected Function> executionExce }; } + ActionConfiguration deepCopyActionConfiguration(ActionConfiguration actionConfiguration) { + try { + // Convert the ActionConfiguration object to JSON string + String json = objectMapper.writeValueAsString(actionConfiguration); + + // Convert the JSON string back to an ActionConfiguration object + return objectMapper.readValue(json, ActionConfiguration.class); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return null; + } + /** * Handles the execution logic, call to pluginExecutor with the payload post retrieval and validation of action, datasource, and plugin * @@ -799,9 +811,7 @@ protected Mono getActionExecutionResult( ActionConfiguration rawActionConfiguration = null; if (actionDTO != null && actionDTO.getActionConfiguration() != null) { // deep copying the actionConfiguration to avoid any changes in the original object - Gson gson = commonConfig.gsonInstance(); - rawActionConfiguration = gson.fromJson( - gson.toJson(actionDTO.getActionConfiguration()), ActionConfiguration.class); + rawActionConfiguration = deepCopyActionConfiguration(actionDTO.getActionConfiguration()); } log.debug( From 599506d23bba3233e86288fa6dcded27d448a2bb Mon Sep 17 00:00:00 2001 From: nilansh Date: Thu, 15 Aug 2024 00:49:55 +0530 Subject: [PATCH 2/2] added comment --- .../solutions/ce/ActionExecutionSolutionCEImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java index 170649a541e1..738f4a14a223 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java @@ -770,7 +770,13 @@ protected Function> executionExce }; } - ActionConfiguration deepCopyActionConfiguration(ActionConfiguration actionConfiguration) { + /** + * This function deep copies the actionConfiguration object to send the original object to mixpanel which contains + * the actual user query with bindings + * @param actionConfiguration + * @return + */ + private ActionConfiguration deepCopyActionConfiguration(ActionConfiguration actionConfiguration) { try { // Convert the ActionConfiguration object to JSON string String json = objectMapper.writeValueAsString(actionConfiguration); @@ -811,7 +817,7 @@ protected Mono getActionExecutionResult( ActionConfiguration rawActionConfiguration = null; if (actionDTO != null && actionDTO.getActionConfiguration() != null) { // deep copying the actionConfiguration to avoid any changes in the original object - rawActionConfiguration = deepCopyActionConfiguration(actionDTO.getActionConfiguration()); + rawActionConfiguration = this.deepCopyActionConfiguration(actionDTO.getActionConfiguration()); } log.debug(