Use 'x' over "x" wherever possible / String.equals("") -> isEmpty()

This commit is contained in:
Trustin Lee 2012-11-10 08:03:52 +09:00
parent 05c416b674
commit b4f796c5e3
44 changed files with 87 additions and 85 deletions

View File

@ -1217,7 +1217,7 @@ public class DefaultCompositeByteBuf extends AbstractByteBuf implements Composit
public String toString() {
String result = super.toString();
result = result.substring(0, result.length() - 1);
return result + ", components=" + components.size() + ")";
return result + ", components=" + components.size() + ')';
}
private static final class Component {

View File

@ -1245,7 +1245,7 @@ public class HttpHeaders {
@Override
public String toString() {
return key + "=" + value;
return key + '=' + value;
}
}
}

View File

@ -163,7 +163,7 @@ public class QueryStringDecoder {
hasPath = false;
}
// Also take care of cut of things like "http://localhost"
String newUri = rawPath + "?" + uri.getRawQuery();
String newUri = rawPath + '?' + uri.getRawQuery();
// http://en.wikipedia.org/wiki/Query_string
this.uri = newUri.replace(';', '&');

View File

@ -100,14 +100,14 @@ public class QueryStringEncoder {
if (params.isEmpty()) {
return uri;
} else {
StringBuilder sb = new StringBuilder(uri).append("?");
StringBuilder sb = new StringBuilder(uri).append('?');
for (int i = 0; i < params.size(); i++) {
Param param = params.get(i);
sb.append(encodeComponent(param.name, charset));
sb.append("=");
sb.append('=');
sb.append(encodeComponent(param.value, charset));
if (i != params.size() - 1) {
sb.append("&");
sb.append('&');
}
}
return sb.toString();

View File

@ -15,7 +15,6 @@
*/
package io.netty.handler.codec.http.multipart;
import static io.netty.buffer.Unpooled.*;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.HttpConstants;
@ -28,6 +27,8 @@ import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import static io.netty.buffer.Unpooled.*;
/**
* Abstract Disk HttpData implementation
*/
@ -76,7 +77,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
String newpostfix = null;
String diskFilename = getDiskFilename();
if (diskFilename != null) {
newpostfix = "_" + diskFilename;
newpostfix = '_' + diskFilename;
} else {
newpostfix = getPostfix();
}

View File

@ -15,10 +15,11 @@
*/
package io.netty.handler.codec.http.multipart;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.HttpConstants;
import java.io.IOException;
import static io.netty.buffer.Unpooled.*;
/**
@ -115,7 +116,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
@Override
public String toString() {
try {
return getName() + "=" + getValue();
return getName() + '=' + getValue();
} catch (IOException e) {
return getName() + "=IoException";
}

View File

@ -15,11 +15,11 @@
*/
package io.netty.handler.codec.http.multipart;
import io.netty.handler.codec.http.HttpHeaders;
import java.io.File;
import java.nio.charset.Charset;
import io.netty.handler.codec.http.HttpHeaders;
/**
* Disk FileUpload implementation that stores file into real files
*/
@ -126,7 +126,7 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() +
"\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" +
HttpHeaders.Names.CONTENT_TYPE + ": " + contentType +
(charset != null? "; " + HttpHeaders.Values.CHARSET + "=" + charset + "\r\n" : "\r\n") +
(charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset + "\r\n" : "\r\n") +
HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" +
"Completed: " + isCompleted() +
"\r\nIsInMemory: " + isInMemory() + "\r\nRealFile: " +

View File

@ -706,7 +706,7 @@ public class HttpPostRequestDecoder {
} catch (UnsupportedEncodingException e) {
throw new ErrorDataDecoderException(charset.toString(), e);
} catch (IllegalArgumentException e) {
throw new ErrorDataDecoderException("Bad string: '" + s + "'", e);
throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e);
}
}

View File

@ -454,7 +454,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
Charset localcharset = attribute.getCharset();
if (localcharset != null) {
// Content-Type: charset=charset
internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " + HttpHeaders.Values.CHARSET + "="
internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " + HttpHeaders.Values.CHARSET + '='
+ localcharset + "\r\n");
}
// CRLF between body header and data
@ -524,7 +524,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
+ "; " + HttpPostBodyUtil.NAME + "=\"" + encodeAttribute(fileUpload.getName(), charset)
+ "\"\r\n";
replacement += HttpHeaders.Names.CONTENT_TYPE + ": " + HttpPostBodyUtil.MULTIPART_MIXED + "; "
+ HttpHeaders.Values.BOUNDARY + "=" + multipartMixedBoundary + "\r\n\r\n";
+ HttpHeaders.Values.BOUNDARY + '=' + multipartMixedBoundary + "\r\n\r\n";
replacement += "--" + multipartMixedBoundary + "\r\n";
replacement += HttpPostBodyUtil.CONTENT_DISPOSITION + ": " + HttpPostBodyUtil.FILE + "; "
+ HttpPostBodyUtil.FILENAME + "=\"" + encodeAttribute(fileUpload.getFilename(), charset)
@ -577,7 +577,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
internal.addValue("\r\n" + HttpHeaders.Names.CONTENT_TRANSFER_ENCODING + ": "
+ HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value() + "\r\n\r\n");
} else if (fileUpload.getCharset() != null) {
internal.addValue("; " + HttpHeaders.Values.CHARSET + "=" + fileUpload.getCharset() + "\r\n\r\n");
internal.addValue("; " + HttpHeaders.Values.CHARSET + '=' + fileUpload.getCharset() + "\r\n\r\n");
} else {
internal.addValue("\r\n\r\n");
}
@ -637,7 +637,7 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput<HttpChunk> {
}
}
if (isMultipart) {
String value = HttpHeaders.Values.MULTIPART_FORM_DATA + "; " + HttpHeaders.Values.BOUNDARY + "="
String value = HttpHeaders.Values.MULTIPART_FORM_DATA + "; " + HttpHeaders.Values.BOUNDARY + '='
+ multipartDataBoundary;
request.addHeader(HttpHeaders.Names.CONTENT_TYPE, value);
} else {

View File

@ -103,7 +103,7 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute
@Override
public String toString() {
return getName() + "=" + getValue();
return getName() + '=' + getValue();
}
}

View File

@ -120,7 +120,7 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() +
"\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" +
HttpHeaders.Names.CONTENT_TYPE + ": " + contentType +
(charset != null? "; " + HttpHeaders.Values.CHARSET + "=" + charset + "\r\n" : "\r\n") +
(charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset + "\r\n" : "\r\n") +
HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" +
"Completed: " + isCompleted() +
"\r\nIsInMemory: " + isInMemory();

View File

@ -134,7 +134,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
path = wsURL.getPath() + "?" + wsURL.getQuery();
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
// Format request
@ -148,14 +148,14 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
if (wsPort != 80 && wsPort != 443) {
// if the port is not standard (80/443) its needed to add the port to the header.
// See http://tools.ietf.org/html/rfc6454#section-6.2
originValue = originValue + ":" + wsPort;
originValue = originValue + ':' + wsPort;
}
request.addHeader(Names.ORIGIN, originValue);
request.addHeader(Names.SEC_WEBSOCKET_KEY1, key1);
request.addHeader(Names.SEC_WEBSOCKET_KEY2, key2);
String expectedSubprotocol = getExpectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}
@ -269,7 +269,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
int split = WebSocketUtil.randomNumber(1, key.length() - 1);
String part1 = key.substring(0, split);
String part2 = key.substring(split);
key = part1 + " " + part2;
key = part1 + ' ' + part2;
}
return key;

View File

@ -102,7 +102,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
path = wsURL.getPath() + "?" + wsURL.getQuery();
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
// Get 16 bit nonce and base 64 encode it
@ -130,12 +130,12 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
if (wsPort != 80 && wsPort != 443) {
// if the port is not standard (80/443) its needed to add the port to the header.
// See http://tools.ietf.org/html/rfc6454#section-6.2
originValue = originValue + ":" + wsPort;
originValue = originValue + ':' + wsPort;
}
request.addHeader(Names.SEC_WEBSOCKET_ORIGIN, originValue);
String expectedSubprotocol = getExpectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}

View File

@ -102,7 +102,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
path = wsURL.getPath() + "?" + wsURL.getQuery();
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
// Get 16 bit nonce and base 64 encode it
@ -130,12 +130,12 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
if (wsPort != 80 && wsPort != 443) {
// if the port is not standard (80/443) its needed to add the port to the header.
// See http://tools.ietf.org/html/rfc6454#section-6.2
originValue = originValue + ":" + wsPort;
originValue = originValue + ':' + wsPort;
}
request.addHeader(Names.SEC_WEBSOCKET_ORIGIN, originValue);
String expectedSubprotocol = getExpectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}

View File

@ -134,7 +134,7 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
Setting setting = e.getValue();
buf.append("--> ");
buf.append(e.getKey().toString());
buf.append(":");
buf.append(':');
buf.append(setting.getValue());
buf.append(" (persist value: ");
buf.append(setting.isPersist());

View File

@ -760,7 +760,7 @@ public class SpdyHeaders {
@Override
public String toString() {
return key + "=" + value;
return key + '=' + value;
}
}
}

View File

@ -65,7 +65,7 @@ public class HttpServerCodecTest {
private static ByteBuf prepareDataChunk(int size) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; ++i) {
sb.append("a");
sb.append('a');
}
return Unpooled.copiedBuffer(sb.toString(), CharsetUtil.UTF_8);
}

View File

@ -429,7 +429,7 @@ public abstract class ReplayingDecoder<O, S> extends ByteToMessageDecoder<O> {
throw new IllegalStateException(
"decode() method must consume at least one byte " +
"if it returned a decoded message (caused by: " +
getClass() + ")");
getClass() + ')');
}
// A successful decode

View File

@ -28,7 +28,7 @@ final class ZlibUtil {
}
static CompressionException exception(ZStream z, String message, int resultCode) {
return new CompressionException(message + " (" + resultCode + ")" +
return new CompressionException(message + " (" + resultCode + ')' +
(z.msg != null? ": " + z.msg : ""));
}

View File

@ -15,26 +15,26 @@
*/
package io.netty.handler.codec.marshalling;
import static org.junit.Assert.*;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.embedded.EmbeddedByteChannel;
import io.netty.handler.codec.CodecException;
import io.netty.handler.codec.TooLongFrameException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import junit.framework.Assert;
import org.jboss.marshalling.Marshaller;
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import static org.junit.Assert.*;
public abstract class AbstractCompatibleMarshallingDecoderTest {
@SuppressWarnings("RedundantStringConstructorCall")
private final String testObject = new String("test");
@Test

View File

@ -18,21 +18,20 @@ package io.netty.handler.codec.marshalling;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.embedded.EmbeddedByteChannel;
import java.io.IOException;
import junit.framework.Assert;
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.marshalling.Unmarshaller;
import org.junit.Test;
import java.io.IOException;
public abstract class AbstractCompatibleMarshallingEncoderTest {
@Test
public void testMarshalling() throws IOException, ClassNotFoundException {
@SuppressWarnings("RedundantStringConstructorCall")
String testObject = new String("test");
final MarshallerFactory marshallerFactory = createMarshallerFactory();

View File

@ -31,7 +31,7 @@ class OsgiLogger extends AbstractInternalLogger {
this.parent = parent;
this.name = name;
this.fallback = fallback;
prefix = "[" + name + "] ";
prefix = '[' + name + "] ";
}
@Override

View File

@ -251,7 +251,7 @@ public final class MonitorName {
*/
@Override
public String toString() {
return instance != null ? "Monitor(" + group + "/" + type + "/" + name + "/" + instance + ")" : "Monitor("
+ group + "/" + type + "/" + name + ")";
return instance != null ? "Monitor(" + group + '/' + type + '/' + name + '/' + instance + ')' : "Monitor("
+ group + '/' + type + '/' + name + ')';
}
}

View File

@ -107,6 +107,6 @@ public final class MonitorProvider implements Serializable, Comparable<MonitorPr
*/
@Override
public String toString() {
return "MonitorProvider(" + name + ")";
return "MonitorProvider(" + name + ')';
}
}

View File

@ -631,7 +631,7 @@ public class HashedWheelTimer implements Timer {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
TimerTask.class.getSimpleName() + ".", t);
TimerTask.class.getSimpleName() + '.', t);
}
}

View File

@ -143,7 +143,7 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
// Cache Validation
String ifModifiedSince = request.getHeader(IF_MODIFIED_SINCE);
if (ifModifiedSince != null && !ifModifiedSince.equals("")) {
if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
Date ifModifiedSinceDate = dateFormatter.parse(ifModifiedSince);
@ -218,8 +218,8 @@ public class HttpStaticFileServerHandler extends ChannelInboundMessageHandlerAda
// Simplistic dumb security check.
// You will have to do something serious in the production environment.
if (uri.contains(File.separator + ".") ||
uri.contains("." + File.separator) ||
if (uri.contains(File.separator + '.') ||
uri.contains('.' + File.separator) ||
uri.startsWith(".") || uri.endsWith(".") ||
INSECURE_URI.matcher(uri).matches()) {
return null;

View File

@ -181,7 +181,7 @@ public class HttpUploadClient {
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uriGet.toASCIIString());
request.setHeader(HttpHeaders.Names.HOST, host);
request.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
request.setHeader(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP + ","
request.setHeader(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP + ','
+ HttpHeaders.Values.DEFLATE);
request.setHeader(HttpHeaders.Names.ACCEPT_CHARSET, "ISO-8859-1,utf-8;q=0.7,*;q=0.7");

View File

@ -121,7 +121,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
// new method
List<Entry<String, String>> headers = request.getHeaders();
for (Entry<String, String> entry : headers) {
responseContent.append("HEADER: " + entry.getKey() + "=" + entry.getValue() + "\r\n");
responseContent.append("HEADER: " + entry.getKey() + '=' + entry.getValue() + "\r\n");
}
responseContent.append("\r\n\r\n");
@ -142,7 +142,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
Map<String, List<String>> uriAttributes = decoderQuery.getParameters();
for (Entry<String, List<String>> attr: uriAttributes.entrySet()) {
for (String attrVal: attr.getValue()) {
responseContent.append("URI: " + attr.getKey() + "=" + attrVal + "\r\n");
responseContent.append("URI: " + attr.getKey() + '=' + attrVal + "\r\n");
}
}
responseContent.append("\r\n\r\n");
@ -189,7 +189,7 @@ public class HttpUploadServerHandler extends ChannelInboundMessageHandlerAdapter
ctx.channel().close();
return;
}
responseContent.append("o");
responseContent.append('o');
// example of reading chunk by chunk (minimize memory usage due to
// Factory)
readHttpDataChunkByChunk(ctx.channel());

View File

@ -90,7 +90,7 @@ public class WebSocketClientHandler extends ChannelInboundMessageHandlerAdapter<
if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg;
throw new Exception("Unexpected HttpResponse (status=" + response.getStatus() + ", content="
+ response.getContent().toString(CharsetUtil.UTF_8) + ")");
+ response.getContent().toString(CharsetUtil.UTF_8) + ')');
}
WebSocketFrame frame = (WebSocketFrame) msg;

View File

@ -34,7 +34,7 @@ public final class WebSocketServerIndexPage {
"var socket;" + NEWLINE +
"if (!window.WebSocket) {" + NEWLINE +
" window.WebSocket = window.MozWebSocket;" + NEWLINE +
"}" + NEWLINE +
'}' + NEWLINE +
"if (window.WebSocket) {" + NEWLINE +
" socket = new WebSocket(\"" + webSocketLocation + "\");" + NEWLINE +
" socket.onmessage = function(event) {" + NEWLINE +
@ -51,7 +51,7 @@ public final class WebSocketServerIndexPage {
" };" + NEWLINE +
"} else {" + NEWLINE +
" alert(\"Your browser does not support Web Socket.\");" + NEWLINE +
"}" + NEWLINE +
'}' + NEWLINE +
NEWLINE +
"function send(message) {" + NEWLINE +
" if (!window.WebSocket) { return; }" + NEWLINE +
@ -60,7 +60,7 @@ public final class WebSocketServerIndexPage {
" } else {" + NEWLINE +
" alert(\"The socket is not open.\");" + NEWLINE +
" }" + NEWLINE +
"}" + NEWLINE +
'}' + NEWLINE +
"</script>" + NEWLINE +
"<form onsubmit=\"return false;\">" + NEWLINE +
"<input type=\"text\" name=\"message\" value=\"Hello, World!\"/>" +

View File

@ -108,7 +108,7 @@ public class LocalTimeClient {
List<String> cities = new ArrayList<String>();
for (int i = offset; i < args.length; i ++) {
if (!CITY_PATTERN.matcher(args[i]).matches()) {
System.err.println("Syntax error: '" + args[i] + "'");
System.err.println("Syntax error: '" + args[i] + '\'');
printUsage();
return null;
}

View File

@ -77,7 +77,7 @@ public class UptimeClientHandler extends ChannelInboundByteHandlerAdapter {
@Override
public void channelUnregistered(final ChannelHandlerContext ctx)
throws Exception {
println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + "s");
println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + 's');
final EventLoop loop = ctx.channel().eventLoop();
loop.schedule(new Runnable() {

View File

@ -84,6 +84,6 @@ class YammerCounterMonitor implements CounterMonitor {
*/
@Override
public String toString() {
return "YammerCounterMonitor(delegate=" + delegate + ")";
return "YammerCounterMonitor(delegate=" + delegate + ')';
}
}

View File

@ -62,6 +62,6 @@ class YammerEventRateMonitor implements EventRateMonitor {
*/
@Override
public String toString() {
return "YammerEventRateMonitor(delegate=" + delegate + ")";
return "YammerEventRateMonitor(delegate=" + delegate + ')';
}
}

View File

@ -117,6 +117,6 @@ public final class YammerMonitorRegistry implements MonitorRegistry {
*/
@Override
public String toString() {
return "YammerMonitorRegistry(delegate=" + delegate + ")";
return "YammerMonitorRegistry(delegate=" + delegate + ')';
}
}

View File

@ -60,6 +60,6 @@ final class YammerValueDistributionMonitor implements ValueDistributionMonitor {
*/
@Override
public String toString() {
return "YammerEventDistributionMonitor(delegate=" + delegate + ")";
return "YammerEventDistributionMonitor(delegate=" + delegate + ')';
}
}

View File

@ -71,6 +71,6 @@ public class YammerMonitorRegistryFactory implements MonitorRegistryFactory {
*/
@Override
public String toString() {
return "YammerMonitorRegistryFactory(metricsRegistry=" + metricsRegistry + ")";
return "YammerMonitorRegistryFactory(metricsRegistry=" + metricsRegistry + ')';
}
}

View File

@ -15,7 +15,6 @@
*/
package io.netty.channel;
import static java.util.concurrent.TimeUnit.*;
import io.netty.channel.ChannelFlushFutureNotifier.FlushCheckpoint;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
@ -28,6 +27,8 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import static java.util.concurrent.TimeUnit.*;
/**
* The default {@link ChannelFuture} implementation. It is recommended to
* use {@link Channels#future(Channel)} and {@link Channels#future(Channel, boolean)}
@ -492,7 +493,7 @@ public class DefaultChannelFuture extends FlushCheckpoint implements ChannelFutu
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
ChannelFutureListener.class.getSimpleName() + ".", t);
ChannelFutureListener.class.getSimpleName() + '.', t);
}
}
}
@ -534,7 +535,7 @@ public class DefaultChannelFuture extends FlushCheckpoint implements ChannelFutu
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
ChannelFutureProgressListener.class.getSimpleName() + ".", t);
ChannelFutureProgressListener.class.getSimpleName() + '.', t);
}
}
}

View File

@ -370,7 +370,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
ChannelFutureListener.class.getSimpleName() + ".", t);
ChannelFutureListener.class.getSimpleName() + '.', t);
}
}
}

View File

@ -15,7 +15,6 @@
*/
package io.netty.channel.socket;
import static io.netty.channel.ChannelOption.*;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelOption;
import io.netty.channel.DefaultChannelConfig;
@ -31,6 +30,8 @@ import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Map;
import static io.netty.channel.ChannelOption.*;
/**
* The default {@link DatagramChannelConfig} implementation.
*/
@ -151,7 +152,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig implement
"A non-root user can't receive a broadcast packet if the socket " +
"is not bound to a wildcard address; setting the SO_BROADCAST flag " +
"anyway as requested on the socket which is bound to " +
socket.getLocalSocketAddress() + ".");
socket.getLocalSocketAddress() + '.');
}
socket.setBroadcast(broadcast);

View File

@ -111,7 +111,7 @@ public final class NioEventLoop extends SingleThreadEventLoop {
}
if ((interestOps & ~ch.validOps()) != 0) {
throw new IllegalArgumentException(
"invalid interestOps: " + interestOps + "(validOps: " + ch.validOps() + ")");
"invalid interestOps: " + interestOps + "(validOps: " + ch.validOps() + ')');
}
if (task == null) {
throw new NullPointerException("task");

View File

@ -48,7 +48,7 @@ final class SelectorUtil {
}
} catch (SecurityException e) {
if (logger.isDebugEnabled()) {
logger.debug("Unable to get/set System Property '" + key + "'", e);
logger.debug("Unable to get/set System Property '" + key + '\'', e);
}
}
if (logger.isDebugEnabled()) {

View File

@ -32,6 +32,10 @@ import io.netty.channel.ChannelOutboundMessageHandler;
import io.netty.channel.DefaultEventExecutorGroup;
import io.netty.channel.EventExecutorGroup;
import io.netty.channel.EventLoopGroup;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.HashSet;
import java.util.Queue;
@ -43,11 +47,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
public class LocalTransportThreadModelTest {
private static ServerBootstrap sb;
@ -369,7 +368,7 @@ public class LocalTransportThreadModelTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
exception.compareAndSet(null, cause);
System.err.print("[" + Thread.currentThread().getName() + "] ");
System.err.print('[' + Thread.currentThread().getName() + "] ");
cause.printStackTrace();
super.exceptionCaught(ctx, cause);
}
@ -604,7 +603,7 @@ public class LocalTransportThreadModelTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
exception.compareAndSet(null, cause);
System.err.print("[" + Thread.currentThread().getName() + "] ");
System.err.print('[' + Thread.currentThread().getName() + "] ");
cause.printStackTrace();
super.exceptionCaught(ctx, cause);
}

View File

@ -141,7 +141,7 @@ public class LocalTransportThreadModelTest2 {
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
for (int i = 0; i < messageCountPerRun; i ++) {
lastWriteFuture = ctx.channel().write(name + " " + i);
lastWriteFuture = ctx.channel().write(name + ' ' + i);
}
}