History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-13011
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Eugene Vigdorchik
Reporter: Maxim Shafirov
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

Bad code is green

Created: 07 Jan 07 17:36   Updated: 08 Jan 07 13:05
Component/s: Editor. Error Highlighting
Fix Version/s: Demetra 6.0.3

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 6,627
Fixed in build: 6,629
Severity: Extreme


 Description  « Hide
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
  }

}


 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.