|
Project
|
IntelliJ IDEA
|
|
Priority
|
Critical |
|
Type
|
Bug |
|
Fix versions
|
No Fix versions |
|
State
|
Fixed |
|
Assignee
|
Eugene Vigdorchik |
|
Subsystem
|
Editor. Error Highlighting |
|
Affected versions
|
No Affected versions |
|
Fixed in build
|
108.65 |
public class LimitedPool<T> {
private int capacity;
private final ObjectFactory<T> factory;
private Object[] storage;
private int index = 0;
public LimitedPool(final int capacity, ObjectFactory<T> factory) {
this.capacity = capacity;
this.factory = factory;
storage = new Object[capacity];
}
interface ObjectFactory<T> {
T create();
void cleanup(T t);
}
public T alloc() {
if (index >= capacity) return factory.create();
if (storage[index] == null) {
storage[index] = factory.create();
}
return storage; // Compile error here
}
}