can't use HintManager.getInstance().setMasterRouteOnly()
Bug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed GitHub issues.
- Read documentation: ShardingSphere Doc.
Please pay attention on issues you submitted, because we maybe need more details. If no response more than 7 days 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?
4.0.0-RC2
Which project did you use? Sharding-JDBC or Sharding-Proxy?
Sharding-JDBC
Expected behavior
route to master
Actual behavior
throw a exception : HintManagerHolder has previous value, please clear first.
Reason analyze (If you can)
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
// 读写分离配置 MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration("ds", "fcWriteDataSource", Arrays.asList("fcRead1DataSource", "fcRead2DataSource"));
Set<MasterSlaveRuleConfiguration> masterSlaveRuleConfigurationSet = new HashSet<>();
masterSlaveRuleConfigurationSet.add(masterSlaveRuleConfig);
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.setMasterSlaveRuleConfigs(masterSlaveRuleConfigurationSet);
...
Example codes for reproduce this issue (such as a github link).
Perhaps you forget to close previous HintManager
for example:
HintManager.getInstance().setMasterRouteOnly();
final List
then : thow Exception
but : before upgrade , it can route to master
Last version: 3.1.0
for HintManager.getInstance() , in 4.0.0-RC2 version . add Preconditions.checkState for check . so,it need manual close or use try...catch... ?
so,it need manual close or use try...catch... ?
Yes, you need manual close or use try with resource
3q