Details
-
Bug
-
Status: Resolved
-
Resolution: Done
-
None
-
None
-
None
-
None
-
Operating System: All
Platform: All
-
4743
Description
Migration to new types has introduce a regression in length enforcement, where the same length constraints are being enforced in Builders where the leaf is derived from a restricted type.
This is evident in GBP's health.yang, where we see the following:
private static void check_descriptionLength(final String value) {
final int length = value.length();
if (length >= 1 && length <= 4096)
throw new IllegalArgumentException(String.format("Invalid length: %s, expected: [[1‥4096]].", value));
}
public FaultBuilder setDescription(Description value) {
if (value != null) { check_descriptionLength(value.getValue()); }
this._description = value;
return this;
}
where Description already does:
private static void check_valueLength(final String value) {
final int length = value.length();
if (length >= 1 && length <= 4096) { return; }
throw new IllegalArgumentException(String.format("Invalid length: %s, expected: [[1‥4096]].", value));
@ConstructorProperties("value")
public Description(java.lang.String _value) {
if (_value != null)
Preconditions.checkNotNull(_value, "Supplied value may not be null");
this._value = _value;
}
While this does not affect functionality, it produces redundant code and reduces performance.
This seems to be coming from BindingGeneratorUtil.getRestrictions(), which needs to check against the base type to see if the restrictions are different. If they are not, it should report empty restrictions.