While looking for easy enhancements and bugs I stumbled upon:

https://bz.apache.org/bugzilla/show_bug.cgi?id=56862

I have to admit, that the error messages for wrong values are not always that helpful. Especially, when those values are used very late.

To help things, we could either add a validate function (lambda?) to the JMeterUtils#getPropDefault family of functions, or surround those calls by a validator.

I was thinking of something like

private static int TIMEOUT = JMeterUtils.getPropDefault("some.timeout", 5 * 1000, i -> i >= 0);

private static int TIMEOUT = JMeterUtils.getPropDefault("some.timeout", 5 * 1000, Validator::notNegative);

or

private static int TIMEOUT = Validator.notNegative(JMeterUtils.getPropDefault("some.timeout", 5 * 1000), "some.timeout must not be negative");

At the moment I prefer the first variants.

What do you think?

Felix

Reply via email to