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

Union's stringValue() does not handle BitsTypeObject

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Highest Highest
    • 11.0.3
    • 11.0.0, 11.0.1, 11.0.2
    • Binding codegen

      Detected in downstream integration. For the following snippet:

        typedef access-operations-type {
          type bits {
            bit create {
            }
            bit read {
            }
            bit update {
            }
            bit delete {
            }
            bit exec {
            }
          }
        }
      
        leaf access-operations {
          type union {
            type matchall-string-type;
            type access-operations-type;
          }
          default *;
        } 

      we end up generating this code:

              public String stringValue() {
                  if (_matchallStringType != null) {
                      return _matchallStringType.getValue().toString();
                  }
                  if (_accessOperationsType != null) {
                      return Arrays.toString(_accessOperationsType.getValue());
                  }
                  throw new IllegalStateException("No value assigned");
              }
      

      The reference in Arrays.toString() is wrong – it needs to call values(), as there is no getValue() method ever since we have BitsTypeObject.

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

              Created:
              Updated:
              Resolved: