Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
vion-label
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e9161d61
authored
Dec 02, 2021
by
李乾广
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化锁等待
1 parent
2ab9c72a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
label-platform/src/main/java/com/viontech/label/platform/interceptor/AuthInterceptor.java
label-platform/src/main/java/com/viontech/label/platform/interceptor/AuthInterceptor.java
View file @
e9161d6
...
...
@@ -83,7 +83,7 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
String
key
=
user
.
getUnid
()
+
servletPath
;
RLock
lock
=
redissonClient
.
getLock
(
"label:lock:"
+
key
);
try
{
if
(
lock
.
tryLock
(
0
,
10
,
TimeUnit
.
SECONDS
))
{
if
(
lock
.
tryLock
(
1
0
,
10
,
TimeUnit
.
SECONDS
))
{
//查看用户是否已经被锁定
SForbiddenUser
param
=
new
SForbiddenUser
();
param
.
setUserId
(
user
.
getUnid
());
...
...
@@ -124,7 +124,11 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"你违规请求,我们已经记住你,请注意!"
);
}
finally
{
lock
.
unlock
();
if
(
lock
.
isLocked
())
{
if
(
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
}
}
}
return
true
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment