Uploaded image for project: 'Spring Batch Admin'
  1. Spring Batch Admin
  2. BATCHADM-233

SimpleJobService.destroy() is never called on context shutdown


    Affects 1.3.1 and 2.0.0.M1.

    SimpleJobService is implementing DisposableBean interface, providing a destroy method, which tries to stop any active job executions in case of a context shutdown. This is a very useful feature, otherwise those active running job executions will be killed and remain as STARTED-zombies in the job repository.

    Unfortunately, the destroy() method is never called in case of context shutdown:

    • META-INF/spring/batch/bootstrap/manager/execution-context.xml is defining 'jobService' via SimpleJobServiceFactoryBean, so in case of context shutdown only the destroy() method of the factory bean would be called, and not for the bean instance(s) created by the factory bean.
    • This leads to second issue: Currently SimpleJobServiceFactoryBean does not implement interface 'DisposableBean' and therefore has no destroy() method...

    Expected behavior:
    In case of shutdown and configuration using SimpleJobServiceFactoryBean

    • destroy() method of SimpleJobServiceFactoryBean should be called.
    • destroy() method of (singleton) instance SimpleJobService - as provided by factory bean - should be called.

    Possible solutions/workarounds:

    1) As isSingleton() always returns "true" for the factory bean, change signature of factory bean class from

    SimpleJobServiceFactoryBean implements FactoryBean<JobService>, InitializingBean


    SimpleJobServiceFactoryBean extends AbstractFactoryBean<JobService>

    as AbstractFactoryBean already provides all the required code for singleton-handling and proper destroy() handling.

    2) add interface 'DispoableBean' to signature of SimpleJobServiceFactoryBean and add "missing" code (destroy() method, singleton caching).




          • Assignee:
            rmontag Rainer Montag
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: