You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "gdut-yy (via GitHub)" <gi...@apache.org> on 2025/01/23 11:57:05 UTC

[I] `DataSourceReflection#setField()` will cause `IllegalArgumentException: argument type mismatch` when used with `commons-dbcp` >= 2.10.0 [shardingsphere]

gdut-yy opened a new issue, #34444:
URL: https://github.com/apache/shardingsphere/issues/34444

   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   
   5.1.x ~ 5.5.x
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ShardingSphere-JDBC
   
   ### Expected behavior
   
   Application run successful.
   
   ### Actual behavior
   
   Application run failed.
   
   ```
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: argument type mismatch
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:405) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:258) ~[spring-context-5.3.31.jar:5.3.31]
   	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:773) ~[spring-context-5.3.31.jar:5.3.31]
   	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:575) ~[spring-context-5.3.31.jar:5.3.31]
   	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.18.jar:2.7.18]
   	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) [spring-boot-2.7.18.jar:2.7.18]
   	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) [spring-boot-2.7.18.jar:2.7.18]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.7.18.jar:2.7.18]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) [spring-boot-2.7.18.jar:2.7.18]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) [spring-boot-2.7.18.jar:2.7.18]
   	at com.example.sdjdbc512.Sdjdbc512Application.main(Sdjdbc512Application.java:10) [classes/:na]
   Caused by: java.lang.IllegalArgumentException: argument type mismatch
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_322]
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_322]
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_322]
   	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_322]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection.setField(DataSourceReflection.java:144) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection.lambda$setField$0(DataSourceReflection.java:123) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at java.util.Optional.ifPresent(Optional.java:159) ~[na:1.8.0_322]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection.setField(DataSourceReflection.java:123) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator.setConfiguredFields(DataSourcePoolCreator.java:126) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator.create(DataSourcePoolCreator.java:79) ~[shardingsphere-infra-common-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.datasource.DataSourceMapSetter.getDataSource(DataSourceMapSetter.java:92) ~[shardingsphere-jdbc-spring-boot-starter-infra-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.datasource.DataSourceMapSetter.getDataSourceMap(DataSourceMapSetter.java:65) ~[shardingsphere-jdbc-spring-boot-starter-infra-5.1.2.jar:5.1.2]
   	at org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration.setEnvironment(ShardingSphereAutoConfiguration.java:122) ~[shardingsphere-jdbc-core-spring-boot-starter-5.1.2.jar:5.1.2]
   	at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:110) ~[spring-context-5.3.31.jar:5.3.31]
   	at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:102) ~[spring-context-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.3.31.jar:5.3.31]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.31.jar:5.3.31]
   	... 24 common frames omitted
   ```
   
   ### Reason analyze (If you can)
   
   `commons-dbcp` added overloaded method `org.apache.commons.dbcp2.BasicDataSource#setRemoveAbandonedTimeout(java.time.Duration)` since `2.10.0`.
   
   But `org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection#setField(java.lang.reflect.Method, java.lang.Object)` doesn't support `java.time.Duration` parameter of type,will cause `java.lang.IllegalArgumentException: argument type mismatch`.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   Startup the following sample code.
   
   ### Example codes for reproduce this issue (such as a github link).
   
   [code]()


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


Re: [I] `DataSourceReflection#setField()` will cause `IllegalArgumentException: argument type mismatch` when used with `commons-dbcp` >= 2.10.0 [shardingsphere]

Posted by "gdut-yy (via GitHub)" <gi...@apache.org>.
gdut-yy commented on issue #34444:
URL: https://github.com/apache/shardingsphere/issues/34444#issuecomment-2609830369

   @terrymanu Of course, it's easy to fix this problem by adding a judgment branch of `java.time.Duration` to `DataSourcePoolReflection#setField`
   
   But I don't think this will solve the problem fundamentally, it can't exhaust all scenarios, other parameter types of other DataSources may have similar problems, need to see if there is a more elegant design pattern?
   
   Or, should dbcp2 not have the input parameter type `java.time.Duration`?


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


Re: [I] `DataSourceReflection#setField()` will cause `IllegalArgumentException: argument type mismatch` when used with `commons-dbcp` >= 2.10.0 [shardingsphere]

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

   > But I don't think this will solve the problem fundamentally, it can't exhaust all scenarios, other parameter types of other DataSources may have similar problems, need to see if there is a more elegant design pattern?
    
   - I think there is nothing wrong with this. Even Arrow is a one-by-one adaptation, as shown in https://github.com/apache/arrow-java/pull/560 .
   - Feel free to open a PR.


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


Re: [I] `DataSourceReflection#setField()` will cause `IllegalArgumentException: argument type mismatch` when used with `commons-dbcp` >= 2.10.0 [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #34444: `DataSourceReflection#setField()` will cause `IllegalArgumentException: argument type mismatch` when used with `commons-dbcp` >= 2.10.0
URL: https://github.com/apache/shardingsphere/issues/34444


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


Re: [I] `DataSourceReflection#setField()` will cause `IllegalArgumentException: argument type mismatch` when used with `commons-dbcp` >= 2.10.0 [shardingsphere]

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

   Could you fix it?


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


Re: [I] `DataSourceReflection#setField()` will cause `IllegalArgumentException: argument type mismatch` when used with `commons-dbcp` >= 2.10.0 [shardingsphere]

Posted by "gdut-yy (via GitHub)" <gi...@apache.org>.
gdut-yy commented on issue #34444:
URL: https://github.com/apache/shardingsphere/issues/34444#issuecomment-2609739740

   ![Image](https://github.com/user-attachments/assets/44b1f23c-e4e6-4f1d-86c9-bf0c34cd1603)
   
   ![Image](https://github.com/user-attachments/assets/cdd88f9d-fb19-4ac0-8046-a9bb8ca2f239)


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