Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-335

Potentional bug: AbstractGeneratedTypeBuilder allows multiple addition of elements witch equals

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 2172

    Description

      Potentional bug: AbstractGeneratedTypeBuilder allows multiple addition (via add* methods) of elements witch equals. Check of duplicity of added elements is missing in add* methods of AbstractGeneratedTypeBuilder and subclass GeneratedTypeBuilderImpl.

      For an example, it is possible to add two constants with the same type, name and value:

      GeneratedTypeBuilder generatedTypeBuilder = new GeneratedTypeBuilderImpl("my.package","MyName");

      Constant constant1 = generatedTypeBuilder.addConstant(Types.typeForClass(String.class), "myConstant", "myConstantValue");

      Constant constant2 = generatedTypeBuilder.addConstant(Types.typeForClass(String.class), "myConstant", "myConstantValue");

      constant2 != null //true, constant2 is not null
      constant2 != constant1 //true, constant2 is a reference to new object
      constant2.equals(constant1); // true, constant1 and constant2 are equal (they have the same name, type and value)

      generatedTypeBuilder.toInstance().getConstantDefinitions().size() //2

      The same behavior is present also in other add* methods.

      Notice: Maybe this is not a bug and the check is performed somewhere else just before generation of source code from these objects.

      Attachments

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

        Activity

          People

            pkajsa Peter Kajsa
            pkajsa Peter Kajsa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: