You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "daye nam (Jira)" <ji...@apache.org> on 2020/01/21 23:02:00 UTC
[jira] [Updated] (AMQ-7378) Potential shift issue in KahaDB's
JobLocation Hash function
[ https://issues.apache.org/jira/browse/AMQ-7378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
daye nam updated AMQ-7378:
--------------------------
Description:
Hello,
```
@Override
public int hashCode()
{ final int prime = 31; int result = 1; result = prime * result + ((cronEntry == null) ? 0 : cronEntry.hashCode()); result = prime * result + (int) (delay ^ (delay >>> 32)); result = prime * result + ((jobId == null) ? 0 : jobId.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode()); result = prime * result + (int) (nextTime ^ (nextTime >>> 32)); result = prime * result + (int) (period ^ (period >>> 32)); result = prime * result + repeat; result = prime * result + (int) (startTime ^ (startTime >>> 32)); result = prime * result + (rescheduledCount ^ (rescheduledCount >>> 32)); return result; }
```
I found out that a hashcode function of ```activemq/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/scheduler/JobLocation.java``` contains a minor issue with shift (>>>):
(According to the Java specification)[[https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.19]|#jls-15.19]], when a type of a left-hand argument is a primitive int, the shift distance used should be always in the range 0 to 31, but ```rescheduledCount``` was shifted by 32, which could be a potential issue.
This did not generated an actual bug, so it might not be an issue with high priority. Please feel free to ignore this, but I thought there is no harm to report this.
Thank you!
was:
Hello,
```
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((cronEntry == null) ? 0 : cronEntry.hashCode());
result = prime * result + (int) (delay ^ (delay >>> 32));
result = prime * result + ((jobId == null) ? 0 : jobId.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + (int) (nextTime ^ (nextTime >>> 32));
result = prime * result + (int) (period ^ (period >>> 32));
result = prime * result + repeat;
result = prime * result + (int) (startTime ^ (startTime >>> 32));
result = prime * result + (rescheduledCount ^ (rescheduledCount >>> 32));
return result;
}
```
I found out that a hashcode function of ```[root|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/?sort=name&dir=ASC&mode=heatmap]/[activemq-kahadb-store|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/?sort=name&dir=ASC&mode=heatmap]/[src|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/?sort=name&dir=ASC&mode=heatmap]/[main|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/?sort=name&dir=ASC&mode=heatmap]/[java|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/java/?sort=name&dir=ASC&mode=heatmap]/[org|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/java/org/?sort=name&dir=ASC&mode=heatmap]/[apache|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/java/org/apache/?sort=name&dir=ASC&mode=heatmap]/[activemq|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/java/org/apache/activemq/?sort=name&dir=ASC&mode=heatmap]/[store|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/java/org/apache/activemq/store/?sort=name&dir=ASC&mode=heatmap]/[kahadb|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/?sort=name&dir=ASC&mode=heatmap]/[scheduler|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/scheduler/?sort=name&dir=ASC&mode=heatmap]/[JobLocation.java|https://lgtm.com/projects/g/apache/activemq/snapshot/9cc13826aae42bc34e2208f611230ae43da7019f/files/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/scheduler/JobLocation.java?sort=name&dir=ASC&mode=heatmap]``` contains a minor issue with shift (>>>):
(According to the Java specification)[[https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.19]], when a type of a left-hand argument is a primitive int, the shift distance used should be always in the range 0 to 31, but ```rescheduledCount``` was shifted by 32, which could be a potential issue.
This did not generated an actual bug, so it might not be an issue with high priority. Please feel free to ignore this, but I thought there is no harm to report this.
Thank you!
> Potential shift issue in KahaDB's JobLocation Hash function
> -----------------------------------------------------------
>
> Key: AMQ-7378
> URL: https://issues.apache.org/jira/browse/AMQ-7378
> Project: ActiveMQ
> Issue Type: Bug
> Reporter: daye nam
> Priority: Trivial
>
> Hello,
> ```
> @Override
> public int hashCode()
> { final int prime = 31; int result = 1; result = prime * result + ((cronEntry == null) ? 0 : cronEntry.hashCode()); result = prime * result + (int) (delay ^ (delay >>> 32)); result = prime * result + ((jobId == null) ? 0 : jobId.hashCode()); result = prime * result + ((location == null) ? 0 : location.hashCode()); result = prime * result + (int) (nextTime ^ (nextTime >>> 32)); result = prime * result + (int) (period ^ (period >>> 32)); result = prime * result + repeat; result = prime * result + (int) (startTime ^ (startTime >>> 32)); result = prime * result + (rescheduledCount ^ (rescheduledCount >>> 32)); return result; }
> ```
>
> I found out that a hashcode function of ```activemq/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/scheduler/JobLocation.java``` contains a minor issue with shift (>>>):
> (According to the Java specification)[[https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.19]|#jls-15.19]], when a type of a left-hand argument is a primitive int, the shift distance used should be always in the range 0 to 31, but ```rescheduledCount``` was shifted by 32, which could be a potential issue.
> This did not generated an actual bug, so it might not be an issue with high priority. Please feel free to ignore this, but I thought there is no harm to report this.
>
> Thank you!
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)