You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "azexcy (via GitHub)" <gi...@apache.org> on 2023/03/28 03:17:26 UTC

[GitHub] [shardingsphere-elasticjob] azexcy opened a new issue, #2200: CronSettingAndJobEventChangedJobListener will thrown NPE, when OneOffJobBootstrap execute shutdown

azexcy opened a new issue, #2200:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2200

   ## Bug Report
   
   1. After execute `OneOffJobBootstrap.shutdown`, the CronSettingAndJobEventChangedJobListener will 
   
   ```
    java.lang.NullPointerException: null
    	at org.apache.shardingsphere.elasticjob.lite.internal.config.RescheduleListenerManager$CronSettingAndJobEventChangedJobListener.onChange(RescheduleListenerManager.java:58)
    	at org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter.lambda$watch$3(ZookeeperRegistryCenter.java:424)
    	at org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$putStorage$5(CuratorCacheImpl.java:282)
    	at org.apache.curator.framework.listen.MappingListenerManager.lambda$forEach$0(MappingListenerManager.java:92)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:750)
   
   ```
   
   ### Which version of ElasticJob did you use?
   
   3.0.2
   
   ### Which project did you use? ElasticJob-Lite or ElasticJob-Cloud?
   
   ElasticJob-Lite
   
   ### Expected behavior
   
   
   
   ### Actual behavior
   
   ### Reason analyze (If you can)
   
   JobRegistry.shutdown will remove job schedule.
   
   ```
       /**
        * Shutdown job schedule.
        * 
        * @param jobName job name
        */
       public void shutdown(final String jobName) {
           Optional.ofNullable(schedulerMap.remove(jobName)).ifPresent(JobScheduleController::shutdown);
           Optional.ofNullable(regCenterMap.remove(jobName)).ifPresent(regCenter -> regCenter.evictCacheData("/" + jobName));
           ListenerNotifierManager.getInstance().removeJobNotifyExecutor(jobName);
           jobInstanceMap.remove(jobName);
           jobRunningMap.remove(jobName);
           currentShardingTotalCountMap.remove(jobName);
       }
   ```
   
   The `CronSettingAndJobEventChangedJobListener.onChange` may be concurrency problem, causes possible NPE problems
   ```
       class CronSettingAndJobEventChangedJobListener implements DataChangedEventListener {
           
           @Override
           public void onChange(final DataChangedEvent event) {
               if (configNode.isConfigPath(event.getKey()) && Type.UPDATED == event.getType() && !JobRegistry.getInstance().isShutdown(jobName)) {
                   JobConfiguration jobConfiguration = YamlEngine.unmarshal(event.getValue(), JobConfigurationPOJO.class).toJobConfiguration();
                   if (StringUtils.isEmpty(jobConfiguration.getCron())) {
                       JobRegistry.getInstance().getJobScheduleController(jobName).rescheduleJob();
                   } else {
                       JobRegistry.getInstance().getJobScheduleController(jobName).rescheduleJob(jobConfiguration.getCron(), jobConfiguration.getTimeZone());
                   }
               }
           }
       }
   ```
   
   ### Steps to reproduce the behavior.
   
   Test at local, debug, then execute OneOffJobBootstrap.shutdown
   <img width="1126" alt="image" src="https://user-images.githubusercontent.com/101622833/228118748-67a4b0ad-ceb7-4cf8-af47-d544ff15acc1.png">
   
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-elasticjob] TeslaCN closed issue #2200: CronSettingAndJobEventChangedJobListener will thrown NPE, when OneOffJobBootstrap execute shutdown

Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN closed issue #2200: CronSettingAndJobEventChangedJobListener will thrown NPE, when OneOffJobBootstrap execute shutdown
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2200


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-elasticjob] TeslaCN commented on issue #2200: CronSettingAndJobEventChangedJobListener will thrown NPE, when OneOffJobBootstrap execute shutdown

Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN commented on issue #2200:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2200#issuecomment-1722702604

   Close via https://github.com/apache/shardingsphere-elasticjob/pull/2211


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org