Ethanlm commented on a change in pull request #3215: Storm3585 - New compact
Constraint config including maxCoLocationCnt
URL: https://github.com/apache/storm/pull/3215#discussion_r387439682
##########
File path:
storm-client/src/jvm/org/apache/storm/validation/ConfigValidation.java
##########
@@ -850,6 +852,128 @@ public void validateField(String name, Object o) {
}
}
+ public static class CustomIsExactlyOneOfValidators extends Validator {
+ private Class<?>[] subValidators;
+ private List<String> validatorClassNames;
+
+ public CustomIsExactlyOneOfValidators(Map<String, Object> params) {
+ this.subValidators = (Class<?>[])
params.get(ConfigValidationAnnotations.ValidatorParams.VALUE_VALIDATOR_CLASSES);
+ this.validatorClassNames =
Arrays.asList(subValidators).stream().map(x ->
x.getName()).collect(Collectors.toList());
+ }
+
+ @Override
+ public void validateField(String name, Object o) {
+ if (o == null) {
+ throw new IllegalArgumentException("Field " + name + " must be
set.");
Review comment:
Originally when the validation class for `topology.ras.constraints` with
ListOfListOfStringValidator, a value of `null` is accpetable.
The null check here will break backwards compatibility. So the question here
is: do we want to maintain the backwards compatibility?
One thing I notice is that other validation classes accept `null`. And we
rely on `NotNull` annotation if we don't accept null as the value.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services