Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengtianlai3
ioc_sixiang_license
Commits
e1d56c3f
Commit
e1d56c3f
authored
Jul 07, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.3.9 异常处理:finally代码块中抛出异常
parent
62b1e32c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
32 deletions
+25
-32
TcpServer.java
license/src/main/java/iot/sixiang/license/net/TcpServer.java
+19
-22
ResourceManager.java
...in/java/iot/sixiang/license/resource/ResourceManager.java
+6
-10
No files found.
license/src/main/java/iot/sixiang/license/net/TcpServer.java
View file @
e1d56c3f
...
@@ -27,29 +27,26 @@ public class TcpServer {
...
@@ -27,29 +27,26 @@ 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
);
//创建服务端的启动对象,设置参数
ServerBootstrap
b
=
new
ServerBootstrap
();
//设置两个线程组boosGroup和workerGroup
b
.
group
(
bossGroup
,
workerGroup
)
//设置服务端通道实现类型
.
channel
(
NioServerSocketChannel
.
class
)
// .handler(new LoggingHandler(LogLevel.INFO))
.
childHandler
(
channelInitializer
)
// 设置tcp缓冲区
.
option
(
ChannelOption
.
SO_BACKLOG
,
1024
)
//设置保持活动连接状态
.
childOption
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
ChannelFuture
f
;
try
{
try
{
//创建服务端的启动对象,设置参数
f
=
b
.
bind
(
port
).
sync
();
ServerBootstrap
b
=
new
ServerBootstrap
();
f
.
channel
().
closeFuture
().
sync
();
//设置两个线程组boosGroup和workerGroup
}
catch
(
InterruptedException
e
)
{
b
.
group
(
bossGroup
,
workerGroup
)
// TODO Auto-generated catch block
//设置服务端通道实现类型
log
.
error
(
"Tcp服务异常,端口:{}"
,
port
);
.
channel
(
NioServerSocketChannel
.
class
)
}
finally
{
// .handler(new LoggingHandler(LogLevel.INFO))
.
childHandler
(
channelInitializer
)
// 设置tcp缓冲区
.
option
(
ChannelOption
.
SO_BACKLOG
,
1024
)
//设置保持活动连接状态
.
childOption
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
ChannelFuture
f
;
try
{
f
=
b
.
bind
(
port
).
sync
();
f
.
channel
().
closeFuture
().
sync
();
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"Tcp服务异常,端口:{}"
,
port
);
}
}
finally
{
log
.
debug
(
"Tcp服务,停止退出"
);
log
.
debug
(
"Tcp服务,停止退出"
);
workerGroup
.
shutdownGracefully
();
workerGroup
.
shutdownGracefully
();
bossGroup
.
shutdownGracefully
();
bossGroup
.
shutdownGracefully
();
...
...
license/src/main/java/iot/sixiang/license/resource/ResourceManager.java
View file @
e1d56c3f
...
@@ -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,15 +115,11 @@ public class ResourceManager {
...
@@ -115,15 +115,11 @@ 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
());
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment