shardingsphere: v5.2, If a druid datasource has some filters, then create a ShardingSphereDataSource will occur exception

Bug Report

Which version of ShardingSphere did you use?

v5.2.0

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

  1. Create a druid datasource, and then add some filters.
DruidDataSource druidDataSource = new DruidDataSource();
// ...
druidDataSource.setProxyFilters(buildFilters());
  1. Create a shardingsphere datasource by ShardingSphereDataSourceFactory
  2. Exception occurs: Can’t construct a java object for tag:yaml.org,2002:com.alibaba.druid.filter.stat.StatFilter; exception=Class is not accepted: com.alibaba.druid.filter.stat.StatFilter.

Example codes for reproduce this issue (such as a github link).

https://github.com/caol64/sharding-test

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 17 (8 by maintainers)

Most upvoted comments

@caol64

  • Do you mean that we should set up an ArrayList to put Alibaba Druid’s plugin-related classes into it, and then add a judgment about the array to this if judgment?
  • But it would surprise me if ShardingSphere 5.1.2 is normal, because this code is there before 5.1.2, it sounds like the problem happens when the java class ( Of course, I mean Alibaba Druid’s class ) is serialized to yaml.
  • I don’t have time to troubleshoot this problem these days. I have several issues of my own that need to be dealt with on my timeline.

Thank you for replying. The same code run in 5.1.2 is OK. Only when upgrading to 5.2.0 will cause this error.