Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
Overview
Overview
Details
Activity
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
yaru
fgqyxxlr
Commits
00a661e3
Commit
00a661e3
authored
Mar 15, 2019
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
捕获线程池执行任务抛出的异常
parent
975829f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
16 deletions
+36
-16
ruoyi-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java
+36
-16
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java
View file @
00a661e3
...
...
@@ -55,25 +55,45 @@ public class ThreadPoolConfig
protected
ScheduledExecutorService
scheduledExecutorService
()
{
return
new
ScheduledThreadPoolExecutor
(
corePoolSize
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"schedule-pool-%d"
).
daemon
(
true
).
build
())
{
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"schedule-pool-%d"
).
daemon
(
true
).
build
())
{
@Override
protected
void
afterExecute
(
Runnable
r
,
Throwable
t
)
{
protected
void
afterExecute
(
Runnable
r
,
Throwable
t
)
{
super
.
afterExecute
(
r
,
t
);
if
(
t
==
null
&&
r
instanceof
Future
<?>)
{
try
{
Object
result
=
((
Future
<?>)
r
).
get
();
}
catch
(
CancellationException
ce
)
{
t
=
ce
;
}
catch
(
ExecutionException
ee
)
{
t
=
ee
.
getCause
();
}
catch
(
InterruptedException
ie
)
{
Thread
.
currentThread
().
interrupt
();
// ignore/reset
}
}
if
(
t
!=
null
)
{
log
.
error
(
t
.
getMessage
());
}
printException
(
r
,
t
);
}
};
}
private
static
void
printException
(
Runnable
r
,
Throwable
t
)
{
if
(
t
==
null
&&
r
instanceof
Future
<?>)
{
try
{
Future
<?>
future
=
(
Future
<?>)
r
;
if
(
future
.
isDone
())
{
future
.
get
();
}
}
catch
(
CancellationException
ce
)
{
t
=
ce
;
}
catch
(
ExecutionException
ee
)
{
t
=
ee
.
getCause
();
}
catch
(
InterruptedException
ie
)
{
Thread
.
currentThread
().
interrupt
();
}
}
if
(
t
!=
null
)
{
log
.
error
(
t
.
getMessage
(),
t
);
}
}
}
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