This is an automated email from the ASF dual-hosted git repository.

cegerton pushed a commit to branch 3.5
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/3.5 by this push:
     new 7fe5dccc112 MINOR: Replace synchronization with atomic update in 
Connect's StateTracker::changeState method (#13934)
7fe5dccc112 is described below

commit 7fe5dccc11263be42868a9c4d7373e44bf8891e4
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));
     }
 
     /**

Reply via email to