Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 30b5120

Browse files
sjiwonfmbenhassine
authored andcommitted
Use type-safe constants in ExitStatus#isRunning
Signed-off-by: sjiwon <sjiwon4491@gmail.com>
1 parent b9b08bf commit 30b5120

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

‎spring-batch-core/src/main/java/org/springframework/batch/core/ExitStatus.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2023 the original author or authors.
2+
* Copyright 2006-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
*
3030
* @author Dave Syer
3131
* @author Mahmoud Ben Hassine
32+
* @author JiWon Seo
3233
*
3334
*/
3435
public class ExitStatus implements Serializable, Comparable<ExitStatus> {
@@ -231,7 +232,7 @@ public ExitStatus replaceExitCode(String code) {
231232
* @return {@code true} if the exit code is {@code EXECUTING} or {@code UNKNOWN}.
232233
*/
233234
public boolean isRunning() {
234-
return "EXECUTING".equals(this.exitCode) || "UNKNOWN".equals(this.exitCode);
235+
return EXECUTING.exitCode.equals(this.exitCode) || UNKNOWN.exitCode.equals(this.exitCode);
235236
}
236237

237238
/**

‎spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2024 the original author or authors.
2+
* Copyright 2006-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
3333
/**
3434
* @author Dave Syer
3535
* @author Mahmoud Ben Hassine
36+
* @author JiWon Seo
3637
*
3738
*/
3839
class ExitStatusTests {
@@ -153,7 +154,7 @@ void testAddExitDescription() {
153154
}
154155

155156
@Test
156-
void testAddExitDescriptionWIthStacktrace() {
157+
void testAddExitDescriptionWithStacktrace() {
157158
ExitStatus status = ExitStatus.EXECUTING.addExitDescription(new RuntimeException("Foo"));
158159
assertNotSame(ExitStatus.EXECUTING, status);
159160
String description = status.getExitDescription();
@@ -182,8 +183,15 @@ void testAddExitCodeWithDescription() {
182183
}
183184

184185
@Test
185-
void testUnknownIsRunning() {
186+
void testIsRunning() {
187+
// running statuses
188+
assertTrue(ExitStatus.EXECUTING.isRunning());
186189
assertTrue(ExitStatus.UNKNOWN.isRunning());
190+
// non running statuses
191+
assertFalse(ExitStatus.COMPLETED.isRunning());
192+
assertFalse(ExitStatus.FAILED.isRunning());
193+
assertFalse(ExitStatus.STOPPED.isRunning());
194+
assertFalse(ExitStatus.NOOP.isRunning());
187195
}
188196

189197
@Test

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /