Skip to content

Commit

Permalink
Fix potential overflow in AdminClient.waitForCompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjwylie committed Jun 20, 2013
1 parent 81f0a16 commit 2bf1543
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/java/voldemort/client/protocol/admin/AdminClient.java
Expand Up @@ -782,7 +782,7 @@ public String waitForCompletion(int nodeId, int requestId) {
* @param key metadata key to keep checking for current value
* @param value metadata value should match for exit criteria.
* @param maxWait Maximum time we'll keep checking a request until we
* give up
* give up. Pass in 0 or less to wait "forever".
* @param timeUnit Unit in which maxWait is expressed.
*/
public void waitForCompletion(int nodeId,
Expand All @@ -791,7 +791,10 @@ public void waitForCompletion(int nodeId,
long maxWait,
TimeUnit timeUnit) {
long delay = INITIAL_DELAY;
long waitUntil = System.currentTimeMillis() + timeUnit.toMillis(maxWait);
long waitUntil = Long.MAX_VALUE;
if(maxWait > 0) {
waitUntil = System.currentTimeMillis() + timeUnit.toMillis(maxWait);
}

while(System.currentTimeMillis() < waitUntil) {
String currentValue = metadataMgmtOps.getRemoteMetadata(nodeId, key).getValue();
Expand Down Expand Up @@ -827,7 +830,7 @@ public void waitForCompletion(int nodeId,
* @param value metadata value should match for exit criteria.
*/
public void waitForCompletion(int nodeId, String key, String value) {
waitForCompletion(nodeId, key, value, Long.MAX_VALUE, TimeUnit.SECONDS);
waitForCompletion(nodeId, key, value, 0, TimeUnit.SECONDS);
}

}
Expand Down

0 comments on commit 2bf1543

Please sign in to comment.