You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/06/08 18:17:12 UTC

[GitHub] [dubbo] noobyu6 opened a new issue, #10131: Code optimization suggestions

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: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] CrazyHZM closed issue #10131: Code optimization suggestions

Posted by GitBox <gi...@apache.org>.
CrazyHZM closed issue #10131: Code optimization suggestions
URL: https://github.com/apache/dubbo/issues/10131


-- 
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@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] CrazyHZM commented on issue #10131: Code optimization suggestions

Posted by GitBox <gi...@apache.org>.
CrazyHZM commented on issue #10131:
URL: https://github.com/apache/dubbo/issues/10131#issuecomment-1150840717

   The 2.5.x version has been EOL and will no longer be released. Welcome to the latest 3.x version.
   


-- 
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@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org