Re: [POOL2] Pooling mutable objects

2015-02-06 Thread William Speirs
I'd think adding a UUID then overriding equals and hashCode would do the trick. To aid you in doing this, commons-lang has EqualsBuilder [1] and HashCodeBuilder [2], I highly recommend using them. Bill- [1]

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread Michael Osipov
This is what I did: this.internalId = RandomStringUtils.randomAlphanumeric(8); Some Eclipse magic: @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((internalId == null) ? 0 :

Re: [POOL2] Pooling mutable objects

2015-02-06 Thread James Carman
Or just let your IDE generate the methods. On Fri, Feb 6, 2015 at 9:05 AM, William Speirs wspe...@apache.org wrote: I'd think adding a UUID then overriding equals and hashCode would do the trick. To aid you in doing this, commons-lang has EqualsBuilder [1] and HashCodeBuilder [2], I highly

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread James Carman
Try UUID.randomUUID().toString() rather than RandomStringUtils if you really want unique keys. On Fri, Feb 6, 2015 at 10:54 AM, Michael Osipov 1983-01...@gmx.net wrote: This is what I did: this.internalId = RandomStringUtils.randomAlphanumeric(8); Some Eclipse magic: @Override

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread William Speirs
I'm not sure I understand your comment Mat. From what I can tell, Michael made his own hash function. That's fine, but *might* have unexpected collision issues. Might not too... I don't know. My guess though is that he's not an expert (who is an expert on hash functions?) and might unknowingly

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread Mat Jaggard
He didn't create his own hash function, he generated it in eclipse. This is better because you get all the testing of other eclipse users without any runtime dependencies. On 6 February 2015 at 16:16, William Speirs wspe...@apache.org wrote: I'm not sure I understand your comment Mat. From what

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread sebb
The existing Pool2 implementations use equals() to decide if two objects are the same. You have to make sure that your equals() implementation returns true if and only if the objects being compared are the same as far as your use of them is concerned. So for example two Integers are equal if they

[POOL2] Pooling mutable objects

2015-02-06 Thread Michael Osipov
Hi folks, I am developing a session pool for an HTTP backend which is requested with the fabulous HttpClient. The session object is this: public class RawSession { private CookieStore cookieStore; private String logId; private MutableInt requestId; private

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread Jörg Schaible
Hi William, William Speirs wrote: I'm not sure I understand your comment Mat. From what I can tell, Michael made his own hash function. That's fine, but *might* have unexpected collision issues. Might not too... I don't know. My guess though is that he's not an expert (who is an expert on

Re: [POOL2] Pooling mutable objects

2015-02-06 Thread Phil Steitz
On 2/6/15 10:16 AM, sebb wrote: The existing Pool2 implementations use equals() to decide if two objects are the same. As of pool 2.3. You have to make sure that your equals() implementation returns true if and only if the objects being compared are the same as far as your use of them is