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