Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 1ba1048

Browse files
committed
Update code to resolve review comments
Thank you @cbono!!!!
1 parent 089dadb commit 1ba1048

File tree

7 files changed

+32
-27
lines changed

7 files changed

+32
-27
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<module>spring-cloud-starter-dataflow-server</module>
7878
<module>spring-cloud-starter-dataflow-ui</module>
7979
<module>spring-cloud-dataflow-server</module>
80+
<!-- TODO: Boot3x followup -->
8081
<!-- <module>spring-cloud-dataflow-tasklauncher</module>-->
8182
<!-- <module>spring-cloud-dataflow-single-step-batch-job</module>-->
8283
<!-- <module>spring-cloud-dataflow-composed-task-runner</module>-->

spring-cloud-dataflow-server-core/pom.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050
<groupId>org.hibernate.orm</groupId>
5151
<artifactId>hibernate-micrometer</artifactId>
5252
</dependency>
53-
<dependency>
54-
<groupId>org.hibernate.orm</groupId>
55-
<artifactId>hibernate-ant</artifactId>
56-
</dependency>
5753
<dependency>
5854
<groupId>org.springframework.cloud</groupId>
5955
<artifactId>spring-cloud-dataflow-schema</artifactId>
@@ -257,6 +253,11 @@
257253
<artifactId>postgresql</artifactId>
258254
<scope>test</scope>
259255
</dependency>
256+
<dependency>
257+
<groupId>org.hibernate.orm</groupId>
258+
<artifactId>hibernate-ant</artifactId>
259+
<scope>test</scope>
260+
</dependency>
260261
</dependencies>
261262
<build>
262263
<resources>

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/batch/JobRestartRuntimeException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.cloud.dataflow.server.batch;
1818

19+
//TODO: Boot3x followup
1920
public class JobRestartRuntimeException extends RuntimeException {
2021

2122
public JobRestartRuntimeException(Long jobExecutionId, Exception cause) {

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/batch/JobStartRuntimeException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.cloud.dataflow.server.batch;
1818

19+
//TODO: Boot3x followup
1920
public class JobStartRuntimeException extends RuntimeException {
2021

2122
public JobStartRuntimeException(String jobName, Exception cause) {

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/batch/JobStopException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.cloud.dataflow.server.batch;
1818

19+
//TODO: Boot3x followup
1920
public class JobStopException extends RuntimeException {
2021

2122
public JobStopException(Long jobExecutionId, Exception cause) {

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/batch/SimpleJobService.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public SimpleJobService(SearchableJobInstanceDao jobInstanceDao, SearchableJobEx
108108
this.executionContextDao = executionContextDao;
109109
this.aggregateJobQueryDao = aggregateJobQueryDao;
110110
this.schemaVersionTarget = schemaVersionTarget;
111-
Assert.notNull(this.jobOperator = jobOperator, "jobOperator must not be null");
111+
Objects.requireNonNull(jobOperator, "jobOperator must not be null");
112+
this.jobOperator = jobOperator;
112113
}
113114

114115
/**
@@ -165,8 +166,7 @@ public JobExecution restart(Long jobExecutionId, JobParameters params) throws No
165166
try {
166167
jobExecution = new JobExecution(jobOperator.restart(jobExecutionId.longValue()));
167168
}
168-
catch (JobParametersInvalidException | JobRestartException | NoSuchJobExecutionException |
169-
JobInstanceAlreadyCompleteException e) {
169+
catch (Exception e) {
170170
throw new JobRestartRuntimeException(jobExecutionId, e);
171171
}
172172

@@ -178,14 +178,14 @@ public JobExecution launch(String jobName, JobParameters jobParameters) throws N
178178
JobExecution jobExecution;
179179

180180
if (jobOperator != null) {
181-
try {
182-
jobExecution = new JobExecution(jobOperator.start(jobName, jobParameters.toProperties()));
183-
} catch (JobInstanceAlreadyExistsException | JobParametersInvalidException e) {
184-
throw new JobStartRuntimeException(jobName, e);
185-
}
186-
} else {
181+
try {
182+
jobExecution = new JobExecution(jobOperator.start(jobName, jobParameters.toProperties()));
183+
} catch (JobInstanceAlreadyExistsException | JobParametersInvalidException e) {
184+
throw new JobStartRuntimeException(jobName, e);
185+
}
186+
} else {
187187
throw new NoSuchJobException(String.format("Unable to find job %s to launch",
188-
String.valueOf(jobName)));
188+
jobName));
189189
}
190190

191191
return jobExecution;
@@ -257,19 +257,18 @@ public int countJobs() {
257257
@Override
258258
public int stopAll() {
259259
Collection<JobExecution> result = jobExecutionDao.getRunningJobExecutions();
260-
Collection<String> jsrJobNames = getJobNames();
260+
Collection<String> jobNames = getJobNames();
261261

262262
for (JobExecution jobExecution : result) {
263-
if (jsrJobNames.contains(jobExecution.getJobInstance().getJobName())) {
264-
try {
265-
jobOperator.stop(jobExecution.getId());
266-
} catch (NoSuchJobExecutionException e) {
267-
throw new JobStopException(jobExecution.getId(), e);
268-
} catch (JobExecutionNotRunningException e) {
269-
throw new JobStopException(jobExecution.getId(), e);
270-
}
271-
} else {
272-
throw new JobStopException(jobExecution.getId());
263+
try {
264+
if (jobNames.contains(jobExecution.getJobInstance().getJobName())) {
265+
jobOperator.stop(jobExecution.getId());
266+
267+
} else {
268+
throw new JobStopException(jobExecution.getId());
269+
}
270+
} catch (Exception e) {
271+
throw new IllegalArgumentException("The following JobExecutionId was not found: " + jobExecution.getId(), e);
273272
}
274273
}
275274

@@ -309,10 +308,10 @@ public JobExecution abandon(Long jobExecutionId) throws NoSuchJobExecutionExcept
309308

310309
logger.info("Aborting job execution: " + jobExecution);
311310

312-
Collection<String> jsrJobNames = getJobNames();
311+
Collection<String> jobNames = getJobNames();
313312

314313
JobInstance jobInstance = jobExecution.getJobInstance();
315-
if (jobOperator != null && jsrJobNames.contains(jobInstance.getJobName())) {
314+
if (jobOperator != null && jobNames.contains(jobInstance.getJobName())) {
316315
jobOperator.abandon(jobExecutionId);
317316
jobExecution = getJobExecution(jobExecutionId);
318317
} else {

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/service/impl/DefaultTaskJobService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public void restartJobExecution(long jobExecutionId, String schemaTarget) throws
243243

244244
}
245245

246+
//TODO: Boot3x followup Remove boot2 check in this method once boot2 suuport code has been removed.
246247
/**
247248
* Apply identifying job parameters to arguments. There are cases (incrementers)
248249
* that add parameters to a job and thus must be added for each restart so that the

0 commit comments

Comments
 (0)