Uploaded image for project: 'Service Design and Creation'
  1. Service Design and Creation
  2. SDC-4446

Fix missing default no-args constructor

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Medium Medium
    • London Release
    • None
    • SDC
    • None

      Upgrade org.yaml.snakeyaml to v1.31+ revealed problem

      Can't construct a java object for tag:yaml.org,2002:org.onap.sdc.tosca.services.StrictMapAppenderConstructor$1; exception=java.lang.NoSuchMethodException: org.onap.sdc.tosca.services.StrictMapAppenderConstructor$1.<init>()

      During investigation I detected that implementation of org.yaml.snakeyaml.constructor.BaseConstructor#newMap
      changed from (v1.30-)

      protected Map<Object, Object> newMap(MappingNode node) {
              try {
                  return (Map<Object, Object>) newInstance(Map.class, node);
              } catch (InstantiationException e) {
                  return createDefaultMap(node.getValue().size());
              }
          }

      to (v1.31+)

      protected Map<Object, Object> newMap(MappingNode node) {
          Object instance = newInstance(Map.class, node);
          if (instance != NOT_INSTANTIATED_OBJECT) {
            return (Map<Object, Object>) instance;
          } else {
            return createDefaultMap(node.getValue().size());
          }
        }

      As we can see any missing default no-args constructor now will throw exception above.

      java.lang.reflect.Constructor<?> c = type.getDeclaredConstructor();

      However, before it was handled and return defaultMap.

      Could not find any reference to this change in https://bitbucket.org/snakeyaml/snakeyaml/wiki/Changes

            vasraz vasraz
            vasraz vasraz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: