Re: [POOL2] Pooling mutable objects

2015-02-09 Thread Matthew Hall
On Mon, Feb 09, 2015 at 06:37:32AM -0500, James Carman wrote: Premature optimization. UUIDs aren't slow. Could be indeed. Depends on the specific use case. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For

Re: [POOL2] Pooling mutable objects

2015-02-09 Thread Mark Thomas
On 09/02/2015 18:47, Adrian Crum wrote: I have been reading this thread for days, and I am confused. I might be wrong, but it seems to me the discussion started with a simple problem - an object borrowed from an object pool could not be returned to the pool because the object's hash value

Re: [POOL2] Pooling mutable objects

2015-02-09 Thread James Carman
Premature optimization. UUIDs aren't slow. On Monday, February 9, 2015, Matthew Hall mh...@mhcomputing.net wrote: On Sun, Feb 08, 2015 at 11:07:59AM +0100, Michael Osipov wrote: How would you propose to use it? I would still need a random number or do you recomment to use a static one

Re: [POOL2] Pooling mutable objects

2015-02-09 Thread sebb
On 9 February 2015 at 05:07, Matthew Hall mh...@mhcomputing.net wrote: On Sun, Feb 08, 2015 at 11:07:59AM +0100, Michael Osipov wrote: How would you propose to use it? I would still need a random number or do you recomment to use a static one and simply increment during the lifetime of the

Re: Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Matthew Hall
On Fri, Feb 06, 2015 at 04:54:25PM +0100, Michael Osipov wrote: This is what I did: this.internalId = RandomStringUtils.randomAlphanumeric(8); When doing these types of tricks to assign transaction ID's or serial numbers to objects / log messages / etc., I'm more of a fan of using AtomicLong.

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Michael Osipov
Am 2015-02-06 um 22:13 schrieb Matthew Hall: On Fri, Feb 06, 2015 at 04:54:25PM +0100, Michael Osipov wrote: This is what I did: this.internalId = RandomStringUtils.randomAlphanumeric(8); When doing these types of tricks to assign transaction ID's or serial numbers to objects / log messages /

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Michael Osipov
Am 2015-02-06 um 19:21 schrieb 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

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Michael Osipov
Am 2015-02-06 um 17:14 schrieb James Carman: Try UUID.randomUUID().toString() rather than RandomStringUtils if you really want unique keys. Aren't both pseudo random? I won't have more than 30 sessions in parallel. Do you think that a collision might happen? Michael

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Michael Osipov
Am 2015-02-06 um 17:14 schrieb James Carman: Try UUID.randomUUID().toString() rather than RandomStringUtils if you really want unique keys. Aren't both pseudo random? I won't have more than 30 sessions in parallel. Do you think that a collision might happen? Michael

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Michael Osipov
Am 2015-02-06 um 19:21 schrieb 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

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread James Carman
You aren't guaranteed for them not to collide. So, yes, it could happen. On Saturday, February 7, 2015, Michael Osipov 1983-01...@gmx.net wrote: Am 2015-02-06 um 17:14 schrieb James Carman: Try UUID.randomUUID().toString() rather than RandomStringUtils if you really want unique keys.

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Phil Steitz
On Feb 7, 2015, at 2:23 AM, Michael Osipov 1983-01...@gmx.net wrote: Am 2015-02-06 um 19:21 schrieb 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

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread James Carman
Or not implement them at all since this is exactly what the Object class will do for you. On Sunday, February 8, 2015, sebb seb...@gmail.com wrote: Why don't you just implement equals() and hashCode() as noted here [1] ? This will allow the use of Pool2 and guarantee that different instances

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread sebb
On 8 February 2015 at 15:09, James Carman ja...@carmanconsulting.com wrote: Or not implement them at all since this is exactly what the Object class will do for you. Yes, that is true for the sample RawSession class shown at the start of the thread. However if the class were changed to inherit

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Michael Osipov
Am 2015-02-08 um 14:34 schrieb sebb: Why don't you just implement equals() and hashCode() as noted here [1] ? This will allow the use of Pool2 and guarantee that different instances are treated as different, regardless of mutabiity. No need to generate unique ids for each instance. Pool2

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Michael Osipov
Am 2015-02-08 um 13:12 schrieb James Carman: You aren't guaranteed for them not to collide. So, yes, it could happen. But UUID is neither but the probability is exteremely low. Is that what you tried to say? On Saturday, February 7, 2015, Michael Osipov 1983-01...@gmx.net wrote: Am

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread sebb
On 8 February 2015 at 20:38, Michael Osipov 1983-01...@gmx.net wrote: Am 2015-02-08 um 14:34 schrieb sebb: Why don't you just implement equals() and hashCode() as noted here [1] ? This will allow the use of Pool2 and guarantee that different instances are treated as different, regardless of

Re: [POOL2] Pooling mutable objects

2015-02-08 Thread Matthew Hall
On Sun, Feb 08, 2015 at 11:07:59AM +0100, Michael Osipov wrote: How would you propose to use it? I would still need a random number or do you recomment to use a static one and simply increment during the lifetime of the application? If so, thing might cause trouble in the future because I

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
)) return false; return true; } Gesendet: Freitag, 06. Februar 2015 um 16:47 Uhr Von: James Carman ja...@carmanconsulting.com An: Commons Users List user@commons.apache.org Betreff: Re: [POOL2] Pooling mutable objects Or just let your IDE

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
. Februar 2015 um 16:47 Uhr Von: James Carman ja...@carmanconsulting.com An: Commons Users List user@commons.apache.org Betreff: Re: [POOL2] Pooling mutable objects 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

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread William Speirs
; return true; } Gesendet: Freitag, 06. Februar 2015 um 16:47 Uhr Von: James Carman ja...@carmanconsulting.com An: Commons Users List user@commons.apache.org Betreff: Re: [POOL2] Pooling mutable objects Or just let your IDE generate the methods

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread Mat Jaggard
false; return true; } Gesendet: Freitag, 06. Februar 2015 um 16:47 Uhr Von: James Carman ja...@carmanconsulting.com An: Commons Users List user@commons.apache.org Betreff: Re: [POOL2] Pooling mutable objects Or just let your IDE

Re: Re: [POOL2] Pooling mutable objects

2015-02-06 Thread sebb
...@carmanconsulting.com An: Commons Users List user@commons.apache.org Betreff: Re: [POOL2] Pooling mutable objects 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

[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
, 06. Februar 2015 um 16:47 Uhr Von: James Carman ja...@carmanconsulting.com An: Commons Users List user@commons.apache.org Betreff: Re: [POOL2] Pooling mutable objects 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