Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
560ffc90
Commit
560ffc90
authored
Aug 26, 2015
by
james
Committed by
Stephane Nicoll
Sep 02, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not attempt to restart non-restartable jobs
Closes gh-3830
parent
cd1ace0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
JobLauncherCommandLineRunner.java
...oot/autoconfigure/batch/JobLauncherCommandLineRunner.java
+1
-1
JobLauncherCommandLineRunnerTests.java
...utoconfigure/batch/JobLauncherCommandLineRunnerTests.java
+20
-2
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java
View file @
560ffc90
...
...
@@ -144,7 +144,7 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
parameters
=
incrementer
.
getNext
(
new
JobParameters
());
}
}
else
if
(
isStoppedOrFailed
(
previousExecution
))
{
else
if
(
isStoppedOrFailed
(
previousExecution
)
&&
job
.
isRestartable
()
)
{
// Retry a failed or stopped execution
parameters
=
previousExecution
.
getJobParameters
();
// Non-identifying additional parameters can be added to a retry
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java
View file @
560ffc90
...
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
batch
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.batch.core.Job
;
...
...
@@ -43,8 +45,6 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.core.task.SyncTaskExecutor
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Tests for {@link JobLauncherCommandLineRunner}.
*
...
...
@@ -124,6 +124,24 @@ public class JobLauncherCommandLineRunnerTests {
assertEquals
(
1
,
this
.
jobExplorer
.
getJobInstances
(
"job"
,
0
,
100
).
size
());
}
@Test
public
void
retryFailedExecutionOnNonRestartableJob
()
throws
Exception
{
this
.
job
=
this
.
jobs
.
get
(
"job"
).
preventRestart
()
.
start
(
this
.
steps
.
get
(
"step"
).
tasklet
(
new
Tasklet
()
{
@Override
public
RepeatStatus
execute
(
StepContribution
contribution
,
ChunkContext
chunkContext
)
throws
Exception
{
throw
new
RuntimeException
(
"Planned"
);
}
}).
build
()).
incrementer
(
new
RunIdIncrementer
()).
build
();
this
.
runner
.
execute
(
this
.
job
,
new
JobParameters
());
this
.
runner
.
execute
(
this
.
job
,
new
JobParameters
());
/* A failed job that is not restartable does not re-use the job params of
* the last execution, but creates a new job instance when running it again.
*/
assertEquals
(
2
,
this
.
jobExplorer
.
getJobInstances
(
"job"
,
0
,
100
).
size
());
}
@Test
public
void
retryFailedExecutionWithNonIdentifyingParameters
()
throws
Exception
{
this
.
job
=
this
.
jobs
.
get
(
"job"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment