Skip to content

Commit

Permalink
Prevent ISE Queue full #804
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wyhasany committed Jan 7, 2021
1 parent fcca0fc commit cccb087
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/com/esotericsoftware/kryo/util/Pool.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public Pool (boolean threadSafe, boolean softReferences, final int maximumCapaci
queue = new LinkedBlockingQueue<T>(maximumCapacity) {
@Override
public boolean add (T o) {
if (size() >= maximumCapacity) return false;
super.add(o);
return true;
return super.offer(o);
}
};
else if (softReferences) {
Expand Down

0 comments on commit cccb087

Please sign in to comment.