fix: Add support for jackson with java time modules (#28347)

## Description
Add support for java Instant new Java8 Date API datatype modules in
Jackson.

#### PR fixes following issue(s)
Fixes https://github.com/appsmithorg/appsmith/issues/28350

#### Type of change
- Bug fix (non-breaking change which fixes an issue)

## Testing
#### How Has This Been Tested?
- [ ] Manual
- [ ] JUnit

## Checklist:
#### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
This commit is contained in:
Anagh Hegde 2023-10-25 19:09:18 +05:30 committed by GitHub
parent 269075164e
commit ecf0b9bd2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import com.appsmith.server.imports.internal.ImportApplicationService;
import com.appsmith.server.services.ce.ApplicationTemplateServiceCEImpl; import com.appsmith.server.services.ce.ApplicationTemplateServiceCEImpl;
import com.appsmith.server.solutions.ApplicationPermission; import com.appsmith.server.solutions.ApplicationPermission;
import com.appsmith.server.solutions.ReleaseNotesService; import com.appsmith.server.solutions.ReleaseNotesService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -24,7 +25,8 @@ public class ApplicationTemplateServiceImpl extends ApplicationTemplateServiceCE
UserDataService userDataService, UserDataService userDataService,
ApplicationService applicationService, ApplicationService applicationService,
ResponseUtils responseUtils, ResponseUtils responseUtils,
ApplicationPermission applicationPermission) { ApplicationPermission applicationPermission,
ObjectMapper objectMapper) {
super( super(
cloudServicesConfig, cloudServicesConfig,
releaseNotesService, releaseNotesService,
@ -34,6 +36,7 @@ public class ApplicationTemplateServiceImpl extends ApplicationTemplateServiceCE
userDataService, userDataService,
applicationService, applicationService,
responseUtils, responseUtils,
applicationPermission); applicationPermission,
objectMapper);
} }
} }

View File

@ -56,6 +56,8 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ
private final ResponseUtils responseUtils; private final ResponseUtils responseUtils;
private final ApplicationPermission applicationPermission; private final ApplicationPermission applicationPermission;
private final ObjectMapper objectMapper;
public ApplicationTemplateServiceCEImpl( public ApplicationTemplateServiceCEImpl(
CloudServicesConfig cloudServicesConfig, CloudServicesConfig cloudServicesConfig,
ReleaseNotesService releaseNotesService, ReleaseNotesService releaseNotesService,
@ -65,7 +67,8 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ
UserDataService userDataService, UserDataService userDataService,
ApplicationService applicationService, ApplicationService applicationService,
ResponseUtils responseUtils, ResponseUtils responseUtils,
ApplicationPermission applicationPermission) { ApplicationPermission applicationPermission,
ObjectMapper objectMapper) {
this.cloudServicesConfig = cloudServicesConfig; this.cloudServicesConfig = cloudServicesConfig;
this.releaseNotesService = releaseNotesService; this.releaseNotesService = releaseNotesService;
this.importApplicationService = importApplicationService; this.importApplicationService = importApplicationService;
@ -75,6 +78,7 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ
this.applicationService = applicationService; this.applicationService = applicationService;
this.responseUtils = responseUtils; this.responseUtils = responseUtils;
this.applicationPermission = applicationPermission; this.applicationPermission = applicationPermission;
this.objectMapper = objectMapper;
} }
@Override @Override
@ -337,7 +341,7 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ
String authHeader = "Authorization"; String authHeader = "Authorization";
String payload; String payload;
try { try {
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); ObjectWriter ow = objectMapper.writer().withDefaultPrettyPrinter();
payload = ow.writeValueAsString(communityTemplate); payload = ow.writeValueAsString(communityTemplate);
} catch (Exception e) { } catch (Exception e) {
return Mono.error(e); return Mono.error(e);

View File

@ -95,7 +95,8 @@ public class ApplicationTemplateServiceUnitTest {
userDataService, userDataService,
applicationService, applicationService,
responseUtils, responseUtils,
applicationPermission); applicationPermission,
objectMapper);
} }
private ApplicationTemplate create(String id, String title) { private ApplicationTemplate create(String id, String title) {