Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong event setting #3043

Merged
merged 7 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ public boolean isEvent() {
return mEvent;
}

public void setEvent(String event) {
mEvent = true;
mData = event;
public void setEvent(boolean mEvent) {
beiwei30 marked this conversation as resolved.
Show resolved Hide resolved
this.mEvent = mEvent;
}

public boolean isBroken() {
Expand All @@ -121,7 +120,8 @@ public boolean isHeartbeat() {

public void setHeartbeat(boolean isHeartbeat) {
if (isHeartbeat) {
setEvent(HEARTBEAT_EVENT);
setEvent(true);
setData(HEARTBEAT_EVENT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@

/**
* ExchangeCodec.
*
*
*
*/
public class ExchangeCodec extends TelnetCodec {

Expand Down Expand Up @@ -176,7 +173,7 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro
req.setVersion(Version.getProtocolVersion());
req.setTwoWay((flag & FLAG_TWOWAY) != 0);
if ((flag & FLAG_EVENT) != 0) {
req.setEvent(Request.HEARTBEAT_EVENT);
req.setEvent(true);
}
try {
ObjectInput in = CodecSupport.deserialize(channel.getUrl(), is, proto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static void sent(Channel channel, Request request) {
* @param channel channel to close
*/
public static void closeChannel(Channel channel) {
for (Map.Entry<Long, Channel> entry: CHANNELS.entrySet()) {
for (Map.Entry<Long, Channel> entry : CHANNELS.entrySet()) {
if (channel.equals(entry.getValue())) {
DefaultFuture future = getFuture(entry.getKey());
if (future != null && !future.isDone()) {
Expand Down Expand Up @@ -255,7 +255,6 @@ private void invokeCallback(ResponseCallback c) {
if (callbackCopy == null) {
throw new NullPointerException("callback cannot be null.");
}
c = null;
Response res = response;
if (res == null) {
throw new IllegalStateException("response cannot be null. url:" + channel.getUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public void startClose() {

private void sendChannelReadOnlyEvent() {
Request request = new Request();
request.setEvent(Request.READONLY_EVENT);
request.setEvent(true);
beiwei30 marked this conversation as resolved.
Show resolved Hide resolved
request.setData(Request.READONLY_EVENT);
request.setTwoWay(false);
request.setVersion(Version.getProtocolVersion());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ protected void doTask(Channel channel) {
Request req = new Request();
req.setVersion(Version.getProtocolVersion());
req.setTwoWay(true);
req.setEvent(Request.HEARTBEAT_EVENT);
req.setEvent(true);
req.setData(Request.HEARTBEAT_EVENT);
channel.send(req);
if (logger.isDebugEnabled()) {
logger.debug("Send heartbeat to remote channel " + channel.getRemoteAddress()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ public void send(Object message) throws RemotingException {
public void test_received_request_event_readonly() throws RemotingException {
final Request request = new Request();
request.setTwoWay(true);
request.setEvent(Request.READONLY_EVENT);
request.setEvent(true);
request.setData(Request.READONLY_EVENT);

final Channel mchannel = new MockedChannel();
HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(new MockedExchangeHandler());
Expand All @@ -167,7 +168,8 @@ public void test_received_request_event_readonly() throws RemotingException {
public void test_received_request_event_other_discard() throws RemotingException {
final Request request = new Request();
request.setTwoWay(true);
request.setEvent("my event");
request.setEvent(true);
request.setData("my event");

final Channel mchannel = new MockedChannel() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro
req.setVersion(Version.getProtocolVersion());
req.setTwoWay((flag & FLAG_TWOWAY) != 0);
if ((flag & FLAG_EVENT) != 0) {
req.setEvent(Request.HEARTBEAT_EVENT);
req.setEvent(true);
}
try {
ObjectInput in = CodecSupport.deserialize(channel.getUrl(), is, proto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro
req.setVersion(Version.getProtocolVersion());
req.setTwoWay((flag & FLAG_TWOWAY) != 0);
if ((flag & FLAG_EVENT) != 0) {
req.setEvent(Request.HEARTBEAT_EVENT);
req.setEvent(true);
}
try {
Object data;
Expand Down Expand Up @@ -145,6 +145,7 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro
req.setBroken(true);
req.setData(t);
}

return req;
}
}
Expand Down