This commit is contained in:
Redkale
2018-04-09 10:12:44 +08:00
parent d3c63bf35a
commit a833f20729
6 changed files with 10 additions and 21 deletions

View File

@@ -22,8 +22,6 @@ import org.redkale.util.*;
*/
public class JsonByteBufferWriter extends JsonWriter {
protected static final Charset UTF8 = Charset.forName("UTF-8");
protected Charset charset;
private final Supplier<ByteBuffer> supplier;
@@ -38,7 +36,7 @@ public class JsonByteBufferWriter extends JsonWriter {
protected JsonByteBufferWriter(boolean tiny, Charset charset, Supplier<ByteBuffer> supplier) {
this.tiny = tiny;
this.charset = UTF8.equals(charset) ? null : charset;
this.charset = StandardCharsets.UTF_8.equals(charset) ? null : charset;
this.supplier = supplier;
}

View File

@@ -28,8 +28,6 @@ import org.redkale.util.*;
*/
public class Context {
private static final Charset UTF8 = Charset.forName("UTF-8");
//服务启动时间
protected final long serverStartTime;
@@ -90,7 +88,7 @@ public class Context {
this.bufferPool = bufferPool;
this.responsePool = responsePool;
this.maxbody = maxbody;
this.charset = UTF8.equals(charset) ? null : charset;
this.charset = StandardCharsets.UTF_8.equals(charset) ? null : charset;
this.address = address;
this.prepare = prepare;
this.resourceFactory = resourceFactory;

View File

@@ -9,7 +9,7 @@ import java.io.*;
import java.net.*;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.charset.Charset;
import java.nio.charset.*;
import java.util.*;
import org.redkale.convert.json.JsonConvert;
import org.redkale.net.*;
@@ -31,8 +31,6 @@ import org.redkale.util.AnyValue.DefaultAnyValue;
*/
public class HttpRequest extends Request<HttpContext> {
protected static final Charset UTF8 = Charset.forName("UTF-8");
public static final String SESSIONID_NAME = "JSESSIONID";
@Comment("Method GET/POST/...")
@@ -340,7 +338,7 @@ public class HttpRequest extends Request<HttpContext> {
* @return 内容
*/
public String getBodyUTF8() {
return array.toString(UTF8);
return array.toString(StandardCharsets.UTF_8);
}
/**
@@ -352,7 +350,7 @@ public class HttpRequest extends Request<HttpContext> {
* @return 内容
*/
public <T> T getBodyJson(java.lang.reflect.Type type) {
String str = array.toString(UTF8);
String str = array.toString(StandardCharsets.UTF_8);
if (str == null || str.isEmpty()) return null;
return context.getJsonConvert().convertFrom(type, str);
}
@@ -367,7 +365,7 @@ public class HttpRequest extends Request<HttpContext> {
* @return 内容
*/
public <T> T getBodyJson(JsonConvert convert, java.lang.reflect.Type type) {
String str = array.toString(UTF8);
String str = array.toString(StandardCharsets.UTF_8);
if (str == null || str.isEmpty()) return null;
return convert.convertFrom(type, str);
}

View File

@@ -26,8 +26,6 @@ public final class MultiContext {
private static final Logger logger = Logger.getLogger(MultiContext.class.getSimpleName());
private static final Charset UTF8 = Charset.forName("UTF-8");
private final String contentType;
private final InputStream in;
@@ -58,7 +56,7 @@ public final class MultiContext {
};
public MultiContext(final Charset charsetName, final String contentType, final DefaultAnyValue params, final InputStream in, String fielnameRegex) {
this.charset = charsetName == null ? UTF8 : charsetName;
this.charset = charsetName == null ? StandardCharsets.UTF_8 : charsetName;
this.contentType = contentType == null ? "" : contentType.trim();
this.parameters = params;
this.boundary = parseBoundary(this.contentType);

View File

@@ -8,7 +8,7 @@ package org.redkale.net.http;
import org.redkale.util.Utility;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.AbstractMap;
import java.util.function.*;
import java.util.logging.*;
@@ -24,8 +24,6 @@ import org.redkale.net.Cryptor;
*/
public final class WebSocketPacket {
private static final Charset UTF_8 = Charset.forName("UTF-8");
static final WebSocketPacket NONE = new WebSocketPacket();
public static final WebSocketPacket DEFAULT_PING_PACKET = new WebSocketPacket(FrameType.PING, new byte[0]);
@@ -480,7 +478,7 @@ public final class WebSocketPacket {
if (this.type == FrameType.TEXT) {
Convert textConvert = webSocket.getTextConvert();
if (textConvert == null) {
this.receiveMessage = new String(this.getReceiveBytes(buffers), UTF_8);
this.receiveMessage = new String(this.getReceiveBytes(buffers), StandardCharsets.UTF_8);
this.receiveType = MessageType.STRING;
} else {
this.receiveMessage = textConvert.convertFrom(webSocket._messageTextType, this.receiveMasker, buffers);

View File

@@ -10,6 +10,7 @@ import java.net.*;
import java.nio.ByteBuffer;
import java.nio.channels.CompletionHandler;
import java.nio.charset.*;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.time.*;
import java.util.*;
import java.util.function.*;
@@ -31,8 +32,6 @@ public final class Utility {
private static final String format = "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS";
private static final Charset UTF_8 = Charset.forName("UTF-8");
private static final char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
/**