You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/06/25 02:35:31 UTC

[GitHub] [shardingsphere] Erzhoumu opened a new issue #11008: 5.0.0-beta in class ShardingSphereAlgorithmBeanRegistry some spring bean would cause java.lang.NullPointerException

Erzhoumu opened a new issue #11008:
URL: https://github.com/apache/shardingsphere/issues/11008


   hi,  starting a spring-boot project, when parse the sharing:rule element
   The class ShardingSphereAlgorithmBeanRegistry in line 25
   `public static Map<String, RuntimeBeanReference> getAlgorithmBeanReferences(ParserContext parserContext, Class<? extends ShardingSphereAlgorithmFactoryBean<?>> algorithmFactoryBeanClass) {
           String[] beanDefinitionNames = parserContext.getRegistry().getBeanDefinitionNames();
           String algorithmFactoryBeanClassName = algorithmFactoryBeanClass.getName();
           Map<String, RuntimeBeanReference> result = new ManagedMap(beanDefinitionNames.length);
           String[] var5 = beanDefinitionNames;
           int var6 = beanDefinitionNames.length;
   
           for(int var7 = 0; var7 < var6; ++var7) {
               String each = var5[var7];
               if (parserContext.getRegistry().getBeanDefinition(each).getBeanClassName().equals(algorithmFactoryBeanClassName)) {
                   result.put(each, new RuntimeBeanReference(each));
               }
           }
   
           return result;
       }`
   
   The code may cause NullPointerException, when 'each' is  "org.springframework.context.annotation.internalAsyncAnnotationProcessor"  or "org.springframework.context.annotation.internalScheduledAnnotationProcessor" 
   `
     if (parserContext.getRegistry().getBeanDefinition(each).getBeanClassName().equals(algorithmFactoryBeanClassName)) {
                   result.put(each, new RuntimeBeanReference(each));
               }`
   I think foreach all beanDefinitionNames is not a good choice, and some lazy-init bean may cause exception.
   my spring-boot version is <version>2.1.1.RELEASE</version>


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

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



[GitHub] [shardingsphere] sandynz commented on issue #11008: 5.0.0-beta in class ShardingSphereAlgorithmBeanRegistry some spring bean would cause java.lang.NullPointerException

Posted by GitBox <gi...@apache.org>.
sandynz commented on issue #11008:
URL: https://github.com/apache/shardingsphere/issues/11008#issuecomment-965003975


   I checked on master branch code, it has been fixed by #11702. You could try version `5.0.0`.


-- 
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] tristaZero commented on issue #11008: 5.0.0-beta in class ShardingSphereAlgorithmBeanRegistry some spring bean would cause java.lang.NullPointerException

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #11008:
URL: https://github.com/apache/shardingsphere/issues/11008#issuecomment-868356133


   @Erzhoumu Thanks for your feedback.
   It looks like a bug?
   Would you like to raise a PR to improve it? FYI, [How to raise a PR](https://shardingsphere.apache.org/community/cn/contribute/contributor/).


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

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



[GitHub] [shardingsphere] sandynz closed issue #11008: 5.0.0-beta in class ShardingSphereAlgorithmBeanRegistry some spring bean would cause java.lang.NullPointerException

Posted by GitBox <gi...@apache.org>.
sandynz closed issue #11008:
URL: https://github.com/apache/shardingsphere/issues/11008


   


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