Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » HashPartitioningPolicy fails for large IDs of type long(reason: remainder function returns negative result)
HashPartitioningPolicy fails for large IDs of type long [message #916123] Tue, 18 September 2012 15:19 Go to next message
Alexander Bätz is currently offline Alexander BätzFriend
Messages: 6
Registered: August 2012
Junior Member
I'm toying with eclipse link partitioning for my current project. we have an id generator that is base on the twitter id schema (first x bits = timestamp (seconds), 10 bits machine id, rest counter per second)

this means our ids are pretty large by default. the hashpartitioningpolicy uses the following line to find the target server:

int index = value.hashCode() % this.connectionPools.size();

in java % is the remainder function that can be negative IF value.hashCode() returns a negative value (its not a real modulo). since our Long ids are large the resulting hash code can indeed become negative, which causes a negative index, which causes an ArrayIndexOutOfBoundsException.

I'm going to work around this by implementing my own custom policy but this really should be fixed.

Re: HashPartitioningPolicy fails for large IDs of type long [message #923001 is a reply to message #916123] Tue, 25 September 2012 14:27 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This is a bug.

It will hopefully be fixed soon.

James : Wiki : Book : Blog : Twitter

[Updated on: Tue, 25 September 2012 14:28]

Report message to a moderator

Previous Topic:NPE in MethodAttributeAccessor.getAttributeValueFromObject()
Next Topic:EclipseLink/Toplink Cache coordination using JMS for manual DB updates
Goto Forum:

Current Time: Wed Oct 24 05:26:32 GMT 2018

Powered by FUDForum. Page generated in 0.01961 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top