Skip to content

Commit

Permalink
Use Threadlocal.remove() instead of Threadlocal.set(null)
Browse files Browse the repository at this point in the history
Issue #4601
  • Loading branch information
Seungpang authored and fmbenhassine committed May 27, 2024
1 parent b3b4310 commit 3b9ceea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2024 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.
Expand Down Expand Up @@ -35,6 +35,7 @@
* @author Dave Syer
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @author Seungrae Kim
*
*/
public class JobFlowExecutor implements FlowExecutor {
Expand All @@ -58,7 +59,6 @@ public JobFlowExecutor(JobRepository jobRepository, StepHandler stepHandler, Job
this.jobRepository = jobRepository;
this.stepHandler = stepHandler;
this.execution = execution;
stepExecutionHolder.set(null);
}

@Override
Expand Down Expand Up @@ -118,7 +118,7 @@ public StepExecution getStepExecution() {

@Override
public void close(FlowExecution result) {
stepExecutionHolder.set(null);
stepExecutionHolder.remove();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-2024 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.
Expand Down Expand Up @@ -32,6 +32,7 @@
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Seungrae Kim
* @since 2.0
*/
public class ChunkMonitor extends ItemStreamSupport {
Expand Down Expand Up @@ -104,7 +105,7 @@ public void setChunkSize(int chunkSize) {
@Override
public void close() throws ItemStreamException {
super.close();
holder.set(null);
holder.remove();
if (streamsRegistered) {
stream.close();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2024 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.
Expand Down Expand Up @@ -30,6 +30,7 @@
* {@link RepeatOperations} implementations.
*
* @author Dave Syer
* @author Seungrae Kim
*
*/
public final class RepeatSynchronizationManager {
Expand Down Expand Up @@ -70,7 +71,7 @@ public static void setCompleteOnly() {
*/
public static RepeatContext register(RepeatContext context) {
RepeatContext oldSession = getContext();
RepeatSynchronizationManager.contextHolder.set(context);
contextHolder.set(context);
return oldSession;
}

Expand All @@ -81,7 +82,7 @@ public static RepeatContext register(RepeatContext context) {
*/
public static RepeatContext clear() {
RepeatContext context = getContext();
RepeatSynchronizationManager.contextHolder.set(null);
contextHolder.remove();
return context;
}

Expand Down

0 comments on commit 3b9ceea

Please sign in to comment.