[ 
https://issues.apache.org/jira/browse/KAFKA-5054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16690707#comment-16690707
 ] 

ASF GitHub Bot commented on KAFKA-5054:
---------------------------------------

guozhangwang closed pull request #5873: KAFKA-5054 : synchronized all the 
methods
URL: https://github.com/apache/kafka/pull/5873
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/streams/src/main/java/org/apache/kafka/streams/state/internals/ChangeLoggingKeyValueBytesStore.java
 
b/streams/src/main/java/org/apache/kafka/streams/state/internals/ChangeLoggingKeyValueBytesStore.java
index 1d8fb5806be..6f853baa6ed 100644
--- 
a/streams/src/main/java/org/apache/kafka/streams/state/internals/ChangeLoggingKeyValueBytesStore.java
+++ 
b/streams/src/main/java/org/apache/kafka/streams/state/internals/ChangeLoggingKeyValueBytesStore.java
@@ -61,13 +61,13 @@ public long approximateNumEntries() {
     }
 
     @Override
-    public void put(final Bytes key, final byte[] value) {
+    public synchronized void put(final Bytes key, final byte[] value) {
         inner.put(key, value);
         changeLogger.logChange(key, value);
     }
 
     @Override
-    public byte[] putIfAbsent(final Bytes key, final byte[] value) {
+    public synchronized byte[] putIfAbsent(final Bytes key, final byte[] 
value) {
         final byte[] previous = get(key);
         if (previous == null) {
             put(key, value);
@@ -76,7 +76,7 @@ public void put(final Bytes key, final byte[] value) {
     }
 
     @Override
-    public void putAll(final List<KeyValue<Bytes, byte[]>> entries) {
+    public synchronized void putAll(final List<KeyValue<Bytes, byte[]>> 
entries) {
         inner.putAll(entries);
         for (final KeyValue<Bytes, byte[]> entry : entries) {
             changeLogger.logChange(entry.key, entry.value);
@@ -84,24 +84,24 @@ public void putAll(final List<KeyValue<Bytes, byte[]>> 
entries) {
     }
 
     @Override
-    public byte[] delete(final Bytes key) {
+    public synchronized byte[] delete(final Bytes key) {
         final byte[] oldValue = inner.delete(key);
         changeLogger.logChange(key, null);
         return oldValue;
     }
 
     @Override
-    public byte[] get(final Bytes key) {
+    public synchronized byte[] get(final Bytes key) {
         return inner.get(key);
     }
 
     @Override
-    public KeyValueIterator<Bytes, byte[]> range(final Bytes from, final Bytes 
to) {
+    public synchronized KeyValueIterator<Bytes, byte[]> range(final Bytes 
from, final Bytes to) {
         return inner.range(from, to);
     }
 
     @Override
-    public KeyValueIterator<Bytes, byte[]> all() {
+    public synchronized KeyValueIterator<Bytes, byte[]> all() {
         return inner.all();
     }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> ChangeLoggingKeyValueByteStore delete and putIfAbsent should be synchronized
> ----------------------------------------------------------------------------
>
>                 Key: KAFKA-5054
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5054
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>    Affects Versions: 0.10.2.0
>            Reporter: Damian Guy
>            Assignee: Liju
>            Priority: Critical
>
> {{putIfAbsent}} and {{delete}} should be synchronized as they involve at 
> least 2 operations on the underlying store and may result in inconsistent 
> results if someone were to query via IQ



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to