curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jordan Zimmerman (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CURATOR-108) Wrong usage of Arrays.equals in DistributedAtomicValue for values equality test
Date Fri, 23 May 2014 15:21:01 GMT

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

Jordan Zimmerman edited comment on CURATOR-108 at 5/23/14 3:19 PM:
-------------------------------------------------------------------

I don't think this is the right approach. What would be better is a way to set a default value
for a fresh DAV.  For example, DistributedAtomicValue's constructor (or a setter) could take
the default value, then getCurrentValue() would return that default if the current value is
empty.


was (Author: randgalt):
I don't think this is the right approach. What would be better is a way to set a default value
for a fresh DAV. 

> Wrong usage of Arrays.equals in DistributedAtomicValue for values equality test
> -------------------------------------------------------------------------------
>
>                 Key: CURATOR-108
>                 URL: https://issues.apache.org/jira/browse/CURATOR-108
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>            Reporter: Alex Lopashev
>            Priority: Critical
>              Labels: easyfix
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Without setting value ZooKeeper DistributedAtomicValue instance returns byte[0]{} as
its value, but in #compareAndSet method expectedValue is always non-zero-sized byte array,
so in fresh new DistributedAtomicValue with no data in ZooKeeper node test Arrays.equals(byte[4]{0,0,0,0},
byte[0]{}) for integer and Arrays.equals(byte[8]{0,0,0,0,0,0,0,0}, byte[0]{}) will always
fail. Solution is to not only check with Arrays.equals, but also if one of byte arrays is
empty then check if second one has only zero elements.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message