noobyu6 opened a new issue, #10131:
URL: https://github.com/apache/dubbo/issues/10131

   <!-- If you need to report a security issue please visit 
https://github.com/apache/dubbo/security/policy -->
   
   <!-- For all design discussions please continue. -->
   Hi,
   
   I find that the private field connectorKey at Line 56 in the file 
'dubbo/dubbo-remoting/dubbo-remoting-mina/src/main/java/com/alibaba/dubbo/remoting/transport/mina/MinaClient.java'
 on the 2.5.x branch is only assigned and used in the method doOpen. Therefore, 
this field can be removed from the class, and become a local variable in the 
method doOpen. This transformation will normally reduce memory usage and 
improve readability of your code.I will be happy if this transformation is 
helpful.
   
   ```java
   private String connectorKey; // line 56 this field can be replaced by local 
variable
   
   protected void doOpen() throws Throwable {
        // String connectorKey = getUrl().toFullString();
           connectorKey = getUrl().toFullString();
           SocketConnector c = connectors.get(connectorKey);
           if (c != null) {
               connector = c;
           } else {
               // set thread pool.
               connector = new SocketConnector(Constants.DEFAULT_IO_THREADS,
                       Executors.newCachedThreadPool(new 
NamedThreadFactory("MinaClientWorker", true)));
               // config
               SocketConnectorConfig cfg = (SocketConnectorConfig) 
connector.getDefaultConfig();
               cfg.setThreadModel(ThreadModel.MANUAL);
               cfg.getSessionConfig().setTcpNoDelay(true);
               cfg.getSessionConfig().setKeepAlive(true);
               int timeout = getTimeout();
               cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000);
               // set codec.
               connector.getFilterChain().addLast("codec", new 
ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
               connectors.put(connectorKey, connector);
           }
   }
   ```


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

Reply via email to