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

View File

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

View File

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