Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
野花太放肆
jenkins
提交
386ec0d1
J
jenkins
项目概览
野花太放肆
/
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,发现更多精彩内容 >>
提交
386ec0d1
编写于
7月 20, 2011
作者:
J
Jerome Lacoste
提交者:
Kohsuke Kawaguchi
7月 23, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure that the Readers are closed properly
上级
b58044ad
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
72 addition
and
41 deletion
+72
-41
core/src/main/java/hudson/ClassicPluginStrategy.java
core/src/main/java/hudson/ClassicPluginStrategy.java
+3
-10
core/src/main/java/hudson/Main.java
core/src/main/java/hudson/Main.java
+11
-3
core/src/main/java/hudson/Util.java
core/src/main/java/hudson/Util.java
+8
-5
core/src/main/java/hudson/model/Queue.java
core/src/main/java/hudson/model/Queue.java
+9
-6
core/src/main/java/hudson/util/IOUtils.java
core/src/main/java/hudson/util/IOUtils.java
+16
-0
core/src/main/java/hudson/util/Service.java
core/src/main/java/hudson/util/Service.java
+18
-14
test/src/main/java/org/jvnet/hudson/test/TestPluginManager.java
...rc/main/java/org/jvnet/hudson/test/TestPluginManager.java
+7
-3
未找到文件。
core/src/main/java/hudson/ClassicPluginStrategy.java
浏览文件 @
386ec0d1
...
...
@@ -27,14 +27,13 @@ import hudson.Plugin.DummyImpl;
import
hudson.PluginWrapper.Dependency
;
import
hudson.model.Hudson
;
import
hudson.util.IOException2
;
import
hudson.util.IOUtils
;
import
hudson.util.MaskingClassLoader
;
import
hudson.util.VersionNumber
;
import
java.io.BufferedReader
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileReader
;
import
java.io.FilenameFilter
;
import
java.io.IOException
;
import
java.net.URL
;
...
...
@@ -86,13 +85,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
boolean
isLinked
=
archive
.
getName
().
endsWith
(
".hpl"
);
if
(
isLinked
)
{
// resolve the .hpl file to the location of the manifest file
final
String
firstLine
;
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
archive
));
try
{
firstLine
=
reader
.
readLine
();
}
finally
{
reader
.
close
();
}
final
String
firstLine
=
IOUtils
.
readFirstLine
(
archive
);
if
(
firstLine
.
startsWith
(
"Manifest-Version:"
))
{
// this is the manifest already
}
else
{
...
...
@@ -179,7 +172,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
return
new
PluginWrapper
(
pluginManager
,
archive
,
manifest
,
baseResourceURL
,
createClassLoader
(
paths
,
dependencyLoader
,
atts
),
disableFile
,
dependencies
,
optionalDependencies
);
}
@Deprecated
protected
ClassLoader
createClassLoader
(
List
<
File
>
paths
,
ClassLoader
parent
)
throws
IOException
{
return
createClassLoader
(
paths
,
parent
,
null
);
...
...
core/src/main/java/hudson/Main.java
浏览文件 @
386ec0d1
...
...
@@ -32,6 +32,7 @@ import java.io.File;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.Writer
;
...
...
@@ -123,9 +124,7 @@ public class Main {
HttpURLConnection
con
=
open
(
new
URL
(
home
+
"crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)'"
));
if
(
auth
!=
null
)
con
.
setRequestProperty
(
"Authorization"
,
auth
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
con
.
getInputStream
()));
String
line
=
in
.
readLine
();
in
.
close
();
String
line
=
readFirstLine
(
con
.
getInputStream
());
String
[]
components
=
line
.
split
(
":"
);
if
(
components
.
length
==
2
)
{
crumbField
=
components
[
0
];
...
...
@@ -197,6 +196,15 @@ public class Main {
}
}
private
static
String
readFirstLine
(
InputStream
is
)
throws
IOException
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
is
));
try
{
return
reader
.
readLine
();
}
finally
{
reader
.
close
();
}
}
/**
* Connects to the given HTTP URL and configure time out, to avoid infinite hang.
*/
...
...
core/src/main/java/hudson/Util.java
浏览文件 @
386ec0d1
...
...
@@ -200,11 +200,14 @@ public class Util {
StringBuilder
str
=
new
StringBuilder
((
int
)
logfile
.
length
());
BufferedReader
r
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
logfile
),
charset
));
char
[]
buf
=
new
char
[
1024
];
int
len
;
while
((
len
=
r
.
read
(
buf
,
0
,
buf
.
length
))>
0
)
str
.
append
(
buf
,
0
,
len
);
r
.
close
();
try
{
char
[]
buf
=
new
char
[
1024
];
int
len
;
while
((
len
=
r
.
read
(
buf
,
0
,
buf
.
length
))>
0
)
str
.
append
(
buf
,
0
,
len
);
}
finally
{
r
.
close
();
}
return
str
.
toString
();
}
...
...
core/src/main/java/hudson/model/Queue.java
浏览文件 @
386ec0d1
...
...
@@ -274,13 +274,16 @@ public class Queue extends ResourceController implements Saveable {
File
queueFile
=
getQueueFile
();
if
(
queueFile
.
exists
())
{
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
queueFile
)));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
AbstractProject
j
=
Jenkins
.
getInstance
().
getItemByFullName
(
line
,
AbstractProject
.
class
);
if
(
j
!=
null
)
j
.
scheduleBuild
();
try
{
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
AbstractProject
j
=
Jenkins
.
getInstance
().
getItemByFullName
(
line
,
AbstractProject
.
class
);
if
(
j
!=
null
)
j
.
scheduleBuild
();
}
}
finally
{
in
.
close
();
}
in
.
close
();
// discard the queue file now that we are done
queueFile
.
delete
();
}
else
{
...
...
core/src/main/java/hudson/util/IOUtils.java
浏览文件 @
386ec0d1
...
...
@@ -124,5 +124,21 @@ public class IOUtils extends org.apache.commons.io.IOUtils {
return
PosixAPI
.
get
().
stat
(
f
.
getPath
()).
mode
();
}
/**
* Read the first line of a file
* @param file
* @return the first line of a file
* @throws IOException
* @since 1.422
*/
public
static
String
readFirstLine
(
File
file
)
throws
IOException
{
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
file
));
try
{
return
reader
.
readLine
();
}
finally
{
reader
.
close
();
}
}
private
static
final
byte
[]
SKIP_BUFFER
=
new
byte
[
8192
];
}
core/src/main/java/hudson/util/Service.java
浏览文件 @
386ec0d1
...
...
@@ -51,23 +51,27 @@ public class Service {
while
(
e
.
hasMoreElements
())
{
URL
url
=
e
.
nextElement
();
BufferedReader
configFile
=
new
BufferedReader
(
new
InputStreamReader
(
url
.
openStream
(),
"UTF-8"
));
String
line
;
while
((
line
=
configFile
.
readLine
())
!=
null
)
{
line
=
line
.
trim
();
if
(
line
.
startsWith
(
"#"
)
||
line
.
length
()==
0
)
continue
;
try
{
String
line
;
while
((
line
=
configFile
.
readLine
())
!=
null
)
{
line
=
line
.
trim
();
if
(
line
.
startsWith
(
"#"
)
||
line
.
length
()==
0
)
continue
;
try
{
Class
<?>
t
=
classLoader
.
loadClass
(
line
);
if
(!
type
.
isAssignableFrom
(
t
))
continue
;
// invalid type
try
{
Class
<?>
t
=
classLoader
.
loadClass
(
line
);
if
(!
type
.
isAssignableFrom
(
t
))
continue
;
// invalid type
result
.
add
(
type
.
cast
(
t
.
newInstance
()));
}
catch
(
ClassNotFoundException
x
)
{
LOGGER
.
log
(
WARNING
,
"Failed to load "
+
line
,
x
);
}
catch
(
InstantiationException
x
)
{
LOGGER
.
log
(
WARNING
,
"Failed to load "
+
line
,
x
);
}
catch
(
IllegalAccessException
x
)
{
LOGGER
.
log
(
WARNING
,
"Failed to load "
+
line
,
x
);
result
.
add
(
type
.
cast
(
t
.
newInstance
()));
}
catch
(
ClassNotFoundException
x
)
{
LOGGER
.
log
(
WARNING
,
"Failed to load "
+
line
,
x
);
}
catch
(
InstantiationException
x
)
{
LOGGER
.
log
(
WARNING
,
"Failed to load "
+
line
,
x
);
}
catch
(
IllegalAccessException
x
)
{
LOGGER
.
log
(
WARNING
,
"Failed to load "
+
line
,
x
);
}
}
}
finally
{
configFile
.
close
();
}
}
...
...
test/src/main/java/org/jvnet/hudson/test/TestPluginManager.java
浏览文件 @
386ec0d1
...
...
@@ -88,9 +88,13 @@ public class TestPluginManager extends PluginManager {
URL
index
=
getClass
().
getResource
(
"/test-dependencies/index"
);
if
(
index
!=
null
)
{
// if built with maven-hpi-plugin < 1.52 this file won't exist.
BufferedReader
r
=
new
BufferedReader
(
new
InputStreamReader
(
index
.
openStream
(),
"UTF-8"
));
String
line
;
while
((
line
=
r
.
readLine
())!=
null
)
{
copyBundledPlugin
(
new
URL
(
index
,
line
+
".hpi"
),
line
+
".hpi"
);
try
{
String
line
;
while
((
line
=
r
.
readLine
())!=
null
)
{
copyBundledPlugin
(
new
URL
(
index
,
line
+
".hpi"
),
line
+
".hpi"
);
}
}
finally
{
r
.
close
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录