Fixed issue: NETTY-173 Do not use Class.isArray() in ReplayingDecoder and FrameDecoder
* Modified FrameDecoder and ReplayingDecoder not to use Class.isArray() anymore.
This commit is contained in:
parent
5ae0adbfaa
commit
e410abed02
@ -22,7 +22,6 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.frame;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@ -264,21 +263,16 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
|
||||
"if it returned a frame.");
|
||||
}
|
||||
|
||||
fireMessageReceived(context, remoteAddress, frame);
|
||||
unfoldAndFireMessageReceived(context, remoteAddress, frame);
|
||||
}
|
||||
}
|
||||
|
||||
private void fireMessageReceived(ChannelHandlerContext context, SocketAddress remoteAddress, Object result) {
|
||||
private void unfoldAndFireMessageReceived(ChannelHandlerContext context, SocketAddress remoteAddress, Object result) {
|
||||
if (unfold) {
|
||||
if (result instanceof Object[]) {
|
||||
for (Object r: (Object[]) result) {
|
||||
Channels.fireMessageReceived(context, r, remoteAddress);
|
||||
}
|
||||
} else if (result.getClass().isArray()){
|
||||
int length = Array.getLength(result);
|
||||
for (int i = 0; i < length; i ++) {
|
||||
Channels.fireMessageReceived(context, Array.get(result, i), remoteAddress);
|
||||
}
|
||||
} else if (result instanceof Iterable<?>) {
|
||||
for (Object r: (Iterable<?>) result) {
|
||||
Channels.fireMessageReceived(context, r, remoteAddress);
|
||||
@ -309,7 +303,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
|
||||
// notify a user that the connection was closed explicitly.
|
||||
Object partialFrame = decodeLast(ctx, ctx.getChannel(), cumulation);
|
||||
if (partialFrame != null) {
|
||||
fireMessageReceived(ctx, null, partialFrame);
|
||||
unfoldAndFireMessageReceived(ctx, null, partialFrame);
|
||||
}
|
||||
} finally {
|
||||
ctx.sendUpstream(e);
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.replay;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@ -452,11 +451,6 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
|
||||
for (Object r: (Object[]) result) {
|
||||
Channels.fireMessageReceived(context, r, remoteAddress);
|
||||
}
|
||||
} else if (result.getClass().isArray()){
|
||||
int length = Array.getLength(result);
|
||||
for (int i = 0; i < length; i ++) {
|
||||
Channels.fireMessageReceived(context, Array.get(result, i), remoteAddress);
|
||||
}
|
||||
} else if (result instanceof Iterable<?>) {
|
||||
for (Object r: (Iterable<?>) result) {
|
||||
Channels.fireMessageReceived(context, r, remoteAddress);
|
||||
|
Loading…
Reference in New Issue
Block a user