Skip to content

Commit dfd7b0d

Browse files
committed
NETTY-426 Prevent a user from reusing an upstream MessageEvent to write
something Modified the pipeline implementations so that it rejects the attempt to send an UpstreamMessageEvent to downstream
1 parent 4bf26c3 commit dfd7b0d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ public void sendDownstream(ChannelEvent e) {
590590
}
591591

592592
void sendDownstream(DefaultChannelHandlerContext ctx, ChannelEvent e) {
593+
if (e instanceof UpstreamMessageEvent) {
594+
throw new IllegalArgumentException("cannot send an upstream event to downstream");
595+
}
596+
593597
try {
594598
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
595599
} catch (Throwable t) {

src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,10 @@ public void sendDownstream(ChannelEvent e) {
407407
}
408408

409409
void sendDownstream(StaticChannelHandlerContext ctx, ChannelEvent e) {
410+
if (e instanceof UpstreamMessageEvent) {
411+
throw new IllegalArgumentException("cannot send an upstream event to downstream");
412+
}
413+
410414
try {
411415
((ChannelDownstreamHandler) ctx.getHandler()).handleDownstream(ctx, e);
412416
} catch (Throwable t) {

0 commit comments

Comments
 (0)