avivijay19 commented on code in PR #6069:
URL: https://github.com/apache/fineract/pull/6069#discussion_r3639955971
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/ScheduledJobRunnerConfig.java:
##########
@@ -20,26 +20,48 @@
import
org.apache.fineract.infrastructure.core.service.database.RoutingDataSource;
import
org.apache.fineract.infrastructure.jobs.config.FineractDataFieldMaxValueIncrementerFactory;
+import org.springframework.batch.core.configuration.JobRegistry;
import
org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
-import org.springframework.batch.core.explore.JobExplorer;
-import org.springframework.batch.core.explore.support.JobExplorerFactoryBean;
-import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher;
+import org.springframework.batch.core.configuration.support.MapJobRegistry;
import org.springframework.batch.core.repository.JobRepository;
-import
org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
-import
org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
-import
org.springframework.batch.item.database.support.DataFieldMaxValueIncrementerFactory;
+import
org.springframework.batch.core.repository.dao.JacksonExecutionContextStringSerializer;
+import
org.springframework.batch.core.repository.support.JdbcJobRepositoryFactoryBean;
+import
org.springframework.batch.infrastructure.item.database.support.DataFieldMaxValueIncrementerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
+import tools.jackson.databind.json.JsonMapper;
+import tools.jackson.databind.jsontype.BasicPolymorphicTypeValidator;
+import tools.jackson.databind.jsontype.PolymorphicTypeValidator;
@Configuration(proxyBeanMethods = false)
@EnableBatchProcessing
public class ScheduledJobRunnerConfig {
@Bean
- public Jackson2ExecutionContextStringSerializer
executionContextSerializer() {
- return new Jackson2ExecutionContextStringSerializer();
+ public JobRegistry jobRegistry() {
+ // @EnableBatchProcessing's registrar wires its jobOperator against
the bean named
+ // "jobRegistry" but does not define one itself
+ return new MapJobRegistry();
+ }
+
+ @Bean
+ public JacksonExecutionContextStringSerializer
executionContextSerializer() {
+ // mirrors the serializer's default type validator, extended with
Fineract types, because
+ // execution contexts carry e.g. the COB business-step set and
partition parameters
Review Comment:
Good call, done. I've pulled the allowlist out into a `static final
List<String> ALLOWED_EXECUTION_CONTEXT_SUBTYPES` and moved the builder wiring
into a small `executionContextTypeValidator()` helper, so the `@Bean` method
now just constructs the serializer. The set of prefixes and their order are
unchanged, so there's no behavioral difference, it's purely to keep the
allowlist in one readable place.
##########
fineract-provider/src/test/java/org/apache/fineract/infrastructure/jobs/service/JobStarterTest.java:
##########
@@ -138,16 +138,17 @@ public void runWithFailed() throws
JobInstanceAlreadyCompleteException, JobExecu
when(jobExecution.getExitStatus()).thenReturn(new
ExitStatus(failedStatus.name(), "testException"));
JobExecutionException exception =
Assertions.assertThrows(JobExecutionException.class,
() -> underTest.run(job, scheduledJobDetail, Set.of(),
"default"));
-
Assertions.assertEquals(String.format("exitCode=%s;exitDescription=%s",
failedStatus.name(), "testException"),
+ Assertions.assertEquals(
+
String.format("exitCode=%s;exitDescription=%s;exitException=null",
failedStatus.name(), "testException"),
Review Comment:
It comes from Spring Batch 6's `ExitStatus.toString()`, not from a change
here. `JobStarter` throws `new
JobExecutionException(result.getExitStatus().toString())`, and Batch 6 added a
`Throwable exitException` field to `ExitStatus`, so its `toString()` went from
`exitCode=%s;exitDescription=%s` to
`exitCode=%s;exitDescription=%s;exitException=%s`. The mocked status has no
exception, hence `exitException=null`. Happy to derive the expected string from
`exitStatus.toString()` instead of the literal if you'd prefer not to hardcode
the format.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]