[
https://issues.apache.org/jira/browse/ROCKETMQ-74?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15837128#comment-15837128
]
ASF GitHub Bot commented on ROCKETMQ-74:
----------------------------------------
Github user zhouxinyu commented on a diff in the pull request:
https://github.com/apache/incubator-rocketmq/pull/50#discussion_r97704748
--- Diff: common/src/main/java/org/apache/rocketmq/common/DataVersion.java
---
@@ -58,16 +58,28 @@ public boolean equals(final Object o) {
final DataVersion that = (DataVersion) o;
- if (timestatmp != that.timestatmp)
+ if (timestamp != that.timestamp)
return false;
- return counter != null ? counter.equals(that.counter) :
that.counter == null;
+
+ if (null == counter && null == that.counter) {
+ return true;
+ }
+
+ if (counter != null && that.counter == null || counter == null) {
+ return false;
+ }
+
--- End diff --
I have a advise, when compare the `counter`, below code is more readable:
```java
if (counter != null && that.counter != null) {
return counter.longValue() == that.counter.longValue();
}
return counter == that.counter;
```
> DataVersion equals not working as expected.
> -------------------------------------------
>
> Key: ROCKETMQ-74
> URL: https://issues.apache.org/jira/browse/ROCKETMQ-74
> Project: Apache RocketMQ
> Issue Type: Bug
> Components: rocketmq-broker, rocketmq-namesrv
> Affects Versions: 4.0.0-incubating, 4.1.0-incubating
> Environment: All
> Reporter: Zhanhui Li
> Assignee: yukon
> Fix For: 4.1.0-incubating
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> DataVersion equals method assumes that AtomicLong's equals method comparing
> by value. This assumption turns out invalid.
> This brings about a few issues, say, wipeWritePerm command would not be
> working as expected as perm will be overridden in 30s at most.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)