Skip to content

Commit

Permalink
fixing LimitedRoundRobinSelector (instances got stuck at waitNodesCre…
Browse files Browse the repository at this point in the history
…ation)
  • Loading branch information
leonardofl committed Apr 11, 2014
1 parent 7fae51d commit 06a13b3
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,17 @@ private int defineNewQty(List<T> objects, int objectsQuantity) {
private List<T> selectInCreatingState(List<T> objects, R requirements, int objectsQuantity, int newQty)
throws NotSelectedException {

List<T> result = this.alwaysCreatorSelector.select(requirements, newQty);
synchronized (this) {
objectsBeenCreated.set(objectsBeenCreated.get() - newQty);
List<T> result = null;
try {
result = this.alwaysCreatorSelector.select(requirements, newQty);
} catch (NotSelectedException e) {
throw e;
} finally {
synchronized (this) {
objectsBeenCreated.set(objectsBeenCreated.get() - newQty);
}
}

if (result.size() < objectsQuantity) {
int diff = objectsQuantity = result.size();
List<T> moreNodes = this.roundRobinSelector.select(requirements, diff);
Expand Down

0 comments on commit 06a13b3

Please sign in to comment.