Simpler toString() for ByteBufAllocators

This commit is contained in:
Trustin Lee 2013-11-08 17:53:57 +09:00
parent 4c7fa950cc
commit 9125977692
2 changed files with 24 additions and 17 deletions

View File

@ -17,6 +17,7 @@
package io.netty.buffer; package io.netty.buffer;
import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.StringUtil;
/** /**
* Skeletal {@link ByteBufAllocator} implementation to extend. * Skeletal {@link ByteBufAllocator} implementation to extend.
@ -188,4 +189,9 @@ public abstract class AbstractByteBufAllocator implements ByteBufAllocator {
* Create a direct {@link ByteBuf} with the given initialCapacity and maxCapacity. * Create a direct {@link ByteBuf} with the given initialCapacity and maxCapacity.
*/ */
protected abstract ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity); protected abstract ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity);
@Override
public String toString() {
return StringUtil.simpleClassName(this) + "(directByDefault: " + directByDefault + ')';
}
} }

View File

@ -17,7 +17,6 @@
package io.netty.buffer; package io.netty.buffer;
import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.StringUtil;
import io.netty.util.internal.SystemPropertyUtil; import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory; import io.netty.util.internal.logging.InternalLoggerFactory;
@ -245,20 +244,22 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator {
return directArenas != null; return directArenas != null;
} }
public String toString() { // Too noisy at the moment.
StringBuilder buf = new StringBuilder(); //
buf.append(heapArenas.length); // public String toString() {
buf.append(" heap arena(s):"); // StringBuilder buf = new StringBuilder();
buf.append(StringUtil.NEWLINE); // buf.append(heapArenas.length);
for (PoolArena<byte[]> a: heapArenas) { // buf.append(" heap arena(s):");
buf.append(a); // buf.append(StringUtil.NEWLINE);
} // for (PoolArena<byte[]> a: heapArenas) {
buf.append(directArenas.length); // buf.append(a);
buf.append(" direct arena(s):"); // }
buf.append(StringUtil.NEWLINE); // buf.append(directArenas.length);
for (PoolArena<ByteBuffer> a: directArenas) { // buf.append(" direct arena(s):");
buf.append(a); // buf.append(StringUtil.NEWLINE);
} // for (PoolArena<ByteBuffer> a: directArenas) {
return buf.toString(); // buf.append(a);
} // }
// return buf.toString();
// }
} }