Skip to content

Commit

Permalink
Modified to lower camel case (#3003)
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyHZM authored and ralf0131 committed Jan 16, 2019
1 parent 0e0fbd5 commit 66afe96
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public static Object newInstance(String name) {

public static Class<?> forName(String[] packages, String className) {
try {
return _forName(className);
return classForName(className);
} catch (ClassNotFoundException e) {
if (packages != null && packages.length > 0) {
for (String pkg : packages) {
try {
return _forName(pkg + "." + className);
return classForName(pkg + "." + className);
} catch (ClassNotFoundException e2) {
}
}
Expand All @@ -72,13 +72,13 @@ public static Class<?> forName(String[] packages, String className) {

public static Class<?> forName(String className) {
try {
return _forName(className);
return classForName(className);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}

public static Class<?> _forName(String className) throws ClassNotFoundException {
public static Class<?> classForName(String className) throws ClassNotFoundException {
switch (className) {
case "boolean":
return boolean.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public void run() {

SimpleDateFormat sdf;

String OS = System.getProperty("os.name").toLowerCase();
String os = System.getProperty("os.name").toLowerCase();

// window system don't support ":" in file name
if(OS.contains("win")){
if(os.contains("win")){
sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
}else {
sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpRequest msg) throws E
// return 404 when fail to construct command context
if (commandContext == null) {
log.warn("can not found commandContext url: " + msg.getUri());
FullHttpResponse response = http_404();
FullHttpResponse response = http404();
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} else {
commandContext.setRemote(ctx.channel());
try {
String result = commandExecutor.execute(commandContext);
FullHttpResponse response = http_200(result);
FullHttpResponse response = http200(result);
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} catch (NoSuchCommandException ex) {
log.error("can not find commandContext: " + commandContext, ex);
FullHttpResponse response = http_404();
FullHttpResponse response = http404();
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} catch (Exception qosEx) {
log.error("execute commandContext: " + commandContext + " got exception", qosEx);
FullHttpResponse response = http_500(qosEx.getMessage());
FullHttpResponse response = http500(qosEx.getMessage());
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
}
}

private static final FullHttpResponse http_200(String result) {
private static final FullHttpResponse http200(String result) {
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
Unpooled.wrappedBuffer(result.getBytes()));
HttpHeaders httpHeaders = response.headers();
Expand All @@ -87,15 +87,15 @@ private static final FullHttpResponse http_200(String result) {
return response;
}

private static final FullHttpResponse http_404() {
private static final FullHttpResponse http404() {
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND);
HttpHeaders httpHeaders = response.headers();
httpHeaders.set(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
httpHeaders.set(HttpHeaders.Names.CONTENT_LENGTH, response.content().readableBytes());
return response;
}

private static final FullHttpResponse http_500(String errorMessage) {
private static final FullHttpResponse http500(String errorMessage) {
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR
, Unpooled.wrappedBuffer(errorMessage.getBytes()));
HttpHeaders httpHeaders = response.headers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,17 @@ public <T> Invoker<T> refer(Class<T> serviceType, URL url) throws RpcException {

private ExchangeClient[] getClients(URL url) {
// whether to share connection
boolean service_share_connect = false;
boolean serviceShareConnect = false;
int connections = url.getParameter(Constants.CONNECTIONS_KEY, 0);
// if not configured, connection is shared, otherwise, one connection for one service
if (connections == 0) {
service_share_connect = true;
serviceShareConnect = true;
connections = 1;
}

ExchangeClient[] clients = new ExchangeClient[connections];
for (int i = 0; i < clients.length; i++) {
if (service_share_connect) {
if (serviceShareConnect) {
clients[i] = getSharedClient(url);
} else {
clients[i] = initClient(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ public String telnet(Channel channel, String message) {
if (!StringUtils.isInteger(str[0])) {
LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
} else {
int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);
int showLogLength = Integer.parseInt(str[0]);

if (file != null && file.exists()) {
try {
FileInputStream fis = new FileInputStream(file);
FileChannel filechannel = fis.getChannel();
size = filechannel.size();
ByteBuffer bb;
if (size <= SHOW_LOG_LENGTH) {
if (size <= showLogLength) {
bb = ByteBuffer.allocate((int) size);
filechannel.read(bb, 0);
} else {
int pos = (int) (size - SHOW_LOG_LENGTH);
bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
int pos = (int) (size - showLogLength);
bb = ByteBuffer.allocate(showLogLength);
filechannel.read(bb, pos);
}
bb.flip();
Expand Down

0 comments on commit 66afe96

Please sign in to comment.