This is an automated email from the ASF dual-hosted git repository.
cegerton pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 32bcdac6a18 MINOR: Replace synchronization with atomic update in
Connect's StateTracker::changeState method (#13934)
32bcdac6a18 is described below
commit 32bcdac6a187939efe879ed275ee23d3dfc6fe63
Author: Yash Mayya <[email protected]>
AuthorDate: Thu Jun 29 20:05:06 2023 +0100
MINOR: Replace synchronization with atomic update in Connect's
StateTracker::changeState method (#13934)
Reviewers: Chris Egerton <[email protected]>
---
.../main/java/org/apache/kafka/connect/runtime/StateTracker.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git
a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/StateTracker.java
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/StateTracker.java
index 23ac3eac32f..7c10f42148e 100644
---
a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/StateTracker.java
+++
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/StateTracker.java
@@ -30,16 +30,12 @@ public class StateTracker {
/**
* Change the current state.
- * <p>
- * This method is synchronized to ensure that all state changes are
captured correctly and in the same order.
- * Synchronization is acceptable since it is assumed that state changes
will be relatively infrequent.
*
* @param newState the current state; may not be null
* @param now the current time in milliseconds
*/
- public synchronized void changeState(State newState, long now) {
- // JDK8: remove synchronization by using
lastState.getAndUpdate(oldState->oldState.newState(newState, now));
- lastState.set(lastState.get().newState(newState, now));
+ public void changeState(State newState, long now) {
+ lastState.getAndUpdate(oldState -> oldState.newState(newState, now));
}
/**