Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Meiracle
spring-framework
提交
27bfcbbc
S
spring-framework
项目概览
Meiracle
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
27bfcbbc
编写于
4月 20, 2021
作者:
A
Arjen Poutsma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix daylight saving issue in CronExpression
Closes gh-26830
上级
b153b5e5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
16 deletion
+24
-16
spring-context/src/main/java/org/springframework/scheduling/support/CronField.java
...ava/org/springframework/scheduling/support/CronField.java
+12
-6
spring-context/src/main/java/org/springframework/scheduling/support/QuartzCronField.java
...g/springframework/scheduling/support/QuartzCronField.java
+1
-7
spring-context/src/test/java/org/springframework/scheduling/support/CronExpressionTests.java
...ringframework/scheduling/support/CronExpressionTests.java
+8
-0
spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java
.../springframework/scheduling/support/CronTriggerTests.java
+3
-3
未找到文件。
spring-context/src/main/java/org/springframework/scheduling/support/CronField.java
浏览文件 @
27bfcbbc
...
...
@@ -157,6 +157,11 @@ abstract class CronField {
return
this
.
type
;
}
@SuppressWarnings
(
"unchecked"
)
protected
static
<
T
extends
Temporal
&
Comparable
<?
super
T
>>
T
cast
(
Temporal
temporal
)
{
return
(
T
)
temporal
;
}
/**
* Represents the type of cron field, i.e. seconds, minutes, hours,
...
...
@@ -236,16 +241,17 @@ abstract class CronField {
*/
public
<
T
extends
Temporal
&
Comparable
<?
super
T
>>
T
elapseUntil
(
T
temporal
,
int
goal
)
{
int
current
=
get
(
temporal
);
ValueRange
range
=
temporal
.
range
(
this
.
field
);
if
(
current
<
goal
)
{
T
result
=
this
.
field
.
getBaseUnit
().
addTo
(
temporal
,
goal
-
current
);
current
=
get
(
result
);
if
(
current
>
goal
)
{
// can occur due to daylight saving, see gh-26744
result
=
this
.
field
.
getBaseUnit
().
addTo
(
result
,
goal
-
current
);
if
(
range
.
isValidIntValue
(
goal
))
{
return
cast
(
temporal
.
with
(
this
.
field
,
goal
));
}
else
{
// goal is invalid, eg. 29th Feb, lets try to get as close as possible
return
this
.
field
.
getBaseUnit
().
addTo
(
temporal
,
goal
-
current
);
}
return
result
;
}
else
{
ValueRange
range
=
temporal
.
range
(
this
.
field
);
long
amount
=
goal
+
range
.
getMaximum
()
-
current
+
1
-
range
.
getMinimum
();
return
this
.
field
.
getBaseUnit
().
addTo
(
temporal
,
amount
);
}
...
...
spring-context/src/main/java/org/springframework/scheduling/support/QuartzCronField.java
浏览文件 @
27bfcbbc
/*
* Copyright 2002-202
0
the original author or authors.
* Copyright 2002-202
1
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -326,12 +326,6 @@ final class QuartzCronField extends CronField {
}
}
@SuppressWarnings
(
"unchecked"
)
private
static
<
T
extends
Temporal
&
Comparable
<?
super
T
>>
T
cast
(
Temporal
temporal
)
{
return
(
T
)
temporal
;
}
@Override
public
<
T
extends
Temporal
&
Comparable
<?
super
T
>>
T
nextOrSame
(
T
temporal
)
{
T
result
=
adjust
(
temporal
);
...
...
spring-context/src/test/java/org/springframework/scheduling/support/CronExpressionTests.java
浏览文件 @
27bfcbbc
...
...
@@ -1276,6 +1276,14 @@ class CronExpressionTests {
actual
=
cronExpression
.
next
(
last
);
assertThat
(
actual
).
isNotNull
();
assertThat
(
actual
).
isEqualTo
(
expected
);
cronExpression
=
CronExpression
.
parse
(
"0 10 2 * * *"
);
last
=
ZonedDateTime
.
parse
(
"2013-03-31T01:09:00+01:00[Europe/Amsterdam]"
);
expected
=
ZonedDateTime
.
parse
(
"2013-04-01T02:10:00+02:00[Europe/Amsterdam]"
);
actual
=
cronExpression
.
next
(
last
);
assertThat
(
actual
).
isNotNull
();
assertThat
(
actual
).
isEqualTo
(
expected
);
}
...
...
spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java
浏览文件 @
27bfcbbc
...
...
@@ -822,13 +822,13 @@ class CronTriggerTests {
// 2:00 AM on March 31, 2013: start of Daylight Saving Time for CET in 2013.
// Setting up last completion:
// - PST: Sun Mar 31 10:
10
:54 CEST 2013
// - CET: Sun Mar 31 01:
10
:54 CET 2013
// - PST: Sun Mar 31 10:
09
:54 CEST 2013
// - CET: Sun Mar 31 01:
09
:54 CET 2013
this
.
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
31
);
this
.
calendar
.
set
(
Calendar
.
MONTH
,
Calendar
.
MARCH
);
this
.
calendar
.
set
(
Calendar
.
YEAR
,
2013
);
this
.
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
1
);
this
.
calendar
.
set
(
Calendar
.
MINUTE
,
10
);
// changing to any minute from 0-9 causes the test to fail for CET.
this
.
calendar
.
set
(
Calendar
.
MINUTE
,
9
);
this
.
calendar
.
set
(
Calendar
.
SECOND
,
54
);
Date
lastCompletionTime
=
this
.
calendar
.
getTime
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录