Skip to content

Commit

Permalink
issue #4699: org.apache.dubbo.remoting.exchange.support.DefaultFuture…
Browse files Browse the repository at this point in the history
…#closeChannel doesn't work as expected
  • Loading branch information
beiwei30 committed Jul 30, 2019
1 parent 5d299af commit 4aa12c6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import org.apache.dubbo.common.timer.HashedWheelTimer;
import org.apache.dubbo.common.utils.Assert;
import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.Client;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.exchange.ExchangeChannel;
import org.apache.dubbo.remoting.exchange.ExchangeClient;
import org.apache.dubbo.remoting.exchange.ExchangeHandler;
import org.apache.dubbo.remoting.transport.AbstractClient;

import java.net.InetSocketAddress;
import java.util.Collections;
Expand Down Expand Up @@ -55,7 +57,7 @@ public class HeaderExchangeClient implements ExchangeClient {
public HeaderExchangeClient(Client client, boolean startTimer) {
Assert.notNull(client, "Client can't be null");
this.client = client;
this.channel = new HeaderExchangeChannel(client);
this.channel = new HeaderExchangeChannel(unwrapChannel(client));

if (startTimer) {
URL url = client.getUrl();
Expand Down Expand Up @@ -224,4 +226,8 @@ private boolean shouldReconnect(URL url) {
public String toString() {
return "HeaderExchangeClient [channel=" + channel + "]";
}

private Channel unwrapChannel(Client client) {
return (client instanceof AbstractClient) ? ((AbstractClient) client).getChannel() : client;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,5 +325,5 @@ public String toString() {
*
* @return channel
*/
protected abstract Channel getChannel();
public abstract Channel getChannel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void doClose() throws Throwable {
}

@Override
protected Channel getChannel() {
public Channel getChannel() {
Connection<?> c = connection;
if (c == null || !c.isOpen()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected void doClose() throws Throwable {
}

@Override
protected Channel getChannel() {
public Channel getChannel() {
IoSession s = session;
if (s == null || !s.isConnected()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected void doClose() throws Throwable {
}

@Override
protected org.apache.dubbo.remoting.Channel getChannel() {
public org.apache.dubbo.remoting.Channel getChannel() {
Channel c = channel;
if (c == null || !c.isConnected()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected void doClose() throws Throwable {
}

@Override
protected org.apache.dubbo.remoting.Channel getChannel() {
public org.apache.dubbo.remoting.Channel getChannel() {
Channel c = channel;
if (c == null || !c.isActive()) {
return null;
Expand Down

0 comments on commit 4aa12c6

Please sign in to comment.