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 2022/11/07 05:18:31 UTC

[GitHub] [shardingsphere] zkongbai opened a new issue, #21985: DataSourceReflection findSetterMethod bug

zkongbai opened a new issue, #21985:
URL: https://github.com/apache/shardingsphere/issues/21985

   org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection#findSetterMethod(java.lang.String)
   the code like this: 
   private Optional<Method> findSetterMethod(final String fieldName) {
           String setterMethodName = SETTER_PREFIX + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, fieldName);
           return Arrays.stream(dataSourceMethods).filter(each -> each.getName().equals(setterMethodName) && 1 == each.getParameterTypes().length).findFirst();
       }
   
   when i use durid at 1.2.9, the code preview will product a bug. because the method is not the only one.
   so it can be change like this?
       private Optional<Method> findSetterMethod(final String fieldName, final Object fieldValue) {
           String setterMethodName = SETTER_PREFIX + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, fieldName);
           Stream<Method> methodStream = Arrays.stream(dataSourceMethods).filter(each -> each.getName().equals(setterMethodName) && 1 == each.getParameterTypes().length);
           //TODO: By -> 改造set方法有多个的时候,会报错问题.比如: setDBType (at druid 1.2.9)
           return methodStream.filter(m->m.getParameterTypes()[0].equals(fieldValue.getClass())).findFirst();
       }


-- 
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] RaigorJiang commented on issue #21985: DataSourceReflection findSetterMethod bug

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

   Hi @zkongbai 
   Can markdown be used to organize your code? The text you provided is difficult to read.
   Also, please use the issue template to provide more information, such as the version of ShardingSphere.


-- 
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] sandynz closed issue #21985: DataSourceReflection findSetterMethod bug

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


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