Details
-
Bug
-
Status: Resolved
-
Resolution: Done
-
None
-
None
-
None
-
None
-
Operating System: All
Platform: All
-
3643
Description
The following patch changed behavior of builder class generated by yangtools.
commit 7998081d8e1761bf4798c1642e8e6107fc4666fc
Author: Robert Varga <rovarga@cisco.com>
Date: Sun May 31 19:51:43 2015 +0200
BUG-1485: convert BuilderTemplate to use LengthGenerator
Before that patch was merged, a setter method for a length-restricted string accepts a null string.
YANG model:
container test {
leaf name {
type string
}
}
Setter method in a builder class:
public TestBuilder setName(java.lang.String value) {
if (value != null) {
BigInteger _constraint = BigInteger.valueOf(value.length());
boolean isValidLength = false;
for (Range<BigInteger> r : _name_length()) {
if (r.contains(_constraint))
}
if (!isValidLength)
}
this._name = value;
return this;
}
But after that patch was merged, a setter method for a length-restricted string causes NPE when a null string is passed.
private static void check_nameLength(final String value) {
final int length = value.length(); <=== NPE if value is null
if (length >= 1 && length <= 31)
throw new IllegalArgumentException(String.format("Invalid length: %s, expected: [[1‥31]].", value));
}
public TestBuilder setName(java.lang.String value)
{ check_nameLength(value); this._name = value; return this; }I think a setter method should accept a null string even if a length restriction is applied.