[
https://issues.apache.org/jira/browse/AMQ-7378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
daye nam updated AMQ-7378:
--------------------------
Description:
Hello,
{code:java}
private int rescheduledCount;
...
@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;
}
{code}
I found out that a hashcode function of Kaha DB's JobLocation.java contains a
minor issue with shift (>>>):
[According to the Java specification|#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,
{code:java}
private int rescheduledCount;
...
@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;
}
{code}
I found out that a hashcode function of Kaha DB's
[JobLocation|[https://github.com/apache/activemq/blob/9abe2c6f97c92fc99c5a2ef02846f62002a671cf/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|#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,
>
> {code:java}
> private int rescheduledCount;
> ...
> @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;
> }
> {code}
>
>
> I found out that a hashcode function of Kaha DB's JobLocation.java contains a
> minor issue with shift (>>>):
> [According to the Java specification|#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)