Skip to content

Commit

Permalink
fixed travis-ci failed because of test cases. (apache#1370)
Browse files Browse the repository at this point in the history
  • Loading branch information
诣极 ( yì jí ) authored and beiwei30 committed Feb 13, 2018
1 parent 890d8a1 commit 09d2577
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.common.extension.ExtensionLoader;
import com.alibaba.dubbo.common.utils.NetUtils;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Protocol;
import com.alibaba.dubbo.rpc.gen.dubbo.$__DemoStub;
Expand All @@ -36,16 +37,19 @@

public abstract class AbstractTest {

static final int PORT = 30660;
protected int PORT = NetUtils.getAvailablePort();

protected TServer server;

protected Protocol protocol;

protected Invoker<?> invoker;

TServerTransport serverTransport;

protected void init() throws Exception {
TServerTransport serverTransport = new TServerSocket(PORT);

serverTransport = new TServerSocket(PORT);

TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();

Expand Down Expand Up @@ -98,6 +102,15 @@ protected void destroy() throws Exception {
invoker = null;
}

try{
if(serverTransport != null){
// release port if used
serverTransport.close();
}
}catch (Exception e) {
// ignore
}

}

protected TTransportFactory getTransportFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.alibaba.dubbo.rpc.protocol.thrift;

import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.common.utils.NetUtils;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.gen.dubbo.Demo;

Expand All @@ -25,7 +26,7 @@

public class ThriftProtocolTest extends AbstractTest {

public static final int DEFAULT_PORT = 30660;
public final int DEFAULT_PORT = NetUtils.getAvailablePort();

private ThriftProtocol protocol;

Expand Down

0 comments on commit 09d2577

Please sign in to comment.