Fixed all SPDY echo tests / Handle closed old I/O channels correctly
This commit is contained in:
parent
01aa1647bb
commit
f60f918763
@ -26,18 +26,15 @@ public class NioNioSocketSpdyEchoTest extends AbstractSocketSpdyEchoTest {
|
||||
|
||||
@Override
|
||||
protected ChannelBootstrap newClientBootstrap() {
|
||||
ChannelBootstrap b = new ChannelBootstrap();
|
||||
b.eventLoop(new SelectorEventLoop());
|
||||
b.channel(new NioSocketChannel());
|
||||
return b;
|
||||
return new ChannelBootstrap()
|
||||
.eventLoop(new SelectorEventLoop())
|
||||
.channel(new NioSocketChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServerChannelBootstrap newServerBootstrap() {
|
||||
ServerChannelBootstrap b = new ServerChannelBootstrap();
|
||||
b.eventLoop(new SelectorEventLoop(), new SelectorEventLoop());
|
||||
b.channel(new NioServerSocketChannel());
|
||||
return b;
|
||||
return new ServerChannelBootstrap()
|
||||
.eventLoop(new SelectorEventLoop(), new SelectorEventLoop())
|
||||
.channel(new NioServerSocketChannel());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,20 +16,26 @@
|
||||
package io.netty.handler.codec.spdy;
|
||||
|
||||
|
||||
import io.netty.channel.ChannelFactory;
|
||||
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import io.netty.channel.socket.oio.OioServerSocketChannelFactory;
|
||||
import io.netty.channel.ChannelBootstrap;
|
||||
import io.netty.channel.ServerChannelBootstrap;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.channel.socket.nio.SelectorEventLoop;
|
||||
import io.netty.channel.socket.oio.BlockingChannelEventLoop;
|
||||
import io.netty.channel.socket.oio.OioServerSocketChannel;
|
||||
|
||||
public class NioOioSocketSpdyEchoTest extends AbstractSocketSpdyEchoTest {
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newClientBootstrap() {
|
||||
return new NioClientSocketChannelFactory(executor);
|
||||
protected ChannelBootstrap newClientBootstrap() {
|
||||
return new ChannelBootstrap()
|
||||
.eventLoop(new SelectorEventLoop())
|
||||
.channel(new NioSocketChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newServerBootstrap() {
|
||||
return new OioServerSocketChannelFactory(executor, executor);
|
||||
protected ServerChannelBootstrap newServerBootstrap() {
|
||||
return new ServerChannelBootstrap()
|
||||
.eventLoop(new BlockingChannelEventLoop(), new BlockingChannelEventLoop())
|
||||
.channel(new OioServerSocketChannel());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,20 +16,26 @@
|
||||
package io.netty.handler.codec.spdy;
|
||||
|
||||
|
||||
import io.netty.channel.ChannelFactory;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
import io.netty.channel.socket.oio.OioClientSocketChannelFactory;
|
||||
import io.netty.channel.ChannelBootstrap;
|
||||
import io.netty.channel.ServerChannelBootstrap;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.SelectorEventLoop;
|
||||
import io.netty.channel.socket.oio.BlockingChannelEventLoop;
|
||||
import io.netty.channel.socket.oio.OioSocketChannel;
|
||||
|
||||
public class OioNioSocketSpdyEchoTest extends AbstractSocketSpdyEchoTest {
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newClientBootstrap() {
|
||||
return new OioClientSocketChannelFactory(executor);
|
||||
protected ChannelBootstrap newClientBootstrap() {
|
||||
return new ChannelBootstrap()
|
||||
.eventLoop(new BlockingChannelEventLoop())
|
||||
.channel(new OioSocketChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newServerBootstrap() {
|
||||
return new NioServerSocketChannelFactory(executor);
|
||||
protected ServerChannelBootstrap newServerBootstrap() {
|
||||
return new ServerChannelBootstrap()
|
||||
.eventLoop(new SelectorEventLoop(), new SelectorEventLoop())
|
||||
.channel(new NioServerSocketChannel());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,20 +16,25 @@
|
||||
package io.netty.handler.codec.spdy;
|
||||
|
||||
|
||||
import io.netty.channel.ChannelFactory;
|
||||
import io.netty.channel.socket.oio.OioClientSocketChannelFactory;
|
||||
import io.netty.channel.socket.oio.OioServerSocketChannelFactory;
|
||||
import io.netty.channel.ChannelBootstrap;
|
||||
import io.netty.channel.ServerChannelBootstrap;
|
||||
import io.netty.channel.socket.oio.BlockingChannelEventLoop;
|
||||
import io.netty.channel.socket.oio.OioServerSocketChannel;
|
||||
import io.netty.channel.socket.oio.OioSocketChannel;
|
||||
|
||||
public class OioOioSocketSpdyEchoTest extends AbstractSocketSpdyEchoTest {
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newClientBootstrap() {
|
||||
return new OioClientSocketChannelFactory(executor);
|
||||
protected ChannelBootstrap newClientBootstrap() {
|
||||
return new ChannelBootstrap()
|
||||
.eventLoop(new BlockingChannelEventLoop())
|
||||
.channel(new OioSocketChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChannelFactory newServerBootstrap() {
|
||||
return new OioServerSocketChannelFactory(executor, executor);
|
||||
protected ServerChannelBootstrap newServerBootstrap() {
|
||||
return new ServerChannelBootstrap()
|
||||
.eventLoop(new BlockingChannelEventLoop(), new BlockingChannelEventLoop())
|
||||
.channel(new OioServerSocketChannel());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -153,6 +153,10 @@ public class OioServerSocketChannel extends AbstractServerChannel
|
||||
|
||||
@Override
|
||||
protected int doRead(Queue<Object> buf) throws Exception {
|
||||
if (socket.isClosed()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Socket s = null;
|
||||
try {
|
||||
s = socket.accept();
|
||||
|
@ -193,6 +193,9 @@ public class OioSocketChannel extends AbstractChannel
|
||||
|
||||
@Override
|
||||
protected int doRead(ChannelBuffer buf) throws Exception {
|
||||
if (socket.isClosed()) {
|
||||
return -1;
|
||||
}
|
||||
try {
|
||||
int readBytes = buf.writeBytes(is, buf.writableBytes());
|
||||
return readBytes;
|
||||
|
Loading…
Reference in New Issue
Block a user