Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
野花太放肆
jenkins
提交
2a1d1631
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,发现更多精彩内容 >>
提交
2a1d1631
编写于
5月 31, 2013
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-14351] jna-posix → jnr-posix upgrade (opt in).
上级
be5cd4fd
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
75 addition
and
28 deletion
+75
-28
changelog.html
changelog.html
+3
-0
core/pom.xml
core/pom.xml
+6
-1
core/src/main/java/hudson/Util.java
core/src/main/java/hudson/Util.java
+9
-6
core/src/main/java/hudson/cli/ClientAuthenticationCache.java
core/src/main/java/hudson/cli/ClientAuthenticationCache.java
+1
-1
core/src/main/java/hudson/os/PosixAPI.java
core/src/main/java/hudson/os/PosixAPI.java
+48
-16
core/src/main/java/hudson/os/PosixException.java
core/src/main/java/hudson/os/PosixException.java
+3
-1
core/src/main/java/hudson/tools/ZipExtractionInstaller.java
core/src/main/java/hudson/tools/ZipExtractionInstaller.java
+1
-1
core/src/main/java/hudson/util/IOUtils.java
core/src/main/java/hudson/util/IOUtils.java
+1
-1
core/src/main/java/hudson/util/jna/GNUCLibrary.java
core/src/main/java/hudson/util/jna/GNUCLibrary.java
+3
-1
未找到文件。
changelog.html
浏览文件 @
2a1d1631
...
...
@@ -61,6 +61,9 @@ Upcoming changes</a>
<li
class=
bug
>
Optimizations in fingerprint recording.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-16301"
>
issue 16301
</a>
)
<li
class=
bug
>
Using JNR-POSIX rather than JNA-POSIX for better platform support.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-14351"
>
issue 14351
</a>
)
<li
class=
'major bug'
>
Errors searching build records when builds were misordered.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-15652"
>
issue 15652
</a>
)
...
...
core/pom.xml
浏览文件 @
2a1d1631
...
...
@@ -112,11 +112,16 @@ THE SOFTWARE.
</exclusions>
</dependency>
<dependency>
<dependency>
<!-- for compatibility only; all new code should use JNR -->
<groupId>
org.jruby.ext.posix
</groupId>
<artifactId>
jna-posix
</artifactId>
<version>
1.0.3
</version>
</dependency>
<dependency>
<groupId>
com.github.jnr
</groupId>
<artifactId>
jnr-posix
</artifactId>
<version>
3.0.0
</version>
</dependency>
<dependency>
<groupId>
org.kohsuke
</groupId>
<artifactId>
trilead-putty-extension
</artifactId>
...
...
core/src/main/java/hudson/Util.java
浏览文件 @
2a1d1631
...
...
@@ -40,8 +40,8 @@ import org.apache.tools.ant.Project;
import
org.apache.tools.ant.taskdefs.Chmod
;
import
org.apache.tools.ant.taskdefs.Copy
;
import
org.apache.tools.ant.types.FileSet
;
import
org.jruby.ext
.posix.FileStat
;
import
org.jruby.ext
.posix.POSIX
;
import
jnr
.posix.FileStat
;
import
jnr
.posix.POSIX
;
import
org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
;
import
javax.crypto.SecretKey
;
...
...
@@ -281,7 +281,7 @@ public class Util {
}
try
{
// try libc chmod
POSIX
posix
=
PosixAPI
.
get
();
POSIX
posix
=
PosixAPI
.
jnr
();
String
path
=
f
.
getAbsolutePath
();
FileStat
stat
=
posix
.
stat
(
path
);
posix
.
chmod
(
path
,
stat
.
mode
()|
0200
);
// u+w
...
...
@@ -1073,13 +1073,16 @@ public class Util {
}
catch
(
LinkageError
e
)
{
// if JNA is unavailable, fall back.
// we still prefer to try JNA first as PosixAPI supports even smaller platforms.
if
(
PosixAPI
.
supportsNative
())
{
r
=
PosixAPI
.
get
().
symlink
(
targetPath
,
symlinkFile
.
getAbsolutePath
());
POSIX
posix
=
PosixAPI
.
jnr
();
if
(
posix
.
isNative
())
{
// XXX should we rethrow PosixException as IOException here?
r
=
posix
.
symlink
(
targetPath
,
symlinkFile
.
getAbsolutePath
());
}
}
}
if
(
r
==
null
)
{
// if all else fail, fall back to the most expensive approach of forking a process
// XXX is this really necessary? JavaPOSIX should do this automatically
r
=
new
LocalProc
(
new
String
[]{
"ln"
,
"-s"
,
targetPath
,
symlinkPath
},
new
String
[
0
],
listener
.
getLogger
(),
baseDir
).
join
();
...
...
@@ -1221,7 +1224,7 @@ public class Util {
}
catch
(
LinkageError
e
)
{
// if JNA is unavailable, fall back.
// we still prefer to try JNA first as PosixAPI supports even smaller platforms.
return
PosixAPI
.
get
().
readlink
(
filename
);
return
PosixAPI
.
jnr
().
readlink
(
filename
);
}
}
...
...
core/src/main/java/hudson/cli/ClientAuthenticationCache.java
浏览文件 @
2a1d1631
...
...
@@ -118,7 +118,7 @@ public class ClientAuthenticationCache implements Serializable {
}
// try to protect this file from other users, if we can.
PosixAPI
.
get
().
chmod
(
f
.
getAbsolutePath
(),
0600
);
PosixAPI
.
jnr
().
chmod
(
f
.
getAbsolutePath
(),
0600
);
return
null
;
}
});
...
...
core/src/main/java/hudson/os/PosixAPI.java
浏览文件 @
2a1d1631
package
hudson.os
;
import
org.jruby.ext.posix.JavaPOSIX
;
import
org.jruby.ext.posix.POSIX
;
import
org.jruby.ext.posix.POSIXFactory
;
import
org.jruby.ext.posix.POSIXHandler
;
import
org.jruby.ext.posix.POSIX.ERRORS
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.PrintStream
;
import
java.util.Map
;
import
java.util.logging.Logger
;
import
jnr.constants.platform.Errno
;
import
jnr.posix.POSIX
;
import
jnr.posix.POSIXFactory
;
import
jnr.posix.util.DefaultPOSIXHandler
;
/**
* POSIX API wrapper.
*
*
Formerly used the jna-posix library, but this has been superseded by jnr-posix.
* @author Kohsuke Kawaguchi
*/
public
class
PosixAPI
{
public
static
POSIX
get
()
{
private
static
POSIX
posix
;
/**
* Load the JNR implementation of the POSIX APIs for the current platform.
* Runtime exceptions will be of type {@link PosixException}.
* @return some implementation (even on Windows or unsupported Unix)
* @since 1.518
*/
public
static
synchronized
POSIX
jnr
()
{
if
(
posix
==
null
)
{
posix
=
POSIXFactory
.
getPOSIX
(
new
DefaultPOSIXHandler
()
{
@Override
public
void
error
(
Errno
error
,
String
extraData
)
{
throw
new
PosixException
(
"native error "
+
error
.
description
()
+
" "
+
extraData
,
convert
(
error
));
}
@Override
public
void
error
(
Errno
error
,
String
methodName
,
String
extraData
)
{
throw
new
PosixException
(
"native error calling "
+
methodName
+
": "
+
error
.
description
()
+
" "
+
extraData
,
convert
(
error
));
}
private
org
.
jruby
.
ext
.
posix
.
POSIX
.
ERRORS
convert
(
Errno
error
)
{
try
{
return
org
.
jruby
.
ext
.
posix
.
POSIX
.
ERRORS
.
valueOf
(
error
.
name
());
}
catch
(
IllegalArgumentException
x
)
{
return
org
.
jruby
.
ext
.
posix
.
POSIX
.
ERRORS
.
EIO
;
// PosixException.message has real error anyway
}
}
},
true
);
}
return
posix
;
}
/**
* @deprecated as of 1.448
* Use {@link #supportsNative()}.
* @deprecated use {@link #jnr} and {@link POSIX#isNative}
*/
@Deprecated
public
boolean
isNative
()
{
return
supportsNative
();
}
/**
* Determine if the jna-posix library could not provide native support, and
* used a fallback java implementation which does not support many operations.
* @deprecated use {@link #jnr} and {@link POSIX#isNative}
*/
@Deprecated
public
static
boolean
supportsNative
()
{
return
!(
posix
instanceof
JavaPOSIX
);
return
!(
jnaPosix
instanceof
org
.
jruby
.
ext
.
posix
.
JavaPOSIX
);
}
private
static
final
POSIX
posix
=
POSIXFactory
.
getPOSIX
(
new
POSIXHandler
()
{
public
void
error
(
ERRORS
errors
,
String
s
)
{
private
static
org
.
jruby
.
ext
.
posix
.
POSIX
jnaPosix
;
/** @deprecated Use {@link #jnr} instead. */
@Deprecated
public
static
synchronized
org
.
jruby
.
ext
.
posix
.
POSIX
get
()
{
if
(
jnaPosix
==
null
)
{
jnaPosix
=
org
.
jruby
.
ext
.
posix
.
POSIXFactory
.
getPOSIX
(
new
org
.
jruby
.
ext
.
posix
.
POSIXHandler
()
{
public
void
error
(
org
.
jruby
.
ext
.
posix
.
POSIX
.
ERRORS
errors
,
String
s
)
{
throw
new
PosixException
(
s
,
errors
);
}
...
...
@@ -87,6 +116,9 @@ public class PosixAPI {
return
System
.
err
;
}
},
true
);
}
return
jnaPosix
;
}
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
PosixAPI
.
class
.
getName
());
}
core/src/main/java/hudson/os/PosixException.java
浏览文件 @
2a1d1631
...
...
@@ -4,7 +4,7 @@ import org.jruby.ext.posix.POSIX.ERRORS;
/**
* Indicates an error during POSIX API call.
*
*
@see PosixAPI
* @author Kohsuke Kawaguchi
*/
public
class
PosixException
extends
RuntimeException
{
...
...
@@ -15,6 +15,8 @@ public class PosixException extends RuntimeException {
this
.
errors
=
errors
;
}
/** @deprecated Leaks reference to deprecated jna-posix API. */
@Deprecated
public
ERRORS
getErrorCode
()
{
return
errors
;
}
...
...
core/src/main/java/hudson/tools/ZipExtractionInstaller.java
浏览文件 @
2a1d1631
...
...
@@ -137,7 +137,7 @@ public class ZipExtractionInstaller extends ToolInstaller {
}
catch
(
LinkageError
e
)
{
// if JNA is unavailable, fall back.
// we still prefer to try JNA first as PosixAPI supports even smaller platforms.
PosixAPI
.
get
().
chmod
(
f
.
getAbsolutePath
(),
0755
);
PosixAPI
.
jnr
().
chmod
(
f
.
getAbsolutePath
(),
0755
);
}
}
}
else
{
...
...
core/src/main/java/hudson/util/IOUtils.java
浏览文件 @
2a1d1631
...
...
@@ -122,7 +122,7 @@ public class IOUtils extends org.apache.commons.io.IOUtils {
*/
public
static
int
mode
(
File
f
)
throws
PosixException
{
if
(
Functions
.
isWindows
())
return
-
1
;
return
PosixAPI
.
get
().
stat
(
f
.
getPath
()).
mode
();
return
PosixAPI
.
jnr
().
stat
(
f
.
getPath
()).
mode
();
}
/**
...
...
core/src/main/java/hudson/util/jna/GNUCLibrary.java
浏览文件 @
2a1d1631
...
...
@@ -30,6 +30,8 @@ import com.sun.jna.Native;
import
com.sun.jna.Memory
;
import
com.sun.jna.NativeLong
;
import
com.sun.jna.ptr.IntByReference
;
import
hudson.os.PosixAPI
;
import
jnr.posix.POSIX
;
import
org.jvnet.libpam.impl.CLibrary.passwd
;
/**
...
...
@@ -38,7 +40,7 @@ import org.jvnet.libpam.impl.CLibrary.passwd;
* <p>
* Not available on all platforms (such as Linux/PPC, IBM mainframe, etc.), so the caller should recover gracefully
* in case of {@link LinkageError}. See HUDSON-4820.
*
*
<p>Consider deprecating all methods present also in {@link POSIX} (as obtained by {@link PosixAPI#jnr}).
* @author Kohsuke Kawaguchi
*/
public
interface
GNUCLibrary
extends
Library
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录