Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
112ceeba
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
112ceeba
编写于
9月 18, 2017
作者:
B
Baptiste Mathus
提交者:
GitHub
9月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2892 from batmat/deprecate-timeunit2
Deprecate TimeUnit2
上级
bbde97d3
b22b02ab
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
58 addition
and
49 deletion
+58
-49
core/src/main/java/hudson/Plugin.java
core/src/main/java/hudson/Plugin.java
+2
-2
core/src/main/java/hudson/console/AnnotatedLargeText.java
core/src/main/java/hudson/console/AnnotatedLargeText.java
+2
-2
core/src/main/java/hudson/console/ConsoleAnnotationDescriptor.java
...main/java/hudson/console/ConsoleAnnotationDescriptor.java
+3
-3
core/src/main/java/hudson/console/ConsoleAnnotatorFactory.java
...src/main/java/hudson/console/ConsoleAnnotatorFactory.java
+3
-3
core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java
core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java
+2
-2
core/src/main/java/hudson/model/AbstractProject.java
core/src/main/java/hudson/model/AbstractProject.java
+2
-2
core/src/main/java/hudson/model/DownloadService.java
core/src/main/java/hudson/model/DownloadService.java
+1
-1
core/src/main/java/hudson/model/Executor.java
core/src/main/java/hudson/model/Executor.java
+2
-2
core/src/main/java/hudson/model/MultiStageTimeSeries.java
core/src/main/java/hudson/model/MultiStageTimeSeries.java
+4
-4
core/src/main/java/hudson/model/Queue.java
core/src/main/java/hudson/model/Queue.java
+2
-2
core/src/main/java/hudson/model/UpdateSite.java
core/src/main/java/hudson/model/UpdateSite.java
+1
-1
core/src/main/java/hudson/model/UsageStatistics.java
core/src/main/java/hudson/model/UsageStatistics.java
+1
-1
core/src/main/java/hudson/model/queue/BackFiller.java
core/src/main/java/hudson/model/queue/BackFiller.java
+2
-2
core/src/main/java/hudson/slaves/CloudRetentionStrategy.java
core/src/main/java/hudson/slaves/CloudRetentionStrategy.java
+1
-1
core/src/main/java/hudson/slaves/CloudSlaveRetentionStrategy.java
.../main/java/hudson/slaves/CloudSlaveRetentionStrategy.java
+2
-2
core/src/main/java/hudson/slaves/ConnectionActivityMonitor.java
...rc/main/java/hudson/slaves/ConnectionActivityMonitor.java
+5
-5
core/src/main/java/hudson/triggers/SCMTrigger.java
core/src/main/java/hudson/triggers/SCMTrigger.java
+2
-2
core/src/main/java/hudson/util/TimeUnit2.java
core/src/main/java/hudson/util/TimeUnit2.java
+9
-0
core/src/main/java/jenkins/model/AssetManager.java
core/src/main/java/jenkins/model/AssetManager.java
+2
-2
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+3
-3
test/src/test/java/hudson/model/JobTest.java
test/src/test/java/hudson/model/JobTest.java
+1
-1
test/src/test/java/hudson/model/UpdateCenterTest.java
test/src/test/java/hudson/model/UpdateCenterTest.java
+2
-2
test/src/test/java/hudson/node_monitors/ClockMonitorDescriptorTest.java
...java/hudson/node_monitors/ClockMonitorDescriptorTest.java
+4
-4
未找到文件。
core/src/main/java/hudson/Plugin.java
浏览文件 @
112ceeba
...
...
@@ -23,7 +23,7 @@
*/
package
hudson
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
jenkins.model.Jenkins
;
import
hudson.model.Descriptor
;
import
hudson.model.Saveable
;
...
...
@@ -237,7 +237,7 @@ public abstract class Plugin implements Saveable {
String
requestPath
=
req
.
getRequestURI
().
substring
(
req
.
getContextPath
().
length
());
boolean
staticLink
=
requestPath
.
startsWith
(
"/static/"
);
long
expires
=
staticLink
?
TimeUnit
2
.
DAYS
.
toMillis
(
365
)
:
-
1
;
long
expires
=
staticLink
?
TimeUnit
.
DAYS
.
toMillis
(
365
)
:
-
1
;
// use serveLocalizedFile to support automatic locale selection
try
{
...
...
core/src/main/java/hudson/console/AnnotatedLargeText.java
浏览文件 @
112ceeba
...
...
@@ -28,7 +28,7 @@ package hudson.console;
import
com.trilead.ssh2.crypto.Base64
;
import
jenkins.model.Jenkins
;
import
hudson.remoting.ObjectInputStreamEx
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
jenkins.security.CryptoConfidentialKey
;
import
org.apache.commons.io.output.ByteArrayOutputStream
;
import
org.kohsuke.stapler.Stapler
;
...
...
@@ -123,7 +123,7 @@ public class AnnotatedLargeText<T> extends LargeText {
Jenkins
.
getInstance
().
pluginManager
.
uberClassLoader
);
try
{
long
timestamp
=
ois
.
readLong
();
if
(
TimeUnit
2
.
HOURS
.
toMillis
(
1
)
>
abs
(
System
.
currentTimeMillis
()-
timestamp
))
if
(
TimeUnit
.
HOURS
.
toMillis
(
1
)
>
abs
(
System
.
currentTimeMillis
()-
timestamp
))
// don't deserialize something too old to prevent a replay attack
return
(
ConsoleAnnotator
)
ois
.
readObject
();
}
finally
{
...
...
core/src/main/java/hudson/console/ConsoleAnnotationDescriptor.java
浏览文件 @
112ceeba
...
...
@@ -27,7 +27,7 @@ import hudson.DescriptorExtensionList;
import
hudson.ExtensionPoint
;
import
hudson.model.Descriptor
;
import
jenkins.model.Jenkins
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
import
org.kohsuke.stapler.WebMethod
;
...
...
@@ -80,12 +80,12 @@ public abstract class ConsoleAnnotationDescriptor extends Descriptor<ConsoleNote
@WebMethod
(
name
=
"script.js"
)
public
void
doScriptJs
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
rsp
.
serveFile
(
req
,
hasResource
(
"/script.js"
),
TimeUnit
2
.
DAYS
.
toMillis
(
1
));
rsp
.
serveFile
(
req
,
hasResource
(
"/script.js"
),
TimeUnit
.
DAYS
.
toMillis
(
1
));
}
@WebMethod
(
name
=
"style.css"
)
public
void
doStyleCss
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
rsp
.
serveFile
(
req
,
hasResource
(
"/style.css"
),
TimeUnit
2
.
DAYS
.
toMillis
(
1
));
rsp
.
serveFile
(
req
,
hasResource
(
"/style.css"
),
TimeUnit
.
DAYS
.
toMillis
(
1
));
}
/**
...
...
core/src/main/java/hudson/console/ConsoleAnnotatorFactory.java
浏览文件 @
112ceeba
...
...
@@ -27,7 +27,7 @@ import hudson.Extension;
import
hudson.ExtensionList
;
import
hudson.ExtensionPoint
;
import
hudson.model.Run
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
org.jvnet.tiger_types.Types
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
...
...
@@ -114,12 +114,12 @@ public abstract class ConsoleAnnotatorFactory<T> implements ExtensionPoint {
*/
@WebMethod
(
name
=
"script.js"
)
public
void
doScriptJs
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
rsp
.
serveFile
(
req
,
getResource
(
"/script.js"
),
TimeUnit
2
.
DAYS
.
toMillis
(
1
));
rsp
.
serveFile
(
req
,
getResource
(
"/script.js"
),
TimeUnit
.
DAYS
.
toMillis
(
1
));
}
@WebMethod
(
name
=
"style.css"
)
public
void
doStyleCss
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
rsp
.
serveFile
(
req
,
getResource
(
"/style.css"
),
TimeUnit
2
.
DAYS
.
toMillis
(
1
));
rsp
.
serveFile
(
req
,
getResource
(
"/style.css"
),
TimeUnit
.
DAYS
.
toMillis
(
1
));
}
/**
...
...
core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java
浏览文件 @
112ceeba
...
...
@@ -23,7 +23,7 @@
*/
package
hudson.diagnosis
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
hudson.util.ColorPalette
;
import
hudson.Extension
;
import
hudson.model.PeriodicWork
;
...
...
@@ -116,7 +116,7 @@ public final class MemoryUsageMonitor extends PeriodicWork {
}
public
long
getRecurrencePeriod
()
{
return
TimeUnit
2
.
SECONDS
.
toMillis
(
10
);
return
TimeUnit
.
SECONDS
.
toMillis
(
10
);
}
protected
void
doRun
()
{
...
...
core/src/main/java/hudson/model/AbstractProject.java
浏览文件 @
112ceeba
...
...
@@ -75,7 +75,6 @@ import hudson.util.AlternativeUiTextProvider;
import
hudson.util.AlternativeUiTextProvider.Message
;
import
hudson.util.DescribableList
;
import
hudson.util.FormValidation
;
import
hudson.util.TimeUnit2
;
import
hudson.widgets.HistoryWidget
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -92,6 +91,7 @@ import java.util.SortedMap;
import
java.util.TreeMap
;
import
java.util.Vector
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicReferenceFieldUpdater
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
...
...
@@ -1345,7 +1345,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
// However, first there are some conditions in which we do not want to do so.
// give time for agents to come online if we are right after reconnection (JENKINS-8408)
long
running
=
Jenkins
.
getInstance
().
getInjector
().
getInstance
(
Uptime
.
class
).
getUptime
();
long
remaining
=
TimeUnit
2
.
MINUTES
.
toMillis
(
10
)-
running
;
long
remaining
=
TimeUnit
.
MINUTES
.
toMillis
(
10
)-
running
;
if
(
remaining
>
0
&&
/* this logic breaks tests of polling */
!
Functions
.
getIsUnitTest
())
{
listener
.
getLogger
().
print
(
Messages
.
AbstractProject_AwaitingWorkspaceToComeOnline
(
remaining
/
1000
));
listener
.
getLogger
().
println
(
" ("
+
workspaceOfflineReason
.
name
()
+
")"
);
...
...
core/src/main/java/hudson/model/DownloadService.java
浏览文件 @
112ceeba
...
...
@@ -35,7 +35,7 @@ import hudson.util.FormValidation;
import
hudson.util.FormValidation.Kind
;
import
hudson.util.QuotedStringTokenizer
;
import
hudson.util.TextFile
;
import
static
hudson
.
util
.
TimeUnit2
.
DAYS
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
DAYS
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
core/src/main/java/hudson/model/Executor.java
浏览文件 @
112ceeba
...
...
@@ -31,7 +31,7 @@ import hudson.model.queue.SubTask;
import
hudson.model.queue.WorkUnit
;
import
hudson.security.ACL
;
import
hudson.util.InterceptingProxy
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
jenkins.model.CauseOfInterruption
;
import
jenkins.model.CauseOfInterruption.UserInterruption
;
import
jenkins.model.InterruptedBuildAction
;
...
...
@@ -724,7 +724,7 @@ public class Executor extends Thread implements ModelObject {
return
d
*
10
<
elapsed
;
}
else
{
// if no ETA is available, a build taking longer than a day is considered stuck
return
TimeUnit
2
.
MILLISECONDS
.
toHours
(
elapsed
)
>
24
;
return
TimeUnit
.
MILLISECONDS
.
toHours
(
elapsed
)
>
24
;
}
}
...
...
core/src/main/java/hudson/model/MultiStageTimeSeries.java
浏览文件 @
112ceeba
...
...
@@ -23,7 +23,7 @@
*/
package
hudson.model
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
hudson.util.NoOverlapCategoryAxis
;
import
hudson.util.ChartUtil
;
...
...
@@ -152,9 +152,9 @@ public class MultiStageTimeSeries implements Serializable {
* Choose which datapoint to use.
*/
public
enum
TimeScale
{
SEC10
(
TimeUnit
2
.
SECONDS
.
toMillis
(
10
)),
MIN
(
TimeUnit
2
.
MINUTES
.
toMillis
(
1
)),
HOUR
(
TimeUnit
2
.
HOURS
.
toMillis
(
1
));
SEC10
(
TimeUnit
.
SECONDS
.
toMillis
(
10
)),
MIN
(
TimeUnit
.
MINUTES
.
toMillis
(
1
)),
HOUR
(
TimeUnit
.
HOURS
.
toMillis
(
1
));
/**
* Number of milliseconds (10 secs, 1 min, and 1 hour)
...
...
core/src/main/java/hudson/model/Queue.java
浏览文件 @
112ceeba
...
...
@@ -68,7 +68,7 @@ import java.nio.file.InvalidPathException;
import
jenkins.security.QueueItemAuthenticatorProvider
;
import
jenkins.util.Timer
;
import
hudson.triggers.SafeTimerTask
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
hudson.util.XStream2
;
import
hudson.util.ConsistentHash
;
import
hudson.util.ConsistentHash.Hash
;
...
...
@@ -2566,7 +2566,7 @@ public class Queue extends ResourceController implements Saveable {
return
elapsed
>
Math
.
max
(
d
,
60000L
)*
10
;
}
else
{
// more than a day in the queue
return
TimeUnit
2
.
MILLISECONDS
.
toHours
(
elapsed
)>
24
;
return
TimeUnit
.
MILLISECONDS
.
toHours
(
elapsed
)>
24
;
}
}
...
...
core/src/main/java/hudson/model/UpdateSite.java
浏览文件 @
112ceeba
...
...
@@ -36,7 +36,7 @@ import hudson.util.FormValidation;
import
hudson.util.FormValidation.Kind
;
import
hudson.util.HttpResponses
;
import
hudson.util.TextFile
;
import
static
hudson
.
util
.
TimeUnit2
.*;
import
static
java
.
util
.
concurrent
.
TimeUnit
.*;
import
hudson.util.VersionNumber
;
import
java.io.File
;
import
java.io.IOException
;
...
...
core/src/main/java/hudson/model/UsageStatistics.java
浏览文件 @
112ceeba
...
...
@@ -29,7 +29,7 @@ import hudson.Util;
import
hudson.Extension
;
import
hudson.node_monitors.ArchitectureMonitor.DescriptorImpl
;
import
hudson.util.Secret
;
import
static
hudson
.
util
.
TimeUnit2
.
DAYS
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
DAYS
;
import
jenkins.model.Jenkins
;
import
net.sf.json.JSONObject
;
...
...
core/src/main/java/hudson/model/queue/BackFiller.java
浏览文件 @
112ceeba
...
...
@@ -12,7 +12,7 @@ import hudson.model.queue.MappingWorksheet.ExecutorChunk;
import
hudson.model.queue.MappingWorksheet.ExecutorSlot
;
import
hudson.model.queue.MappingWorksheet.Mapping
;
import
hudson.model.queue.MappingWorksheet.WorkChunk
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -124,7 +124,7 @@ public class BackFiller extends LoadPredictor {
// The downside of guessing the duration wrong is that we can end up creating tentative plans
// afterward that may be incorrect, but those plans will be rebuilt.
long
d
=
bi
.
task
.
getEstimatedDuration
();
if
(
d
<=
0
)
d
=
TimeUnit
2
.
MINUTES
.
toMillis
(
5
);
if
(
d
<=
0
)
d
=
TimeUnit
.
MINUTES
.
toMillis
(
5
);
TimeRange
slot
=
new
TimeRange
(
System
.
currentTimeMillis
(),
d
);
...
...
core/src/main/java/hudson/slaves/CloudRetentionStrategy.java
浏览文件 @
112ceeba
...
...
@@ -29,7 +29,7 @@ import javax.annotation.concurrent.GuardedBy;
import
java.io.IOException
;
import
java.util.logging.Logger
;
import
static
hudson
.
util
.
TimeUnit2
.*;
import
static
java
.
util
.
concurrent
.
TimeUnit
.*;
import
java.util.logging.Level
;
import
static
java
.
util
.
logging
.
Level
.*;
...
...
core/src/main/java/hudson/slaves/CloudSlaveRetentionStrategy.java
浏览文件 @
112ceeba
...
...
@@ -2,7 +2,7 @@ package hudson.slaves;
import
hudson.model.Computer
;
import
hudson.model.Node
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
jenkins.model.Jenkins
;
import
javax.annotation.concurrent.GuardedBy
;
...
...
@@ -72,7 +72,7 @@ public class CloudSlaveRetentionStrategy<T extends Computer> extends RetentionSt
}
// for debugging, it's convenient to be able to reduce this time
public
static
long
TIMEOUT
=
SystemProperties
.
getLong
(
CloudSlaveRetentionStrategy
.
class
.
getName
()+
".timeout"
,
TimeUnit
2
.
MINUTES
.
toMillis
(
10
));
public
static
long
TIMEOUT
=
SystemProperties
.
getLong
(
CloudSlaveRetentionStrategy
.
class
.
getName
()+
".timeout"
,
TimeUnit
.
MINUTES
.
toMillis
(
10
));
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CloudSlaveRetentionStrategy
.
class
.
getName
());
}
core/src/main/java/hudson/slaves/ConnectionActivityMonitor.java
浏览文件 @
112ceeba
...
...
@@ -27,7 +27,7 @@ import hudson.model.AsyncPeriodicWork;
import
hudson.model.TaskListener
;
import
jenkins.model.Jenkins
;
import
hudson.model.Computer
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
hudson.remoting.VirtualChannel
;
import
hudson.remoting.Channel
;
import
hudson.Extension
;
...
...
@@ -84,20 +84,20 @@ public class ConnectionActivityMonitor extends AsyncPeriodicWork {
}
public
long
getRecurrencePeriod
()
{
return
enabled
?
FREQUENCY
:
TimeUnit
2
.
DAYS
.
toMillis
(
30
);
return
enabled
?
FREQUENCY
:
TimeUnit
.
DAYS
.
toMillis
(
30
);
}
/**
* Time till initial ping
*/
private
static
final
long
TIME_TILL_PING
=
SystemProperties
.
getLong
(
ConnectionActivityMonitor
.
class
.
getName
()+
".timeToPing"
,
TimeUnit
2
.
MINUTES
.
toMillis
(
3
));
private
static
final
long
TIME_TILL_PING
=
SystemProperties
.
getLong
(
ConnectionActivityMonitor
.
class
.
getName
()+
".timeToPing"
,
TimeUnit
.
MINUTES
.
toMillis
(
3
));
private
static
final
long
FREQUENCY
=
SystemProperties
.
getLong
(
ConnectionActivityMonitor
.
class
.
getName
()+
".frequency"
,
TimeUnit
2
.
SECONDS
.
toMillis
(
10
));
private
static
final
long
FREQUENCY
=
SystemProperties
.
getLong
(
ConnectionActivityMonitor
.
class
.
getName
()+
".frequency"
,
TimeUnit
.
SECONDS
.
toMillis
(
10
));
/**
* When do we abandon the effort and cut off?
*/
private
static
final
long
TIMEOUT
=
SystemProperties
.
getLong
(
ConnectionActivityMonitor
.
class
.
getName
()+
".timeToPing"
,
TimeUnit
2
.
MINUTES
.
toMillis
(
4
));
private
static
final
long
TIMEOUT
=
SystemProperties
.
getLong
(
ConnectionActivityMonitor
.
class
.
getName
()+
".timeToPing"
,
TimeUnit
.
MINUTES
.
toMillis
(
4
));
// disabled by default until proven in the production
...
...
core/src/main/java/hudson/triggers/SCMTrigger.java
浏览文件 @
112ceeba
...
...
@@ -45,7 +45,7 @@ import hudson.util.FormValidation;
import
hudson.util.NamingThreadFactory
;
import
hudson.util.SequentialExecutionQueue
;
import
hudson.util.StreamTaskListener
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.OutputStream
;
...
...
@@ -748,5 +748,5 @@ public class SCMTrigger extends Trigger<Item> {
/**
* How long is too long for a polling activity to be in the queue?
*/
public
static
long
STARVATION_THRESHOLD
=
SystemProperties
.
getLong
(
SCMTrigger
.
class
.
getName
()+
".starvationThreshold"
,
TimeUnit
2
.
HOURS
.
toMillis
(
1
));
public
static
long
STARVATION_THRESHOLD
=
SystemProperties
.
getLong
(
SCMTrigger
.
class
.
getName
()+
".starvationThreshold"
,
TimeUnit
.
HOURS
.
toMillis
(
1
));
}
core/src/main/java/hudson/util/TimeUnit2.java
浏览文件 @
112ceeba
...
...
@@ -29,6 +29,10 @@
package
hudson.util
;
import
hudson.RestrictedSince
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
java.util.concurrent.TimeUnit
;
/**
...
...
@@ -63,7 +67,12 @@ import java.util.concurrent.TimeUnit;
*
* @since 1.5
* @author Doug Lea
* @deprecated use {@link TimeUnit}. (Java 5 did not have all the units required, so {@link TimeUnit2} was introduced
* because it had better conversion until Java 6 went out.)
*/
@Deprecated
@RestrictedSince
(
"TODO"
)
@Restricted
(
NoExternalUse
.
class
)
public
enum
TimeUnit2
{
NANOSECONDS
{
@Override
public
long
toNanos
(
long
d
)
{
return
d
;
}
...
...
core/src/main/java/jenkins/model/AssetManager.java
浏览文件 @
112ceeba
...
...
@@ -2,7 +2,7 @@ package jenkins.model;
import
hudson.Extension
;
import
hudson.model.UnprotectedRootAction
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
org.jenkinsci.Symbol
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerResponse
;
...
...
@@ -60,7 +60,7 @@ public class AssetManager implements UnprotectedRootAction {
// to create unique URLs. Recognize that and set a long expiration header.
String
requestPath
=
req
.
getRequestURI
().
substring
(
req
.
getContextPath
().
length
());
boolean
staticLink
=
requestPath
.
startsWith
(
"/static/"
);
long
expires
=
staticLink
?
TimeUnit
2
.
DAYS
.
toMillis
(
365
)
:
-
1
;
long
expires
=
staticLink
?
TimeUnit
.
DAYS
.
toMillis
(
365
)
:
-
1
;
// use serveLocalizedFile to support automatic locale selection
rsp
.
serveLocalizedFile
(
req
,
resource
,
expires
);
...
...
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
112ceeba
...
...
@@ -165,7 +165,7 @@ import hudson.util.PluginServletFilter;
import
hudson.util.RemotingDiagnostics
;
import
hudson.util.RemotingDiagnostics.HeapDump
;
import
hudson.util.TextFile
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
hudson.util.VersionNumber
;
import
hudson.util.XStream2
;
import
hudson.views.DefaultMyViewsTabBar
;
...
...
@@ -900,7 +900,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
// JSON binding needs to be able to see all the classes from all the plugins
WebApp
.
get
(
servletContext
).
setClassLoader
(
pluginManager
.
uberClassLoader
);
adjuncts
=
new
AdjunctManager
(
servletContext
,
pluginManager
.
uberClassLoader
,
"adjuncts/"
+
SESSION_HASH
,
TimeUnit
2
.
DAYS
.
toMillis
(
365
));
adjuncts
=
new
AdjunctManager
(
servletContext
,
pluginManager
.
uberClassLoader
,
"adjuncts/"
+
SESSION_HASH
,
TimeUnit
.
DAYS
.
toMillis
(
365
));
try
{
ClassFilter
.
appendDefaultFilter
(
Pattern
.
compile
(
"java[.]security[.]SignedObject"
));
// TODO move to standard blacklist
...
...
@@ -951,7 +951,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
protected
void
doRun
()
throws
Exception
{
trimLabels
();
}
},
TimeUnit
2
.
MINUTES
.
toMillis
(
5
),
TimeUnit2
.
MINUTES
.
toMillis
(
5
),
TimeUnit
.
MILLISECONDS
);
},
TimeUnit
.
MINUTES
.
toMillis
(
5
),
TimeUnit
.
MINUTES
.
toMillis
(
5
),
TimeUnit
.
MILLISECONDS
);
updateComputerList
();
...
...
test/src/test/java/hudson/model/JobTest.java
浏览文件 @
112ceeba
...
...
@@ -34,7 +34,7 @@ import com.gargoylesoftware.htmlunit.TextPage;
import
hudson.Functions
;
import
hudson.model.queue.QueueTaskFuture
;
import
hudson.util.TextFile
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
java.io.IOException
;
import
java.net.HttpURLConnection
;
import
java.text.MessageFormat
;
...
...
test/src/test/java/hudson/model/UpdateCenterTest.java
浏览文件 @
112ceeba
...
...
@@ -24,7 +24,7 @@
package
hudson.model
;
import
com.trilead.ssh2.crypto.Base64
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
net.sf.json.JSONObject
;
import
java.io.ByteArrayInputStream
;
...
...
@@ -67,7 +67,7 @@ public class UpdateCenterTest {
JSONObject
signature
=
json
.
getJSONObject
(
"signature"
);
for
(
Object
cert
:
signature
.
getJSONArray
(
"certificates"
))
{
X509Certificate
c
=
(
X509Certificate
)
cf
.
generateCertificate
(
new
ByteArrayInputStream
(
Base64
.
decode
(
cert
.
toString
().
toCharArray
())));
c
.
checkValidity
(
new
Date
(
System
.
currentTimeMillis
()
+
TimeUnit
2
.
DAYS
.
toMillis
(
30
)));
c
.
checkValidity
(
new
Date
(
System
.
currentTimeMillis
()
+
TimeUnit
.
DAYS
.
toMillis
(
30
)));
}
}
}
test/src/test/java/hudson/node_monitors/ClockMonitorDescriptorTest.java
浏览文件 @
112ceeba
...
...
@@ -6,7 +6,7 @@ import static org.junit.Assert.fail;
import
hudson.slaves.DumbSlave
;
import
hudson.slaves.SlaveComputer
;
import
hudson.util.ClockDifference
;
import
hudson.util.TimeUnit2
;
import
java.util.concurrent.TimeUnit
;
import
org.junit.Rule
;
import
org.junit.Test
;
...
...
@@ -32,10 +32,10 @@ public class ClockMonitorDescriptorTest {
ClockDifference
cd
=
ClockMonitor
.
DESCRIPTOR
.
monitor
(
c
);
long
diff
=
cd
.
diff
;
assertTrue
(
diff
<
TimeUnit
2
.
SECONDS
.
toMillis
(
5
));
assertTrue
(
diff
>
TimeUnit
2
.
SECONDS
.
toMillis
(-
5
));
assertTrue
(
diff
<
TimeUnit
.
SECONDS
.
toMillis
(
5
));
assertTrue
(
diff
>
TimeUnit
.
SECONDS
.
toMillis
(-
5
));
assertTrue
(
cd
.
abs
()
>=
0
);
assertTrue
(
cd
.
abs
()
<
TimeUnit
2
.
SECONDS
.
toMillis
(
5
));
assertTrue
(
cd
.
abs
()
<
TimeUnit
.
SECONDS
.
toMillis
(
5
));
assertFalse
(
cd
.
isDangerous
());
assertTrue
(
"html output too short"
,
cd
.
toHtml
().
length
()
>
0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录