Skip to content

Commit 3b9ceea

Browse files
Seungpangfmbenhassine
authored andcommitted
Use Threadlocal.remove() instead of Threadlocal.set(null)
Issue #4601
1 parent b3b4310 commit 3b9ceea

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2024 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.
@@ -35,6 +35,7 @@
3535
* @author Dave Syer
3636
* @author Michael Minella
3737
* @author Mahmoud Ben Hassine
38+
* @author Seungrae Kim
3839
*
3940
*/
4041
public class JobFlowExecutor implements FlowExecutor {
@@ -58,7 +59,6 @@ public JobFlowExecutor(JobRepository jobRepository, StepHandler stepHandler, Job
5859
this.jobRepository = jobRepository;
5960
this.stepHandler = stepHandler;
6061
this.execution = execution;
61-
stepExecutionHolder.set(null);
6262
}
6363

6464
@Override
@@ -118,7 +118,7 @@ public StepExecution getStepExecution() {
118118

119119
@Override
120120
public void close(FlowExecution result) {
121-
stepExecutionHolder.set(null);
121+
stepExecutionHolder.remove();
122122
}
123123

124124
@Override

spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkMonitor.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-2024 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.
@@ -32,6 +32,7 @@
3232
*
3333
* @author Dave Syer
3434
* @author Mahmoud Ben Hassine
35+
* @author Seungrae Kim
3536
* @since 2.0
3637
*/
3738
public class ChunkMonitor extends ItemStreamSupport {
@@ -104,7 +105,7 @@ public void setChunkSize(int chunkSize) {
104105
@Override
105106
public void close() throws ItemStreamException {
106107
super.close();
107-
holder.set(null);
108+
holder.remove();
108109
if (streamsRegistered) {
109110
stream.close();
110111
}

spring-batch-infrastructure/src/main/java/org/springframework/batch/repeat/support/RepeatSynchronizationManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2007 the original author or authors.
2+
* Copyright 2006-2024 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.
@@ -30,6 +30,7 @@
3030
* {@link RepeatOperations} implementations.
3131
*
3232
* @author Dave Syer
33+
* @author Seungrae Kim
3334
*
3435
*/
3536
public final class RepeatSynchronizationManager {
@@ -70,7 +71,7 @@ public static void setCompleteOnly() {
7071
*/
7172
public static RepeatContext register(RepeatContext context) {
7273
RepeatContext oldSession = getContext();
73-
RepeatSynchronizationManager.contextHolder.set(context);
74+
contextHolder.set(context);
7475
return oldSession;
7576
}
7677

@@ -81,7 +82,7 @@ public static RepeatContext register(RepeatContext context) {
8182
*/
8283
public static RepeatContext clear() {
8384
RepeatContext context = getContext();
84-
RepeatSynchronizationManager.contextHolder.set(null);
85+
contextHolder.remove();
8586
return context;
8687
}
8788

0 commit comments

Comments
 (0)