Use StringUtil.simpleClassName(..) instead of Class.getSimpleName() where necessary
- Class.getSimpleName() doesn't render anonymous classes very well - + some minor cleanup
This commit is contained in:
parent
20f6f7e018
commit
a327a25a6c
@ -80,6 +80,6 @@ public class DefaultHttpContent extends DefaultHttpObject implements HttpContent
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.simpleClassName(this) +
|
||||
"(data: " + content() + ", getDecoderResult: " + getDecoderResult() + ')';
|
||||
"(data: " + content() + ", decoderResult: " + getDecoderResult() + ')';
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques
|
||||
buf.append(getDecoderResult());
|
||||
buf.append(')');
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(getMethod().toString());
|
||||
buf.append(getMethod());
|
||||
buf.append(' ');
|
||||
buf.append(getUri());
|
||||
buf.append(' ');
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.handler.codec.memcache;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
/**
|
||||
* The default {@link MemcacheContent} implementation.
|
||||
@ -78,7 +79,8 @@ public class DefaultMemcacheContent extends DefaultMemcacheObject implements Mem
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "(data: " + content() + ", getDecoderResult: " + getDecoderResult() + ')';
|
||||
return StringUtil.simpleClassName(this) +
|
||||
"(data: " + content() + ", getDecoderResult: " + getDecoderResult() + ')';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.FileRegion;
|
||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -38,10 +39,12 @@ public abstract class MemcacheObjectEncoder<M extends MemcacheMessage> extends M
|
||||
protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception {
|
||||
if (msg instanceof MemcacheMessage) {
|
||||
if (expectingMoreContent) {
|
||||
throw new IllegalStateException("unexpected message type: " + msg.getClass().getSimpleName());
|
||||
throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
|
||||
}
|
||||
|
||||
out.add(encodeMessage(ctx, (M) msg));
|
||||
@SuppressWarnings({ "unchecked", "CastConflictsWithInstanceof" })
|
||||
final M m = (M) msg;
|
||||
out.add(encodeMessage(ctx, m));
|
||||
}
|
||||
|
||||
if (msg instanceof MemcacheContent || msg instanceof ByteBuf || msg instanceof FileRegion) {
|
||||
@ -86,7 +89,7 @@ public abstract class MemcacheObjectEncoder<M extends MemcacheMessage> extends M
|
||||
if (msg instanceof FileRegion) {
|
||||
return (int) ((FileRegion) msg).count();
|
||||
}
|
||||
throw new IllegalStateException("unexpected message type: " + msg.getClass().getSimpleName());
|
||||
throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +108,7 @@ public abstract class MemcacheObjectEncoder<M extends MemcacheMessage> extends M
|
||||
if (msg instanceof FileRegion) {
|
||||
return ((FileRegion) msg).retain();
|
||||
}
|
||||
throw new IllegalStateException("unexpected message type: " + msg.getClass().getSimpleName());
|
||||
throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user