pinxiong opened a new issue #8218: URL: https://github.com/apache/dubbo/issues/8218
- [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate. - [x] I have checked the [FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate. ### Environment * Dubbo version: `3.0.2-SNAPSHOT` * Operating System version: `Mac OS` * Java version: `1.8` ### Steps to reproduce this issue + Don't need to expose private variables ```java public abstract class AbstractRouter implements Router { // The getter and setter already exist, so don't need to expose the variable protected int priority = DEFAULT_PRIORITY; // The getter and setter already exist, so don't need to expose the variable protected boolean force = false; // The getter already exists, so don't need to expose the variable protected URL url; // Don't need to expose the variable protected GovernanceRuleRepository ruleRepository; public AbstractRouter(URL url) { this.ruleRepository = ExtensionLoader.getExtensionLoader(GovernanceRuleRepository.class).getDefaultExtension(); this.url = url; } @Override public URL getUrl() { return url; } public void setUrl(URL url) { this.url = url; } @Override public boolean isForce() { return force; } public void setForce(boolean force) { this.force = force; } @Override public int getPriority() { return priority; } public void setPriority(int priority) { this.priority = priority; } } ``` + Why not use setter or getter ```java public class ConditionRouter extends AbstractRouter { ...... public ConditionRouter(String rule, boolean force, boolean enabled) { // use setter this.force = force; this.enabled = enabled; if (enabled) { this.init(rule); } } public ConditionRouter(URL url) { // use setter this.url = url; // use setter this.priority = url.getParameter(PRIORITY_KEY, 0); // use setter this.force = url.getParameter(FORCE_KEY, false); this.enabled = url.getParameter(ENABLED_KEY, true); if (enabled) { init(url.getParameterAndDecoded(RULE_KEY)); } } } ``` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
