Small performance improvements
Motivation: Found performance issues via FindBugs and PMD. Modifications: - Removed unnecessary boxing/unboxing operations in DefaultTextHeaders.convertToInt(CharSequence) and DefaultTextHeaders.convertToLong(CharSequence). A boxed primitive is created from a string, just to extract the unboxed primitive value. - Added a static modifier for DefaultHttp2Connection.ParentChangedEvent class. This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary. - Added a static compiled Pattern to avoid compile it each time it is used when we need to replace some part of authority. - Improved using of StringBuilders. Result: Performance improvements.
This commit is contained in:
parent
aef49202b7
commit
9465db25ba
@ -1076,23 +1076,18 @@ public abstract class AbstractByteBuf extends ByteBuf {
|
||||
return StringUtil.simpleClassName(this) + "(freed)";
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append("(ridx: ");
|
||||
buf.append(readerIndex);
|
||||
buf.append(", widx: ");
|
||||
buf.append(writerIndex);
|
||||
buf.append(", cap: ");
|
||||
buf.append(capacity());
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append("(ridx: ").append(readerIndex)
|
||||
.append(", widx: ").append(writerIndex)
|
||||
.append(", cap: ").append(capacity());
|
||||
if (maxCapacity != Integer.MAX_VALUE) {
|
||||
buf.append('/');
|
||||
buf.append(maxCapacity);
|
||||
buf.append('/').append(maxCapacity);
|
||||
}
|
||||
|
||||
ByteBuf unwrapped = unwrap();
|
||||
if (unwrapped != null) {
|
||||
buf.append(", unwrapped: ");
|
||||
buf.append(unwrapped);
|
||||
buf.append(", unwrapped: ").append(unwrapped);
|
||||
}
|
||||
buf.append(')');
|
||||
return buf.toString();
|
||||
|
@ -309,41 +309,41 @@ abstract class PoolArena<T> {
|
||||
protected abstract void destroyChunk(PoolChunk<T> chunk);
|
||||
|
||||
public synchronized String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("Chunk(s) at 0~25%:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(qInit);
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("Chunk(s) at 0~50%:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(q000);
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("Chunk(s) at 25~75%:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(q025);
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("Chunk(s) at 50~100%:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(q050);
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("Chunk(s) at 75~100%:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(q075);
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("Chunk(s) at 100%:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(q100);
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("tiny subpages:");
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append("Chunk(s) at 0~25%:")
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append(qInit)
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("Chunk(s) at 0~50%:")
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append(q000)
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("Chunk(s) at 25~75%:")
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append(q025)
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("Chunk(s) at 50~100%:")
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append(q050)
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("Chunk(s) at 75~100%:")
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append(q075)
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("Chunk(s) at 100%:")
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append(q100)
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("tiny subpages:");
|
||||
for (int i = 1; i < tinySubpagePools.length; i ++) {
|
||||
PoolSubpage<T> head = tinySubpagePools[i];
|
||||
if (head.next == head) {
|
||||
continue;
|
||||
}
|
||||
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(i);
|
||||
buf.append(": ");
|
||||
buf.append(StringUtil.NEWLINE)
|
||||
.append(i)
|
||||
.append(": ");
|
||||
PoolSubpage<T> s = head.next;
|
||||
for (;;) {
|
||||
buf.append(s);
|
||||
@ -353,17 +353,17 @@ abstract class PoolArena<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("small subpages:");
|
||||
buf.append(StringUtil.NEWLINE)
|
||||
.append("small subpages:");
|
||||
for (int i = 1; i < smallSubpagePools.length; i ++) {
|
||||
PoolSubpage<T> head = smallSubpagePools[i];
|
||||
if (head.next == head) {
|
||||
continue;
|
||||
}
|
||||
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(i);
|
||||
buf.append(": ");
|
||||
buf.append(StringUtil.NEWLINE)
|
||||
.append(i)
|
||||
.append(": ");
|
||||
PoolSubpage<T> s = head.next;
|
||||
for (;;) {
|
||||
buf.append(s);
|
||||
|
@ -416,16 +416,16 @@ final class PoolChunk<T> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("Chunk(");
|
||||
buf.append(Integer.toHexString(System.identityHashCode(this)));
|
||||
buf.append(": ");
|
||||
buf.append(usage());
|
||||
buf.append("%, ");
|
||||
buf.append(chunkSize - freeBytes);
|
||||
buf.append('/');
|
||||
buf.append(chunkSize);
|
||||
buf.append(')');
|
||||
return buf.toString();
|
||||
return new StringBuilder()
|
||||
.append("Chunk(")
|
||||
.append(Integer.toHexString(System.identityHashCode(this)))
|
||||
.append(": ")
|
||||
.append(usage())
|
||||
.append("%, ")
|
||||
.append(chunkSize - freeBytes)
|
||||
.append('/')
|
||||
.append(chunkSize)
|
||||
.append(')')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -308,26 +308,26 @@ public class DefaultCookie implements Cookie {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(name());
|
||||
buf.append('=');
|
||||
buf.append(value());
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(name())
|
||||
.append('=')
|
||||
.append(value());
|
||||
if (domain() != null) {
|
||||
buf.append(", domain=");
|
||||
buf.append(domain());
|
||||
buf.append(", domain=")
|
||||
.append(domain());
|
||||
}
|
||||
if (path() != null) {
|
||||
buf.append(", path=");
|
||||
buf.append(path());
|
||||
buf.append(", path=")
|
||||
.append(path());
|
||||
}
|
||||
if (comment() != null) {
|
||||
buf.append(", comment=");
|
||||
buf.append(comment());
|
||||
buf.append(", comment=")
|
||||
.append(comment());
|
||||
}
|
||||
if (maxAge() >= 0) {
|
||||
buf.append(", maxAge=");
|
||||
buf.append(maxAge());
|
||||
buf.append('s');
|
||||
buf.append(", maxAge=")
|
||||
.append(maxAge())
|
||||
.append('s');
|
||||
}
|
||||
if (isSecure()) {
|
||||
buf.append(", secure");
|
||||
|
@ -79,14 +79,14 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append("(version: ");
|
||||
buf.append(protocolVersion().text());
|
||||
buf.append(", keepAlive: ");
|
||||
buf.append(HttpHeaderUtil.isKeepAlive(this));
|
||||
buf.append(')');
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append("(version: ")
|
||||
.append(protocolVersion().text())
|
||||
.append(", keepAlive: ")
|
||||
.append(HttpHeaderUtil.isKeepAlive(this))
|
||||
.append(')')
|
||||
.append(StringUtil.NEWLINE);
|
||||
appendHeaders(buf);
|
||||
|
||||
// Remove the last newline.
|
||||
@ -109,10 +109,10 @@ public abstract class DefaultHttpMessage extends DefaultHttpObject implements Ht
|
||||
|
||||
void appendHeaders(StringBuilder buf, HttpHeaders headers) {
|
||||
for (Map.Entry<CharSequence, CharSequence> e: headers) {
|
||||
buf.append(e.getKey());
|
||||
buf.append(": ");
|
||||
buf.append(e.getValue());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(e.getKey())
|
||||
.append(": ")
|
||||
.append(e.getValue())
|
||||
.append(StringUtil.NEWLINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -520,9 +520,9 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
|
||||
char firstChar = line.charAt(0);
|
||||
if (name != null && (firstChar == ' ' || firstChar == '\t')) {
|
||||
StringBuilder buf = new StringBuilder(value.length() + line.length() + 1);
|
||||
buf.append(value);
|
||||
buf.append(' ');
|
||||
buf.append(line.toString().trim());
|
||||
buf.append(value)
|
||||
.append(' ')
|
||||
.append(line.toString().trim());
|
||||
value = buf.toString();
|
||||
} else {
|
||||
if (name != null) {
|
||||
@ -588,8 +588,8 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
|
||||
String lineTrimmed = line.toString().trim();
|
||||
CharSequence currentLastPos = current.get(lastPos);
|
||||
StringBuilder b = new StringBuilder(currentLastPos.length() + lineTrimmed.length());
|
||||
b.append(currentLastPos);
|
||||
b.append(lineTrimmed);
|
||||
b.append(currentLastPos)
|
||||
.append(lineTrimmed);
|
||||
current.set(lastPos, b.toString());
|
||||
} else {
|
||||
// Content-Length, Transfer-Encoding, or Trailer
|
||||
|
@ -60,9 +60,9 @@ public class HttpRequestEncoder extends HttpObjectEncoder<HttpRequest> {
|
||||
if (uri.lastIndexOf(SLASH, index) <= startIndex) {
|
||||
int len = uri.length();
|
||||
StringBuilder sb = new StringBuilder(len + 1);
|
||||
sb.append(uri, 0, index);
|
||||
sb.append(SLASH);
|
||||
sb.append(uri, index, len);
|
||||
sb.append(uri, 0, index)
|
||||
.append(SLASH)
|
||||
.append(uri, index, len);
|
||||
uri = sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -576,11 +576,11 @@ public class HttpResponseStatus implements Comparable<HttpResponseStatus> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder(reasonPhrase.length() + 5);
|
||||
buf.append(code);
|
||||
buf.append(' ');
|
||||
buf.append(reasonPhrase);
|
||||
return buf.toString();
|
||||
return new StringBuilder(reasonPhrase.length() + 5)
|
||||
.append(code)
|
||||
.append(' ')
|
||||
.append(reasonPhrase)
|
||||
.toString();
|
||||
}
|
||||
|
||||
void encode(ByteBuf buf) {
|
||||
|
@ -581,42 +581,42 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
|
||||
globalBodySize -= pastAttribute.size();
|
||||
StringBuilder replacement = new StringBuilder(
|
||||
139 + multipartDataBoundary.length() + multipartMixedBoundary.length() * 2 +
|
||||
fileUpload.getFilename().length() + fileUpload.getName().length());
|
||||
fileUpload.getFilename().length() + fileUpload.getName().length())
|
||||
|
||||
replacement.append("--");
|
||||
replacement.append(multipartDataBoundary);
|
||||
replacement.append("\r\n");
|
||||
.append("--")
|
||||
.append(multipartDataBoundary)
|
||||
.append("\r\n")
|
||||
|
||||
replacement.append(HttpHeaderNames.CONTENT_DISPOSITION);
|
||||
replacement.append(": ");
|
||||
replacement.append(HttpHeaderValues.FORM_DATA);
|
||||
replacement.append("; ");
|
||||
replacement.append(HttpHeaderValues.NAME);
|
||||
replacement.append("=\"");
|
||||
replacement.append(fileUpload.getName());
|
||||
replacement.append("\"\r\n");
|
||||
.append(HttpHeaderNames.CONTENT_DISPOSITION)
|
||||
.append(": ")
|
||||
.append(HttpHeaderValues.FORM_DATA)
|
||||
.append("; ")
|
||||
.append(HttpHeaderValues.NAME)
|
||||
.append("=\"")
|
||||
.append(fileUpload.getName())
|
||||
.append("\"\r\n")
|
||||
|
||||
replacement.append(HttpHeaderNames.CONTENT_TYPE);
|
||||
replacement.append(": ");
|
||||
replacement.append(HttpHeaderValues.MULTIPART_MIXED);
|
||||
replacement.append("; ");
|
||||
replacement.append(HttpHeaderValues.BOUNDARY);
|
||||
replacement.append('=');
|
||||
replacement.append(multipartMixedBoundary);
|
||||
replacement.append("\r\n\r\n");
|
||||
.append(HttpHeaderNames.CONTENT_TYPE)
|
||||
.append(": ")
|
||||
.append(HttpHeaderValues.MULTIPART_MIXED)
|
||||
.append("; ")
|
||||
.append(HttpHeaderValues.BOUNDARY)
|
||||
.append('=')
|
||||
.append(multipartMixedBoundary)
|
||||
.append("\r\n\r\n")
|
||||
|
||||
replacement.append("--");
|
||||
replacement.append(multipartMixedBoundary);
|
||||
replacement.append("\r\n");
|
||||
.append("--")
|
||||
.append(multipartMixedBoundary)
|
||||
.append("\r\n")
|
||||
|
||||
replacement.append(HttpHeaderNames.CONTENT_DISPOSITION);
|
||||
replacement.append(": ");
|
||||
replacement.append(HttpHeaderValues.ATTACHMENT);
|
||||
replacement.append("; ");
|
||||
replacement.append(HttpHeaderValues.FILENAME);
|
||||
replacement.append("=\"");
|
||||
replacement.append(fileUpload.getFilename());
|
||||
replacement.append("\"\r\n");
|
||||
.append(HttpHeaderNames.CONTENT_DISPOSITION)
|
||||
.append(": ")
|
||||
.append(HttpHeaderValues.ATTACHMENT)
|
||||
.append("; ")
|
||||
.append(HttpHeaderValues.FILENAME)
|
||||
.append("=\"")
|
||||
.append(fileUpload.getFilename())
|
||||
.append("\"\r\n");
|
||||
|
||||
pastAttribute.setValue(replacement.toString(), 1);
|
||||
pastAttribute.setValue("", 2);
|
||||
|
@ -133,16 +133,16 @@ public class DefaultSpdyDataFrame extends DefaultSpdyStreamFrame implements Spdy
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append("(last: ");
|
||||
buf.append(isLast());
|
||||
buf.append(')');
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Stream-ID = ");
|
||||
buf.append(streamId());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Size = ");
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append("(last: ")
|
||||
.append(isLast())
|
||||
.append(')')
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Stream-ID = ")
|
||||
.append(streamId())
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Size = ");
|
||||
if (refCnt() == 0) {
|
||||
buf.append("(freed)");
|
||||
} else {
|
||||
|
@ -83,14 +83,14 @@ public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Last-good-stream-ID = ");
|
||||
buf.append(lastGoodStreamId());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Status: ");
|
||||
buf.append(status());
|
||||
return buf.toString();
|
||||
return new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Last-good-stream-ID = ")
|
||||
.append(lastGoodStreamId())
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Status: ")
|
||||
.append(status())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -79,17 +79,17 @@ public class DefaultSpdyHeadersFrame extends DefaultSpdyStreamFrame
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append("(last: ");
|
||||
buf.append(isLast());
|
||||
buf.append(')');
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Stream-ID = ");
|
||||
buf.append(streamId());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Headers:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append("(last: ")
|
||||
.append(isLast())
|
||||
.append(')')
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Stream-ID = ")
|
||||
.append(streamId())
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Headers:")
|
||||
.append(StringUtil.NEWLINE);
|
||||
appendHeaders(buf);
|
||||
|
||||
// Remove the last newline.
|
||||
|
@ -46,11 +46,11 @@ public class DefaultSpdyPingFrame implements SpdyPingFrame {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> ID = ");
|
||||
buf.append(id());
|
||||
return buf.toString();
|
||||
return new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> ID = ")
|
||||
.append(id())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -71,14 +71,14 @@ public class DefaultSpdyRstStreamFrame extends DefaultSpdyStreamFrame
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Stream-ID = ");
|
||||
buf.append(streamId());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Status: ");
|
||||
buf.append(status());
|
||||
return buf.toString();
|
||||
return new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Stream-ID = ")
|
||||
.append(streamId())
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Status: ")
|
||||
.append(status())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -152,10 +152,11 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append(StringUtil.NEWLINE);
|
||||
appendSettings(buf);
|
||||
|
||||
buf.setLength(buf.length() - StringUtil.NEWLINE.length());
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -52,17 +52,17 @@ public class DefaultSpdySynReplyFrame extends DefaultSpdyHeadersFrame
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append("(last: ");
|
||||
buf.append(isLast());
|
||||
buf.append(')');
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Stream-ID = ");
|
||||
buf.append(streamId());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Headers:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append("(last: ")
|
||||
.append(isLast())
|
||||
.append(')')
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Stream-ID = ")
|
||||
.append(streamId())
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Headers:")
|
||||
.append(StringUtil.NEWLINE);
|
||||
appendHeaders(buf);
|
||||
|
||||
// Remove the last newline.
|
||||
|
@ -102,27 +102,27 @@ public class DefaultSpdySynStreamFrame extends DefaultSpdyHeadersFrame
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append("(last: ");
|
||||
buf.append(isLast());
|
||||
buf.append("; unidirectional: ");
|
||||
buf.append(isUnidirectional());
|
||||
buf.append(')');
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Stream-ID = ");
|
||||
buf.append(streamId());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append("(last: ")
|
||||
.append(isLast())
|
||||
.append("; unidirectional: ")
|
||||
.append(isUnidirectional())
|
||||
.append(')')
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Stream-ID = ")
|
||||
.append(streamId())
|
||||
.append(StringUtil.NEWLINE);
|
||||
if (associatedStreamId != 0) {
|
||||
buf.append("--> Associated-To-Stream-ID = ");
|
||||
buf.append(associatedStreamId());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Associated-To-Stream-ID = ")
|
||||
.append(associatedStreamId())
|
||||
.append(StringUtil.NEWLINE);
|
||||
}
|
||||
buf.append("--> Priority = ");
|
||||
buf.append(priority());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Headers:");
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Priority = ")
|
||||
.append(priority())
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Headers:")
|
||||
.append(StringUtil.NEWLINE);
|
||||
appendHeaders(buf);
|
||||
|
||||
// Remove the last newline.
|
||||
|
@ -69,14 +69,14 @@ public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Stream-ID = ");
|
||||
buf.append(streamId());
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append("--> Delta-Window-Size = ");
|
||||
buf.append(deltaWindowSize());
|
||||
return buf.toString();
|
||||
return new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Stream-ID = ")
|
||||
.append(streamId())
|
||||
.append(StringUtil.NEWLINE)
|
||||
.append("--> Delta-Window-Size = ")
|
||||
.append(deltaWindowSize())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public final class WebSocketExtensionTestUtil {
|
||||
|
||||
@Override
|
||||
public void appendTo(StringBuffer buf) {
|
||||
buf.append("WebSocketExtensionData with name=" + name);
|
||||
buf.append("WebSocketExtensionData with name=").append(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,11 +115,12 @@ public class Http2FrameLogger extends ChannelHandlerAdapter {
|
||||
|
||||
private void log(Direction direction, String format, Object... args) {
|
||||
if (logger.isEnabled(level)) {
|
||||
StringBuilder b = new StringBuilder("\n----------------");
|
||||
b.append(direction.name());
|
||||
b.append("--------------------\n");
|
||||
b.append(String.format(format, args));
|
||||
b.append("\n------------------------------------");
|
||||
StringBuilder b = new StringBuilder(200);
|
||||
b.append("\n----------------")
|
||||
.append(direction.name())
|
||||
.append("--------------------\n")
|
||||
.append(String.format(format, args))
|
||||
.append("\n------------------------------------");
|
||||
logger.log(level, b.toString());
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Provides utility methods and constants for the HTTP/2 to HTTP conversion
|
||||
@ -81,6 +82,12 @@ public final class HttpUtil {
|
||||
*/
|
||||
public static final HttpResponseStatus OUT_OF_MESSAGE_SEQUENCE_RETURN_CODE = HttpResponseStatus.OK;
|
||||
|
||||
/**
|
||||
* This pattern will use to avoid compile it each time it is used
|
||||
* when we need to replace some part of authority.
|
||||
*/
|
||||
private static final Pattern AUTHORITY_REPLACEMENT_PATTERN = Pattern.compile("^.*@");
|
||||
|
||||
private HttpUtil() {
|
||||
}
|
||||
|
||||
@ -269,7 +276,7 @@ public final class HttpUtil {
|
||||
// The authority MUST NOT include the deprecated "userinfo" subcomponent
|
||||
value = hostUri.getAuthority();
|
||||
if (value != null) {
|
||||
out.authority(new AsciiString(value.replaceFirst("^.*@", "")));
|
||||
out.authority(new AsciiString(AUTHORITY_REPLACEMENT_PATTERN.matcher(value).replaceFirst("")));
|
||||
}
|
||||
value = hostUri.getScheme();
|
||||
if (value != null) {
|
||||
|
@ -35,9 +35,10 @@ public class MqttConnAckVariableHeader {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("connectReturnCode=").append(connectReturnCode);
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("connectReturnCode=").append(connectReturnCode)
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -64,13 +64,14 @@ public class MqttConnectPayload {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("clientIdentifier=").append(clientIdentifier);
|
||||
builder.append(", willTopic=").append(willTopic);
|
||||
builder.append(", willMessage=").append(willMessage);
|
||||
builder.append(", userName=").append(userName);
|
||||
builder.append(", password=").append(password);
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("clientIdentifier=").append(clientIdentifier)
|
||||
.append(", willTopic=").append(willTopic)
|
||||
.append(", willMessage=").append(willMessage)
|
||||
.append(", userName=").append(userName)
|
||||
.append(", password=").append(password)
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -92,16 +92,17 @@ public class MqttConnectVariableHeader {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("name=").append(name);
|
||||
builder.append(", version=").append(version);
|
||||
builder.append(", hasUserName=").append(hasUserName);
|
||||
builder.append(", hasPassword=").append(hasPassword);
|
||||
builder.append(", isWillRetain=").append(isWillRetain);
|
||||
builder.append(", isWillFlag=").append(isWillFlag);
|
||||
builder.append(", isCleanSession=").append(isCleanSession);
|
||||
builder.append(", keepAliveTimeSeconds=").append(keepAliveTimeSeconds);
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("name=").append(name)
|
||||
.append(", version=").append(version)
|
||||
.append(", hasUserName=").append(hasUserName)
|
||||
.append(", hasPassword=").append(hasPassword)
|
||||
.append(", isWillRetain=").append(isWillRetain)
|
||||
.append(", isWillFlag=").append(isWillFlag)
|
||||
.append(", isCleanSession=").append(isCleanSession)
|
||||
.append(", keepAliveTimeSeconds=").append(keepAliveTimeSeconds)
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -65,13 +65,14 @@ public class MqttFixedHeader {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("messageType=").append(messageType);
|
||||
builder.append(", isDup=").append(isDup);
|
||||
builder.append(", qosLevel=").append(qosLevel);
|
||||
builder.append(", isRetain=").append(isRetain);
|
||||
builder.append(", remainingLength=").append(remainingLength);
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("messageType=").append(messageType)
|
||||
.append(", isDup=").append(isDup)
|
||||
.append(", qosLevel=").append(qosLevel)
|
||||
.append(", isRetain=").append(isRetain)
|
||||
.append(", remainingLength=").append(remainingLength)
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -70,11 +70,12 @@ public class MqttMessage {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("fixedHeader=").append(fixedHeader() != null ? fixedHeader().toString() : "");
|
||||
builder.append(", variableHeader=").append(variableHeader() != null ? variableHeader.toString() : "");
|
||||
builder.append(", payload=").append(payload() != null ? payload.toString() : "");
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("fixedHeader=").append(fixedHeader() != null ? fixedHeader().toString() : "")
|
||||
.append(", variableHeader=").append(variableHeader() != null ? variableHeader.toString() : "")
|
||||
.append(", payload=").append(payload() != null ? payload.toString() : "")
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,10 @@ public final class MqttMessageIdVariableHeader {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("messageId=").append(messageId);
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("messageId=").append(messageId)
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,11 @@ public class MqttPublishVariableHeader {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("topicName=").append(topicName);
|
||||
builder.append(", messageId=").append(messageId);
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("topicName=").append(topicName)
|
||||
.append(", messageId=").append(messageId)
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +61,10 @@ public class MqttSubAckPayload {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("grantedQoSLevels=").append(grantedQoSLevels);
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("grantedQoSLevels=").append(grantedQoSLevels)
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -42,10 +42,11 @@ public class MqttTopicSubscription {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
builder.append("topicFilter=").append(topicFilter);
|
||||
builder.append(", qualityOfService=").append(qualityOfService);
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
return new StringBuilder(StringUtil.simpleClassName(this))
|
||||
.append('[')
|
||||
.append("topicFilter=").append(topicFilter)
|
||||
.append(", qualityOfService=").append(qualityOfService)
|
||||
.append(']')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -40,10 +40,10 @@ public class MqttUnsubscribePayload {
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(StringUtil.simpleClassName(this)).append('[');
|
||||
for (int i = 0; i < topics.size() - 1; i++) {
|
||||
builder.append("topicName = " + topics.get(i)).append(", ");
|
||||
builder.append("topicName = ").append(topics.get(i)).append(", ");
|
||||
}
|
||||
builder.append("topicName = " + topics.get(topics.size() - 1));
|
||||
builder.append(']');
|
||||
builder.append("topicName = ").append(topics.get(topics.size() - 1))
|
||||
.append(']');
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
@ -69,12 +69,11 @@ public class DecoderResult {
|
||||
}
|
||||
|
||||
String cause = cause().toString();
|
||||
StringBuilder buf = new StringBuilder(cause.length() + 17);
|
||||
buf.append("failure(");
|
||||
buf.append(cause);
|
||||
buf.append(')');
|
||||
|
||||
return buf.toString();
|
||||
return new StringBuilder(cause.length() + 17)
|
||||
.append("failure(")
|
||||
.append(cause)
|
||||
.append(')')
|
||||
.toString();
|
||||
} else {
|
||||
return "unfinished";
|
||||
}
|
||||
|
@ -1366,11 +1366,11 @@ public class DefaultHeaders<T> implements Headers<T> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(name);
|
||||
b.append('=');
|
||||
b.append(value);
|
||||
return b.toString();
|
||||
return new StringBuilder()
|
||||
.append(name)
|
||||
.append('=')
|
||||
.append(value)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,12 +111,12 @@ public class DefaultTextHeaders extends DefaultConvertibleHeaders<CharSequence,
|
||||
|
||||
@Override
|
||||
public int convertToInt(CharSequence value) {
|
||||
return Integer.valueOf(value.toString());
|
||||
return Integer.parseInt(value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long convertToLong(CharSequence value) {
|
||||
return Long.valueOf(value.toString());
|
||||
return Long.parseLong(value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -591,17 +591,16 @@ public class HashedWheelTimer implements Timer {
|
||||
final long currentTime = System.nanoTime();
|
||||
long remaining = deadline - currentTime + timer.startTime;
|
||||
|
||||
StringBuilder buf = new StringBuilder(192);
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append('(');
|
||||
|
||||
buf.append("deadline: ");
|
||||
StringBuilder buf = new StringBuilder(192)
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append('(')
|
||||
.append("deadline: ");
|
||||
if (remaining > 0) {
|
||||
buf.append(remaining);
|
||||
buf.append(" ns later");
|
||||
buf.append(remaining)
|
||||
.append(" ns later");
|
||||
} else if (remaining < 0) {
|
||||
buf.append(-remaining);
|
||||
buf.append(" ns ago");
|
||||
buf.append(-remaining)
|
||||
.append(" ns ago");
|
||||
} else {
|
||||
buf.append("now");
|
||||
}
|
||||
@ -610,10 +609,10 @@ public class HashedWheelTimer implements Timer {
|
||||
buf.append(", cancelled");
|
||||
}
|
||||
|
||||
buf.append(", task: ");
|
||||
buf.append(task());
|
||||
|
||||
return buf.append(')').toString();
|
||||
return buf.append(", task: ")
|
||||
.append(task())
|
||||
.append(')')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,27 +309,27 @@ public final class ResourceLeakDetector<T> {
|
||||
array = lastRecords.toArray();
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder(16384);
|
||||
buf.append(NEWLINE);
|
||||
buf.append("Recent access records: ");
|
||||
buf.append(array.length);
|
||||
buf.append(NEWLINE);
|
||||
StringBuilder buf = new StringBuilder(16384)
|
||||
.append(NEWLINE)
|
||||
.append("Recent access records: ")
|
||||
.append(array.length)
|
||||
.append(NEWLINE);
|
||||
|
||||
if (array.length > 0) {
|
||||
for (int i = array.length - 1; i >= 0; i --) {
|
||||
buf.append('#');
|
||||
buf.append(i + 1);
|
||||
buf.append(':');
|
||||
buf.append(NEWLINE);
|
||||
buf.append(array[i]);
|
||||
buf.append('#')
|
||||
.append(i + 1)
|
||||
.append(':')
|
||||
.append(NEWLINE)
|
||||
.append(array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
buf.append("Created at:");
|
||||
buf.append(NEWLINE);
|
||||
buf.append(creationRecord);
|
||||
buf.setLength(buf.length() - NEWLINE.length());
|
||||
buf.append("Created at:")
|
||||
.append(NEWLINE)
|
||||
.append(creationRecord);
|
||||
|
||||
buf.setLength(buf.length() - NEWLINE.length());
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
@ -806,10 +806,10 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
|
||||
}
|
||||
|
||||
protected StringBuilder toStringBuilder() {
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append('@');
|
||||
buf.append(Integer.toHexString(hashCode()));
|
||||
StringBuilder buf = new StringBuilder(64)
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append('@')
|
||||
.append(Integer.toHexString(hashCode()));
|
||||
|
||||
Object result = this.result;
|
||||
if (result == SUCCESS) {
|
||||
@ -817,9 +817,9 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
|
||||
} else if (result == UNCANCELLABLE) {
|
||||
buf.append("(uncancellable)");
|
||||
} else if (result instanceof CauseHolder) {
|
||||
buf.append("(failure(");
|
||||
buf.append(((CauseHolder) result).cause);
|
||||
buf.append(')');
|
||||
buf.append("(failure(")
|
||||
.append(((CauseHolder) result).cause)
|
||||
.append(')');
|
||||
} else {
|
||||
buf.append("(incomplete)");
|
||||
}
|
||||
|
@ -129,9 +129,9 @@ class PromiseTask<V> extends DefaultPromise<V> implements RunnableFuture<V> {
|
||||
protected StringBuilder toStringBuilder() {
|
||||
StringBuilder buf = super.toStringBuilder();
|
||||
buf.setCharAt(buf.length() - 1, ',');
|
||||
buf.append(" task: ");
|
||||
buf.append(task);
|
||||
buf.append(')');
|
||||
return buf;
|
||||
|
||||
return buf.append(" task: ")
|
||||
.append(task)
|
||||
.append(')');
|
||||
}
|
||||
}
|
||||
|
@ -153,14 +153,14 @@ final class ScheduledFutureTask<V> extends PromiseTask<V> implements ScheduledFu
|
||||
protected StringBuilder toStringBuilder() {
|
||||
StringBuilder buf = super.toStringBuilder();
|
||||
buf.setCharAt(buf.length() - 1, ',');
|
||||
buf.append(" id: ");
|
||||
buf.append(id);
|
||||
buf.append(", deadline: ");
|
||||
buf.append(deadlineNanos);
|
||||
buf.append(", period: ");
|
||||
buf.append(periodNanos);
|
||||
buf.append(')');
|
||||
return buf;
|
||||
|
||||
return buf.append(" id: ")
|
||||
.append(id)
|
||||
.append(", deadline: ")
|
||||
.append(deadlineNanos)
|
||||
.append(", period: ")
|
||||
.append(periodNanos)
|
||||
.append(')');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -240,7 +240,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
|
||||
throw new Error(e);
|
||||
}
|
||||
|
||||
if (!uri.startsWith("/")) {
|
||||
if (uri.isEmpty() || uri.charAt(0) != '/') {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
|
||||
// You will have to do something serious in the production environment.
|
||||
if (uri.contains(File.separator + '.') ||
|
||||
uri.contains('.' + File.separator) ||
|
||||
uri.startsWith(".") || uri.endsWith(".") ||
|
||||
uri.charAt(0) == '.' || uri.charAt(uri.length() - 1) == '.' ||
|
||||
INSECURE_URI.matcher(uri).matches()) {
|
||||
return null;
|
||||
}
|
||||
@ -266,21 +266,20 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
|
||||
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK);
|
||||
response.headers().set(CONTENT_TYPE, "text/html; charset=UTF-8");
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
String dirPath = dir.getPath();
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append("<!DOCTYPE html>\r\n")
|
||||
.append("<html><head><title>")
|
||||
.append("Listing of: ")
|
||||
.append(dirPath)
|
||||
.append("</title></head><body>\r\n")
|
||||
|
||||
buf.append("<!DOCTYPE html>\r\n");
|
||||
buf.append("<html><head><title>");
|
||||
buf.append("Listing of: ");
|
||||
buf.append(dirPath);
|
||||
buf.append("</title></head><body>\r\n");
|
||||
.append("<h3>Listing of: ")
|
||||
.append(dirPath)
|
||||
.append("</h3>\r\n")
|
||||
|
||||
buf.append("<h3>Listing of: ");
|
||||
buf.append(dirPath);
|
||||
buf.append("</h3>\r\n");
|
||||
|
||||
buf.append("<ul>");
|
||||
buf.append("<li><a href=\"../\">..</a></li>\r\n");
|
||||
.append("<ul>")
|
||||
.append("<li><a href=\"../\">..</a></li>\r\n");
|
||||
|
||||
for (File f: dir.listFiles()) {
|
||||
if (f.isHidden() || !f.canRead()) {
|
||||
@ -292,11 +291,11 @@ public class HttpStaticFileServerHandler extends SimpleChannelInboundHandler<Ful
|
||||
continue;
|
||||
}
|
||||
|
||||
buf.append("<li><a href=\"");
|
||||
buf.append(name);
|
||||
buf.append("\">");
|
||||
buf.append(name);
|
||||
buf.append("</a></li>\r\n");
|
||||
buf.append("<li><a href=\"")
|
||||
.append(name)
|
||||
.append("\">")
|
||||
.append(name)
|
||||
.append("</a></li>\r\n");
|
||||
}
|
||||
|
||||
buf.append("</ul></body></html>\r\n");
|
||||
|
@ -66,9 +66,13 @@ public class SpdyFrameLogger extends ChannelHandlerAdapter {
|
||||
|
||||
private void log(SpdyFrame msg, Direction d) {
|
||||
if (logger.isEnabled(level)) {
|
||||
StringBuilder b = new StringBuilder("\n----------------").append(d.name()).append("--------------------\n");
|
||||
b.append(msg);
|
||||
b.append("\n------------------------------------");
|
||||
StringBuilder b = new StringBuilder(200)
|
||||
.append("\n----------------")
|
||||
.append(d.name())
|
||||
.append("--------------------\n")
|
||||
.append(msg)
|
||||
.append("\n------------------------------------");
|
||||
|
||||
logger.log(level, b.toString());
|
||||
}
|
||||
}
|
||||
|
@ -88,17 +88,17 @@ public final class ProxyConnectionEvent {
|
||||
return strVal;
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append('(');
|
||||
buf.append(protocol);
|
||||
buf.append(", ");
|
||||
buf.append(authScheme);
|
||||
buf.append(", ");
|
||||
buf.append(proxyAddress);
|
||||
buf.append(" => ");
|
||||
buf.append(destinationAddress);
|
||||
buf.append(')');
|
||||
StringBuilder buf = new StringBuilder(128)
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append('(')
|
||||
.append(protocol)
|
||||
.append(", ")
|
||||
.append(authScheme)
|
||||
.append(", ")
|
||||
.append(proxyAddress)
|
||||
.append(" => ")
|
||||
.append(destinationAddress)
|
||||
.append(')');
|
||||
|
||||
return strVal = buf.toString();
|
||||
}
|
||||
|
@ -365,18 +365,16 @@ public abstract class ProxyHandler extends ChannelHandlerAdapter {
|
||||
msg = "";
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder(128 + msg.length());
|
||||
|
||||
buf.append(protocol());
|
||||
buf.append(", ");
|
||||
buf.append(authScheme());
|
||||
buf.append(", ");
|
||||
buf.append(proxyAddress);
|
||||
buf.append(" => ");
|
||||
buf.append(destinationAddress);
|
||||
if (msg.length() > 0) {
|
||||
buf.append(", ");
|
||||
buf.append(msg);
|
||||
StringBuilder buf = new StringBuilder(128 + msg.length())
|
||||
.append(protocol())
|
||||
.append(", ")
|
||||
.append(authScheme())
|
||||
.append(", ")
|
||||
.append(proxyAddress)
|
||||
.append(" => ")
|
||||
.append(destinationAddress);
|
||||
if (!msg.isEmpty()) {
|
||||
buf.append(", ").append(msg);
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
|
@ -308,11 +308,11 @@ public class LoggingHandler extends ChannelHandlerAdapter {
|
||||
*/
|
||||
protected String format(ChannelHandlerContext ctx, String eventName) {
|
||||
String chStr = ctx.channel().toString();
|
||||
StringBuilder buf = new StringBuilder(chStr.length() + 1 + eventName.length());
|
||||
buf.append(chStr);
|
||||
buf.append(' ');
|
||||
buf.append(eventName);
|
||||
return buf.toString();
|
||||
return new StringBuilder(chStr.length() + 1 + eventName.length())
|
||||
.append(chStr)
|
||||
.append(' ')
|
||||
.append(eventName)
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -391,8 +391,8 @@ public class LoggingHandler extends ChannelHandlerAdapter {
|
||||
StringBuilder buf = new StringBuilder(
|
||||
chStr.length() + 1 + eventName.length() + 2 + msgStr.length() + 2 + 10 + 1 + 2 + rows * 80);
|
||||
|
||||
buf.append(chStr).append(' ').append(eventName).append(": ");
|
||||
buf.append(msgStr).append(", ").append(length).append('B');
|
||||
buf.append(chStr).append(' ').append(eventName).append(": ")
|
||||
.append(msgStr).append(", ").append(length).append('B');
|
||||
appendHexDump(buf, content);
|
||||
|
||||
return buf.toString();
|
||||
|
@ -302,10 +302,10 @@ public class LoggingHandlerTest {
|
||||
|
||||
@Override
|
||||
public void appendTo(StringBuffer buffer) {
|
||||
buffer.append("matchesLog(");
|
||||
buffer.append("expected: \"" + expected);
|
||||
buffer.append("\", got: \"" + actualMsg);
|
||||
buffer.append("\")");
|
||||
buffer.append("matchesLog(")
|
||||
.append("expected: \"").append(expected)
|
||||
.append("\", got: \"").append(actualMsg)
|
||||
.append("\")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,11 +191,11 @@ public final class UnitHelp {
|
||||
* Display current OS/ARCH.
|
||||
*/
|
||||
public static void logOsArch() {
|
||||
final StringBuilder text = new StringBuilder(1024);
|
||||
text.append("\n\t");
|
||||
text.append(System.getProperty("os.name"));
|
||||
text.append("\n\t");
|
||||
text.append(System.getProperty("os.arch"));
|
||||
final StringBuilder text = new StringBuilder(1024)
|
||||
.append("\n\t")
|
||||
.append(System.getProperty("os.name"))
|
||||
.append("\n\t")
|
||||
.append(System.getProperty("os.arch"));
|
||||
log.info("\n\t[os/arch]{}", text);
|
||||
}
|
||||
|
||||
|
@ -406,42 +406,42 @@ public abstract class AbstractBootstrap<B extends AbstractBootstrap<B, C>, C ext
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append('(');
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append('(');
|
||||
if (group != null) {
|
||||
buf.append("group: ");
|
||||
buf.append(StringUtil.simpleClassName(group));
|
||||
buf.append(", ");
|
||||
buf.append("group: ")
|
||||
.append(StringUtil.simpleClassName(group))
|
||||
.append(", ");
|
||||
}
|
||||
if (channelFactory != null) {
|
||||
buf.append("channelFactory: ");
|
||||
buf.append(channelFactory);
|
||||
buf.append(", ");
|
||||
buf.append("channelFactory: ")
|
||||
.append(channelFactory)
|
||||
.append(", ");
|
||||
}
|
||||
if (localAddress != null) {
|
||||
buf.append("localAddress: ");
|
||||
buf.append(localAddress);
|
||||
buf.append(", ");
|
||||
buf.append("localAddress: ")
|
||||
.append(localAddress)
|
||||
.append(", ");
|
||||
}
|
||||
synchronized (options) {
|
||||
if (!options.isEmpty()) {
|
||||
buf.append("options: ");
|
||||
buf.append(options);
|
||||
buf.append(", ");
|
||||
buf.append("options: ")
|
||||
.append(options)
|
||||
.append(", ");
|
||||
}
|
||||
}
|
||||
synchronized (attrs) {
|
||||
if (!attrs.isEmpty()) {
|
||||
buf.append("attrs: ");
|
||||
buf.append(attrs);
|
||||
buf.append(", ");
|
||||
buf.append("attrs: ")
|
||||
.append(attrs)
|
||||
.append(", ");
|
||||
}
|
||||
}
|
||||
if (handler != null) {
|
||||
buf.append("handler: ");
|
||||
buf.append(handler);
|
||||
buf.append(", ");
|
||||
buf.append("handler: ")
|
||||
.append(handler)
|
||||
.append(", ");
|
||||
}
|
||||
if (buf.charAt(buf.length() - 1) == '(') {
|
||||
buf.append(')');
|
||||
|
@ -288,10 +288,10 @@ public class Bootstrap extends AbstractBootstrap<Bootstrap, Channel> {
|
||||
|
||||
StringBuilder buf = new StringBuilder(super.toString());
|
||||
buf.setLength(buf.length() - 1);
|
||||
buf.append(", remoteAddress: ");
|
||||
buf.append(remoteAddress);
|
||||
buf.append(')');
|
||||
|
||||
return buf.toString();
|
||||
return buf.append(", remoteAddress: ")
|
||||
.append(remoteAddress)
|
||||
.append(')')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -374,28 +374,28 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
dstAddr = localAddr;
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder(96);
|
||||
buf.append("[id: 0x");
|
||||
buf.append(id.asShortText());
|
||||
buf.append(", ");
|
||||
buf.append(srcAddr);
|
||||
buf.append(active? " => " : " :> ");
|
||||
buf.append(dstAddr);
|
||||
buf.append(']');
|
||||
StringBuilder buf = new StringBuilder(96)
|
||||
.append("[id: 0x")
|
||||
.append(id.asShortText())
|
||||
.append(", ")
|
||||
.append(srcAddr)
|
||||
.append(active? " => " : " :> ")
|
||||
.append(dstAddr)
|
||||
.append(']');
|
||||
strVal = buf.toString();
|
||||
} else if (localAddr != null) {
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append("[id: 0x");
|
||||
buf.append(id.asShortText());
|
||||
buf.append(", ");
|
||||
buf.append(localAddr);
|
||||
buf.append(']');
|
||||
StringBuilder buf = new StringBuilder(64)
|
||||
.append("[id: 0x")
|
||||
.append(id.asShortText())
|
||||
.append(", ")
|
||||
.append(localAddr)
|
||||
.append(']');
|
||||
strVal = buf.toString();
|
||||
} else {
|
||||
StringBuilder buf = new StringBuilder(16);
|
||||
buf.append("[id: 0x");
|
||||
buf.append(id.asShortText());
|
||||
buf.append(']');
|
||||
StringBuilder buf = new StringBuilder(16)
|
||||
.append("[id: 0x")
|
||||
.append(id.asShortText())
|
||||
.append(']');
|
||||
strVal = buf.toString();
|
||||
}
|
||||
|
||||
|
@ -811,20 +811,20 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(StringUtil.simpleClassName(this));
|
||||
buf.append('{');
|
||||
StringBuilder buf = new StringBuilder()
|
||||
.append(StringUtil.simpleClassName(this))
|
||||
.append('{');
|
||||
AbstractChannelHandlerContext ctx = head.next;
|
||||
for (;;) {
|
||||
if (ctx == tail) {
|
||||
break;
|
||||
}
|
||||
|
||||
buf.append('(');
|
||||
buf.append(ctx.name());
|
||||
buf.append(" = ");
|
||||
buf.append(ctx.handler().getClass().getName());
|
||||
buf.append(')');
|
||||
buf.append('(')
|
||||
.append(ctx.name())
|
||||
.append(" = ")
|
||||
.append(ctx.handler().getClass().getName())
|
||||
.append(')');
|
||||
|
||||
ctx = ctx.next;
|
||||
if (ctx == tail) {
|
||||
|
Loading…
Reference in New Issue
Block a user