Aman-Mittal commented on code in PR #6069:
URL: https://github.com/apache/fineract/pull/6069#discussion_r3637793113


##########
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:
   maybe something like this be more maintainable
   
   private static final List<String> ALLOWED_SUBTYPE_PACKAGES = List.of(
           "java.util.",
           "java.sql.",
           "java.lang.",
           "java.math.",
           "java.time.",
           "java.net.",
           "java.xml.",
           "org.springframework.batch.",
           "org.apache.fineract."
   );
   
   private static PolymorphicTypeValidator createTypeValidator() {
       var builder = BasicPolymorphicTypeValidator.builder();
       ALLOWED_SUBTYPE_PACKAGES.forEach(builder::allowIfSubType);
       return builder.build();
   }
   
   Consider extracting the construction of the PolymorphicTypeValidator into a 
private helper method backed by a static final List<String> of allowed package 
prefixes. This keeps the @Bean method focused on configuration while making the 
allowlist easier to maintain.



##########
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:
   Why is this required exitCode=%s;exitDescription=%s;exitException=null?



-- 
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]

Reply via email to