Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Update version of Netty dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcox committed Dec 29, 2015
1 parent 0561b5f commit 01108da
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
Expand Up @@ -85,15 +85,15 @@ protected ChannelFuture writeRequest(ChannelBuffer request)
HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST,
endpointUri);

httpRequest.setHeader(HttpHeaders.HOST, hostName);
httpRequest.setHeader(HttpHeaders.CONTENT_LENGTH, request.readableBytes());
httpRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-thrift");
httpRequest.setHeader(HttpHeaders.ACCEPT, "application/x-thrift");
httpRequest.setHeader(HttpHeaders.USER_AGENT, "Java/Swift-HttpThriftClientChannel");
httpRequest.headers().add(HttpHeaders.HOST, hostName);
httpRequest.headers().add(HttpHeaders.CONTENT_LENGTH, request.readableBytes());
httpRequest.headers().add(HttpHeaders.CONTENT_TYPE, "application/x-thrift");
httpRequest.headers().add(HttpHeaders.ACCEPT, "application/x-thrift");
httpRequest.headers().add(HttpHeaders.USER_AGENT, "Java/Swift-HttpThriftClientChannel");

if (headerDictionary != null) {
for (Map.Entry<String, String> entry : headerDictionary.entrySet()) {
httpRequest.setHeader(entry.getKey(), entry.getValue());
httpRequest.headers().add(entry.getKey(), entry.getValue());
}
}

Expand Down
Expand Up @@ -68,6 +68,7 @@ public AbstractSelector openSelector() throws IOException
{
return new AbstractSelector(this) {

private final Object lock = new Object();
private final Set<SelectionKey> keys = Sets.newHashSet();

@Override
Expand Down Expand Up @@ -153,19 +154,36 @@ public int selectNow() throws IOException
@Override
public int select(long timeout) throws IOException
{
return 0;
synchronized (lock) {
try {
lock.wait(timeout);
return 0;
} catch (InterruptedException e) {
throw new IOException(e);
}
}
}

@Override
public int select() throws IOException
{
return 0;
synchronized (lock) {
try {
lock.wait();
return 0;
} catch (InterruptedException e) {
throw new IOException(e);
}
}
}

@Override
public Selector wakeup()
{
return this;
synchronized (lock) {
lock.notify();
return this;
}
}

};
Expand Down
Expand Up @@ -17,6 +17,7 @@

import com.facebook.nifty.client.FramedClientChannel;
import com.facebook.nifty.client.FramedClientConnector;
import com.facebook.nifty.client.NettyClientConfigBuilder;
import com.facebook.nifty.client.NiftyClient;
import com.facebook.nifty.test.scribe;
import com.google.common.base.Throwables;
Expand Down Expand Up @@ -65,7 +66,8 @@ public void testSyncConnectTimeout() throws ConnectException, IOException
{
ServerSocket serverSocket = new ServerSocket(0);
int port = serverSocket.getLocalPort();
final NiftyClient client = new NiftyClient();
NettyClientConfigBuilder builder = new NettyClientConfigBuilder().setBossThreadCount(1).setWorkerThreadCount(1);
final NiftyClient client = new NiftyClient(builder.build());
try {
client.connectSync(scribe.Client.class,
new FramedClientConnector(new InetSocketAddress(port)),
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -107,7 +107,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>3.7.0.Final</version>
<version>3.10.5.Final</version>
</dependency>

<dependency>
Expand Down

0 comments on commit 01108da

Please sign in to comment.