Fix backward incompatibility

This commit is contained in:
Trustin Lee 2012-11-10 00:48:35 +09:00
parent c34d0a2272
commit 59bc375f73
2 changed files with 7 additions and 6 deletions

View File

@ -65,8 +65,8 @@ public class Base64Decoder extends OneToOneDecoder {
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg)
throws Exception {
if (msg instanceof CharSequence) {
msg = ChannelBuffers.copiedBuffer((CharSequence) msg, CharsetUtil.US_ASCII);
if (msg instanceof String) {
msg = ChannelBuffers.copiedBuffer((String) msg, CharsetUtil.US_ASCII);
} else if (!(msg instanceof ChannelBuffer)) {
return msg;
}

View File

@ -87,10 +87,11 @@ public class StringEncoder extends OneToOneEncoder {
@Override
protected Object encode(
ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
if (!(msg instanceof CharSequence)) {
return msg;
if (msg instanceof String) {
return copiedBuffer(
ctx.getChannel().getConfig().getBufferFactory().getDefaultOrder(), (String) msg, charset);
}
return copiedBuffer(
ctx.getChannel().getConfig().getBufferFactory().getDefaultOrder(), (CharSequence) msg, charset);
return msg;
}
}