-
Notifications
You must be signed in to change notification settings - Fork 823
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
llegalStateException on calling free for pooled item to synchronized pool using soft references and being full #804
Comments
It seems that's happened because I've shared |
Oh, it seems I've been mistaken. It's looks like that we can't use Then: queue = new LinkedBlockingQueue<T>(maximumCapacity) {
@Override
public boolean add (T o) {
if (size() >= maximumCapacity) return false;
super.add(o);
return true;
}
}; there is size checking, however we don't have here any locking, so the size could be changed by the another thread. Then - if (size() >= maximumCapacity) return false;
- super.add(o);
- return true;
+ return super.offer(o); |
Prevent throwing exception on multi-threaded environment where two concurrent threads can change state between these lines: ``` if (size() >= maximumCapacity) return false; super.add(o); ``` what causes mentioned exception.
PR is merged and will be part of the next release. Thanks! |
Until the release of Kryo 5.0.4 (probably). If you've found similar bug the basic workaround is switching off soft references: //fails
Pool<Kryo> kryoPool = new Pool<Kryo>(true, true, 16);
//passes
Pool<Kryo> kryoPool = new Pool<Kryo>(true, false, 16) Since the next release the first version would work smoothlessly in multi-threaded environment. @theigl thanks for cooperation 👍 |
Using com.esotericsoftware.kryo.util.Pool with threadSafe = true and softReferences = false and a limit.
I'm running following code under JMH with 8 concurrent threads. Is that correct behavior?
The text was updated successfully, but these errors were encountered: