Skip to content

Commit

Permalink
代码性能与风格优化
Browse files Browse the repository at this point in the history
  • Loading branch information
naosense committed Aug 6, 2018
1 parent 724f395 commit 366ac28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/pingao/server/HttpRequestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static void send100Continue(ChannelHandlerContext ctx) {

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
LOGGER.error("Error occurs cause", cause);
ctx.close();
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/pingao/server/MarkDownServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ public ChannelFuture start(int port) {
future.syncUninterruptibly();
channel = future.channel();
isRunning = true;
LOGGER.info("Markdown server is running...");
LOGGER.info("Markdown server is running on {} ...", channel.localAddress());
return future;
}

public void destroy() {
channel.close();
channelGroup.close();
group.shutdownGracefully();
LOGGER.info("Server shutdown success");
LOGGER.info("Markdown server shutdown success");
}

public boolean isRunning() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/pingao/server/SocketServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void initChannel(SocketChannel ch) {
});

ChannelFuture f = b.bind().sync();
LOGGER.info("Socket server is running on {} ...", f.channel().localAddress());
f.channel().closeFuture().sync();
} finally {
group.shutdownGracefully().sync();
Expand Down Expand Up @@ -80,9 +81,8 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}

@Override
public void exceptionCaught(ChannelHandlerContext ctx,
Throwable cause) {
cause.printStackTrace();
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
LOGGER.error("Error occurs cause", cause);
ctx.close();
}
}
Expand Down

0 comments on commit 366ac28

Please sign in to comment.