Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-120

Duplicate length restriction checking

    XMLWordPrintable

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)

      { return; }
      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)

      { check_valueLength(_value); }

      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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            rovarga Robert Varga
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: