use of io.netty.channel.ChannelId in project spring-framework by spring-projects.
the class ReactorServerHttpResponse method touchDataBuffer.
@Override
protected void touchDataBuffer(DataBuffer buffer) {
if (logger.isDebugEnabled()) {
if (ReactorServerHttpRequest.reactorNettyRequestChannelOperationsIdPresent) {
if (ChannelOperationsIdHelper.touch(buffer, this.response)) {
return;
}
}
this.response.withConnection(connection -> {
ChannelId id = connection.channel().id();
DataBufferUtils.touch(buffer, "Channel id: " + id.asShortText());
});
}
}
use of io.netty.channel.ChannelId in project netty by netty.
the class DefaultChannelGroup method remove.
@Override
public boolean remove(Object o) {
Channel c = null;
if (o instanceof ChannelId) {
c = nonServerChannels.remove(o);
if (c == null) {
c = serverChannels.remove(o);
}
} else if (o instanceof Channel) {
c = (Channel) o;
if (c instanceof ServerChannel) {
c = serverChannels.remove(c.id());
} else {
c = nonServerChannels.remove(c.id());
}
}
if (c == null) {
return false;
}
c.closeFuture().removeListener(remover);
return true;
}
use of io.netty.channel.ChannelId in project netty by netty.
the class Http2StreamChannelIdTest method testSerialization.
@Test
public void testSerialization() throws Exception {
ChannelId normalInstance = new Http2StreamChannelId(DefaultChannelId.newInstance(), 0);
ByteBuf buf = Unpooled.buffer();
ObjectOutputStream outStream = new ObjectOutputStream(new ByteBufOutputStream(buf));
try {
outStream.writeObject(normalInstance);
} finally {
outStream.close();
}
ObjectInputStream inStream = new ObjectInputStream(new ByteBufInputStream(buf, true));
final ChannelId deserializedInstance;
try {
deserializedInstance = (ChannelId) inStream.readObject();
} finally {
inStream.close();
}
assertEquals(normalInstance, deserializedInstance);
assertEquals(normalInstance.hashCode(), deserializedInstance.hashCode());
assertEquals(0, normalInstance.compareTo(deserializedInstance));
assertEquals(normalInstance.asLongText(), deserializedInstance.asLongText());
assertEquals(normalInstance.asShortText(), deserializedInstance.asShortText());
}
use of io.netty.channel.ChannelId in project netty by netty.
the class EmbeddedChannelIdTest method testSerialization.
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
// test that a deserialized instance works the same as a normal instance (issue #2869)
ChannelId normalInstance = EmbeddedChannelId.INSTANCE;
ByteBuf buf = Unpooled.buffer();
ObjectOutputStream outStream = new ObjectOutputStream(new ByteBufOutputStream(buf));
try {
outStream.writeObject(normalInstance);
} finally {
outStream.close();
}
ObjectInputStream inStream = new ObjectInputStream(new ByteBufInputStream(buf, true));
final ChannelId deserializedInstance;
try {
deserializedInstance = (ChannelId) inStream.readObject();
} finally {
inStream.close();
}
assertEquals(normalInstance, deserializedInstance);
assertEquals(normalInstance.hashCode(), deserializedInstance.hashCode());
assertEquals(0, normalInstance.compareTo(deserializedInstance));
}
use of io.netty.channel.ChannelId in project netty by netty.
the class EmbeddedChannelTest method testConstructWithChannelId.
@Test
public void testConstructWithChannelId() {
ChannelId channelId = new CustomChannelId(1);
EmbeddedChannel channel = new EmbeddedChannel(channelId);
assertSame(channelId, channel.id());
}
Aggregations