Allow time unit variables to be 0

plugins.checkFrequency can be disabled by setting the time to 0,
but this is not allowed in a time unit typed variable due to the
regex requiring the value to start with a digit in the range 1-9.
Permit 0 as a value.

Change-Id: I2deca08fe9b0ea93ef23f626fc44cffe98ad2d95
This commit is contained in:
Shawn O. Pearce
2012-10-12 12:08:46 -07:00
parent 1ba65acff2
commit d1d1c08c79
2 changed files with 3 additions and 1 deletions

View File

@@ -228,7 +228,7 @@ public class ConfigUtil {
*/
public static long getTimeUnit(final String valueString, long defaultValue,
TimeUnit wantUnit) {
Matcher m = Pattern.compile("^([1-9][0-9]*)\\s*(.*)$").matcher(valueString);
Matcher m = Pattern.compile("^(0|[1-9][0-9]*)\\s*(.*)$").matcher(valueString);
if (!m.matches()) {
return defaultValue;
}