Use Threadlocal.remove() instead of Threadlocal.set(null)

Issue #4601
This commit is contained in:
Seungrae
2024-05-23 02:53:28 +09:00
committed by Mahmoud Ben Hassine
parent b3b4310a5f
commit 3b9ceea0b4
3 changed files with 10 additions and 8 deletions

View File

@@ -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.
@@ -35,6 +35,7 @@ import org.springframework.lang.Nullable;
* @author Dave Syer
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @author Seungrae Kim
*
*/
public class JobFlowExecutor implements FlowExecutor {
@@ -58,7 +59,6 @@ public class JobFlowExecutor implements FlowExecutor {
this.jobRepository = jobRepository;
this.stepHandler = stepHandler;
this.execution = execution;
stepExecutionHolder.set(null);
}
@Override
@@ -118,7 +118,7 @@ public class JobFlowExecutor implements FlowExecutor {
@Override
public void close(FlowExecution result) {
stepExecutionHolder.set(null);
stepExecutionHolder.remove();
}
@Override

View File

@@ -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.
@@ -32,6 +32,7 @@ import org.springframework.batch.item.support.CompositeItemStream;
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @author Seungrae Kim
* @since 2.0
*/
public class ChunkMonitor extends ItemStreamSupport {
@@ -104,7 +105,7 @@ public class ChunkMonitor extends ItemStreamSupport {
@Override
public void close() throws ItemStreamException {
super.close();
holder.set(null);
holder.remove();
if (streamsRegistered) {
stream.close();
}

View File

@@ -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.
@@ -30,6 +30,7 @@ import org.springframework.batch.repeat.RepeatOperations;
* {@link RepeatOperations} implementations.
*
* @author Dave Syer
* @author Seungrae Kim
*
*/
public final class RepeatSynchronizationManager {
@@ -70,7 +71,7 @@ public final class RepeatSynchronizationManager {
*/
public static RepeatContext register(RepeatContext context) {
RepeatContext oldSession = getContext();
RepeatSynchronizationManager.contextHolder.set(context);
contextHolder.set(context);
return oldSession;
}
@@ -81,7 +82,7 @@ public final class RepeatSynchronizationManager {
*/
public static RepeatContext clear() {
RepeatContext context = getContext();
RepeatSynchronizationManager.contextHolder.set(null);
contextHolder.remove();
return context;
}