You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "hua74ni (via GitHub)" <gi...@apache.org> on 2023/06/02 06:11:21 UTC

[GitHub] [shardingsphere] hua74ni commented on pull request #26007: Fixed the reloadRules method that caused ruleMetaData.getRules() to be null briefly

hua74ni commented on PR #26007:
URL: https://github.com/apache/shardingsphere/pull/26007#issuecomment-1573207264

   Test cases
   
   ```
   @Test
   public void assertTest() throws InterruptedException {
   
       ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(new ShardingSphereRuleFixture()));
   
       Thread thread = new Thread(new Runnable() {
           @Override
           public void run() {
               System.out.println("start cycle get ruleMetaData rules...");
               while (true) {
                   if (CollectionUtils.isEmpty(ruleMetaData.getRules())) {
                       System.out.println("ruleMetaData rules is null!!!!");
                   }
               }
           }
       });
       thread.setDaemon(true);
       thread.start();
   
       Thread.sleep(1000);
   
       boolean flag = false;
       System.out.println("start replace all ruleMetaData rules...");
       if (flag) {
           ((CopyOnWriteArrayList) ruleMetaData.getRules()).replaceAll(shardingSphereRule -> {
               return new ShardingSphereRuleFixture();
           });
       } else {
           ShardingSphereRuleMetaData newRuleMetaData = new ShardingSphereRuleMetaData(Collections.singleton(new ShardingSphereRuleFixture()));
           ruleMetaData.getRules().clear();
           ruleMetaData.getRules().addAll(newRuleMetaData.getRules());
       }
   
       System.out.println("finished replace all ruleMetaData rules...");
   
       Thread.sleep(3000);
   }
   ```


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