Commit e1d56c3f authored by zengtianlai3's avatar zengtianlai3

2.3.9 异常处理:finally代码块中抛出异常

parent 62b1e32c
...@@ -27,7 +27,6 @@ public class TcpServer { ...@@ -27,7 +27,6 @@ public class TcpServer {
EventLoopGroup bossGroup = new NioEventLoopGroup(4); EventLoopGroup bossGroup = new NioEventLoopGroup(4);
EventLoopGroup workerGroup = new NioEventLoopGroup(4); EventLoopGroup workerGroup = new NioEventLoopGroup(4);
log.debug("Tcp服务,开始监听端口:{}",port); log.debug("Tcp服务,开始监听端口:{}",port);
try {
//创建服务端的启动对象,设置参数 //创建服务端的启动对象,设置参数
ServerBootstrap b = new ServerBootstrap(); ServerBootstrap b = new ServerBootstrap();
//设置两个线程组boosGroup和workerGroup //设置两个线程组boosGroup和workerGroup
...@@ -47,9 +46,7 @@ public class TcpServer { ...@@ -47,9 +46,7 @@ public class TcpServer {
} catch (InterruptedException e) { } catch (InterruptedException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
log.error("Tcp服务异常,端口:{}",port); log.error("Tcp服务异常,端口:{}",port);
} }finally {
} finally {
log.debug("Tcp服务,停止退出"); log.debug("Tcp服务,停止退出");
workerGroup.shutdownGracefully(); workerGroup.shutdownGracefully();
bossGroup.shutdownGracefully(); bossGroup.shutdownGracefully();
......
...@@ -22,7 +22,7 @@ public class ResourceManager { ...@@ -22,7 +22,7 @@ public class ResourceManager {
@Autowired @Autowired
ResourceService resourceService; ResourceService resourceService;
public void downloadDeviceInfoExcle(HttpServletResponse response, int userId){ public void downloadDeviceInfoExcle(HttpServletResponse response, int userId) throws IOException {
OutputStream os = null; OutputStream os = null;
HSSFWorkbook wb = null; HSSFWorkbook wb = null;
try { try {
...@@ -115,16 +115,12 @@ public class ResourceManager { ...@@ -115,16 +115,12 @@ public class ResourceManager {
} catch (IOException e) { } catch (IOException e) {
log.error("Excel表格信息下载异常,{}",e.getMessage()); log.error("Excel表格信息下载异常,{}",e.getMessage());
} finally { } finally {
try {
if (os != null) { if (os != null) {
os.close(); os.close();
} }
if (wb != null) { if (wb != null) {
wb.close(); wb.close();
} }
} catch (IOException e) {
log.error("Excel表格信息下载异常,{}",e.getMessage());
}
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment