hengyunabc closed pull request #1589: add @Override annotation and clean code.
URL: https://github.com/apache/incubator-dubbo/pull/1589
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java
index 0c5e876597..1a4d48b0ea 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java
@@ -51,7 +51,23 @@ public ChannelEventRunnable(Channel channel, ChannelHandler
handler, ChannelStat
}
public void run() {
- switch (state) {
+ // branch prediction optimization
+ if (state == ChannelState.SENT) {
+ try {
+ handler.sent(channel, message);
+ } catch (Exception e) {
+ logger.warn("ChannelEventRunnable handle " + state + "
operation error, channel is " + channel
+ + ", message is " + message, e);
+ }
+ } else if (state == ChannelState.RECEIVED) {
+ try {
+ handler.received(channel, message);
+ } catch (Exception e) {
+ logger.warn("ChannelEventRunnable handle " + state + "
operation error, channel is " + channel
+ + ", message is " + message, e);
+ }
+ } else {
+ switch (state) {
case CONNECTED:
try {
handler.connected(channel);
@@ -66,22 +82,6 @@ public void run() {
logger.warn("ChannelEventRunnable handle " + state + "
operation error, channel is " + channel, e);
}
break;
- case SENT:
- try {
- handler.sent(channel, message);
- } catch (Exception e) {
- logger.warn("ChannelEventRunnable handle " + state + "
operation error, channel is " + channel
- + ", message is " + message, e);
- }
- break;
- case RECEIVED:
- try {
- handler.received(channel, message);
- } catch (Exception e) {
- logger.warn("ChannelEventRunnable handle " + state + "
operation error, channel is " + channel
- + ", message is " + message, e);
- }
- break;
case CAUGHT:
try {
handler.caught(channel, exception);
@@ -92,7 +92,9 @@ public void run() {
break;
default:
logger.warn("unknown state: " + state + ", message is " +
message);
+ }
}
+
}
/**
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services