Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
124706a7
J
jenkins
项目概览
FIY695
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
124706a7
编写于
5月 15, 2012
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Eliminated the lock for better scalability.
上级
0e4e2978
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
21 deletion
+31
-21
core/src/main/java/hudson/model/User.java
core/src/main/java/hudson/model/User.java
+31
-21
未找到文件。
core/src/main/java/hudson/model/User.java
浏览文件 @
124706a7
...
...
@@ -63,12 +63,15 @@ import java.io.FileFilter;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.TreeMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
...
...
@@ -295,16 +298,16 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
.
replace
(
'>'
,
'_'
);
// 4 replace() still faster than regex
if
(
Functions
.
isWindows
())
id
=
id
.
replace
(
':'
,
'_'
);
synchronized
(
byName
)
{
User
u
=
byName
.
get
(
id
);
if
(
u
==
null
)
{
User
tmp
=
new
User
(
id
,
idOrFullName
);
if
(
create
||
tmp
.
getConfigFile
().
exists
())
{
byName
.
put
(
id
,
u
=
tmp
);
}
}
return
u
;
String
idkey
=
id
.
toLowerCase
(
Locale
.
ENGLISH
);
User
u
=
byName
.
get
(
idkey
);
if
(
u
==
null
&&
(
create
||
getConfigFileFor
(
id
).
exists
()))
{
User
tmp
=
new
User
(
id
,
idOrFullName
);
User
prev
=
byName
.
putIfAbsent
(
idkey
,
u
=
tmp
);
if
(
prev
!=
null
)
u
=
prev
;
// if somehas already put a value in the map, use it
}
return
u
;
}
/**
...
...
@@ -349,17 +352,20 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
lastScanned
=
System
.
currentTimeMillis
();
}
synchronized
(
byName
)
{
return
new
ArrayList
<
User
>(
byName
.
values
());
}
ArrayList
<
User
>
r
=
new
ArrayList
<
User
>(
byName
.
values
());
Collections
.
sort
(
r
,
new
Comparator
<
User
>()
{
public
int
compare
(
User
o1
,
User
o2
)
{
return
o1
.
getId
().
compareToIgnoreCase
(
o2
.
getId
());
}
});
return
r
;
}
/**
* Reloads the configuration from disk.
*/
public
static
void
reload
()
{
// iterate over an array to be concurrency-safe
for
(
User
u
:
byName
.
values
().
toArray
(
new
User
[
0
])
)
for
(
User
u
:
byName
.
values
()
)
u
.
load
();
}
...
...
@@ -413,7 +419,11 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
* The file we save our configuration.
*/
protected
final
XmlFile
getConfigFile
()
{
return
new
XmlFile
(
XSTREAM
,
new
File
(
getRootDir
(),
id
+
"/config.xml"
));
return
new
XmlFile
(
XSTREAM
,
getConfigFileFor
(
id
));
}
private
static
final
File
getConfigFileFor
(
String
id
)
{
return
new
File
(
getRootDir
(),
id
+
"/config.xml"
);
}
/**
...
...
@@ -439,10 +449,8 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
* if we fail to delete.
*/
public
synchronized
void
delete
()
throws
IOException
{
synchronized
(
byName
)
{
byName
.
remove
(
id
);
Util
.
deleteRecursive
(
new
File
(
getRootDir
(),
id
));
}
byName
.
remove
(
id
.
toLowerCase
(
Locale
.
ENGLISH
));
Util
.
deleteRecursive
(
new
File
(
getRootDir
(),
id
));
}
/**
...
...
@@ -537,8 +545,10 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
/**
* Keyed by {@link User#id}. This map is used to ensure
* singleton-per-id semantics of {@link User} objects.
*
* The key needs to be lower cased for case insensitivity.
*/
private
static
final
Map
<
String
,
User
>
byName
=
new
TreeMap
<
String
,
User
>(
String
.
CASE_INSENSITIVE_ORDER
);
private
static
final
ConcurrentMap
<
String
,
User
>
byName
=
new
ConcurrentHashMap
<
String
,
User
>(
);
/**
* Used to load/save user configuration.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录