Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlockingQueueObjectPool.getObj() must be synchronized #4

Open
GoogleCodeExporter opened this issue Jun 21, 2015 · 6 comments
Open

BlockingQueueObjectPool.getObj() must be synchronized #4

GoogleCodeExporter opened this issue Jun 21, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link

With concurrent accesses you have to synchronize the getObj() method.
If not totalSize will always be the min size defined for the pool and not grows 
correctly.

public synchronized T getObj() throws PoolException { ... }

Check on concurrent accessed methods please. ;)

Best regards,
Daniele Bonetto

Original issue reported on code.google.com by daniele....@gmail.com on 18 Apr 2013 at 8:09

@GoogleCodeExporter
Copy link
Author

OK, modifications are done.

I upload a jar on the download area (objectpool-1.1.3-snapshot.jar).

Best regards,
Eddie Raapoto

Original comment by eddie.ra...@gmail.com on 18 Apr 2013 at 9:16

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

Every time you can access concurrently to queue and totalSize i suppose you've 
to use synchronized (like returnObj and destroyObject methods).
If not in multi-thread active/idle count will be incorrect, etc.

Regards,
Daniele Bonetto

Original comment by daniele....@gmail.com on 18 Apr 2013 at 9:36

@GoogleCodeExporter
Copy link
Author

It strange, because the queue "java.util.concurrent.ConcurrentLinkedQueue" is 
already synchronized.
The totalSize variable "java.util.concurrent.atomic.AtomicInteger" is also 
thread safe.



Original comment by eddie.ra...@gmail.com on 18 Apr 2013 at 11:12

@GoogleCodeExporter
Copy link
Author

Hi, i've tried to shutdown pool while idling objects.
When retrieving idles instances counter was the same as before shutdown.

Shutdown don't close idle connections or idles property wasn't synchronized.
Check it please.

Regards,
Daniele

Original comment by daniele....@gmail.com on 13 May 2013 at 10:43

@GoogleCodeExporter
Copy link
Author

Hi, do u have implemented PoolableObject.destroy(T t) method in your pool 
definition ?
Regards, Eddie

Original comment by eddie.ra...@gmail.com on 16 May 2013 at 8:47

@GoogleCodeExporter
Copy link
Author

Of course and it works.
I think the problem is with counters cause happens that with a max connection 
of 5 actives returns a greater number (eg. 7/8).
I suppose there's some problem when getObject fails, but not jet checked on 
sources.

I call getObject under try/finally (where i release obj if not null).

Regards,
Daniele

Original comment by daniele....@gmail.com on 16 May 2013 at 10:44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant