Ivy
  1. Ivy
  2. IVY-1236

Dynamic version resolution result is incorrect when ivy metadata contains extra attributes.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.3.0-RC1
    • Component/s: Core
    • Labels:
      None

      Description

      Ivy resolution is incorrect given the following configuration:

      ivy metadata of logging#slf4j;1.6.1
      <ivy-module version="2.0" xmlns:extra="http://ant.apache.org/ivy/extra">
      <info organisation="logging" module="slf4j" revision="1.6.1" extra:tag="logging">
      <description>Front end logging API.</description>
      </info>
      <configurations>
      <conf name="runtime" description="Core runtime dependencies"/>
      <conf name="jcl-bridge" extends="runtime" description="Jakarta Commons Logging Bridge dependencies"/>
      <conf name="jul-bridge" extends="runtime" description="Java Util Logging Bridge dependencies"/>
      <conf name="log4j-bridge" extends="runtime" description="Apache Log4J Bridge dependencies"/>
      <conf name="bridges" extends="jcl-bridge,jul-bridge,log4j-bridge" description="Groups all logging bridge dependencies"/>
      </configurations>
      <publications>
      <artifact name="slf4j-api-1.6.1" type="jar" ext="jar" conf="runtime"/>
      <artifact name="jcl-over-slf4j-1.6.1" type="jar" ext="jar" conf="jcl-bridge"/>
      <artifact name="jul-to-slf4j-1.6.1" type="jar" ext="jar" conf="jul-bridge"/>
      <artifact name="log4j-over-slf4j-1.6.1" type="jar" ext="jar" conf="log4j-bridge"/>
      </publications>
      </ivy-module>

      ivy metadata of logging#logback;0.9.24 ivy:
      <ivy-module version="2.0">
      <info organisation="logging" module="logback" revision="0.9.24">
      <description>Back end logging implementation that implements SLF4J (successor to Log4J).</description>
      </info>
      <configurations>
      <conf name="runtime" description="Core runtime dependencies"/>
      </configurations>
      <publications>
      <artifact name="logback-core-0.9.24" type="jar" ext="jar" conf="runtime"/>
      <artifact name="logback-classic-0.9.24" type="jar" ext="jar" conf="runtime"/>
      </publications>
      <dependencies>
      <dependency org="logging" name="slf4j" rev="1.6.1" conf="runtime->bridges"/>
      </dependencies>
      </ivy-module>

      Dependencies to resolve:
      <dependency org="logging" name="slf4j" rev="[1.6.1, 1.6.2]" conf="runtime"/>
      <dependency org="logging" name="logback" rev="[0.9.24, 0.9.25]" conf="build-tests->runtime" />

      I would expect the following jars of slf4j are resolved:
      slf4-api-1.6.1.jar, jcl-over-slf4j-1.6.1.jar, jul-to-slf4j-1.6.1.jar, log4j-over-slf4j-1.6.1.jar
      However, only slf4j-api-1.6.1.jar is resolved.

      A eclipse project is attached to demonstrate the issue.
      ivy metadata for slf4j 1.6.1: repo\logging\slf4j\1.6.1\ivy.xml)
      ivy metadata for logback 0.9.24: repo\logging\logback\0.9.24\ivy.xml

      I've debugged through and found that VisitNode does not deal with dynamic version correctly, so that when slf4j contains extra attributes, it behaves incorrectly:
      org.apache.ivy.core.resolve.VisitNode: line 286 - 302
      public boolean loadData(String conf, boolean shouldBePublic) {
      boolean loaded = node.loadData(
      rootModuleConf, getParentNode(), parentConf, conf, shouldBePublic, getUsage());
      if (loaded) {
      useRealNode();
      // if the loaded revision is different from original one
      // we now register this node on the new resolved id
      // this includes two cases:
      // - the id refers to a dynamic revision, which has beenresolved by loadData
      // - the loaded module descriptor has extra attributes in his info tag which are not
      // used when declaring the dependency
      if (data.getNode(node.getResolvedId()) == null || !data.getNode(node.getResolvedId()).getId().equals(node.getResolvedId()))
      {
      data.register(node.getResolvedId(), this);

      /** If node's id is dynamic, e.g. logging#slf4j;[1.6.1, 1.6.2], then the VisitNode will not be associated with it because only resolvedId is considered here*/
      /** The following fix associates dynamic id with VisitData as well */
      /** FIX START **/
      if(!node.getResolvedId().equals(node.getId()))

      { ModuleRevisionId resolvedId = node.getResolvedId(); data.register(ModuleRevisionId.newInstance(resolvedId.getOrganisation(), resolvedId.getName(), resolvedId.getBranch(), resolvedId.getRevision()), this); }

      /** FIX END **/
      }
      }

      return loaded;
      }

      I've applied this fix to handle dynamic version and then the resolution works fine.

      Thanks,
      Tom

        Activity

        Tom Liu created issue -
        Hide
        Tom Liu added a comment -

        The eclipse project of reproduction.

        Show
        Tom Liu added a comment - The eclipse project of reproduction.
        Tom Liu made changes -
        Field Original Value New Value
        Attachment dynamic_version_bug.zip [ 12456662 ]
        Tom Liu made changes -
        Attachment dynamic_version_bug.zip [ 12456662 ]
        Tom Liu made changes -
        Attachment dynamic_version_bug.zip [ 12456678 ]
        Hide
        Maarten Coene added a comment -

        I've committed a patch into svn trunk which should fix the problem. I've added a junit test based on your example.
        Since I fixed it in a different way as you did, could you please try current trunk version and confirm the issue doesn't occur any longer for you?

        thanks,
        Maarten

        Show
        Maarten Coene added a comment - I've committed a patch into svn trunk which should fix the problem. I've added a junit test based on your example. Since I fixed it in a different way as you did, could you please try current trunk version and confirm the issue doesn't occur any longer for you? thanks, Maarten
        Maarten Coene made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Maarten Coene [ maartenc ]
        Fix Version/s trunk [ 12313426 ]
        Resolution Fixed [ 1 ]
        Hide
        Tom Liu added a comment -

        Hi Maarten,

        Thanks for fixing this.

        I've checked out the trunk and verified that the fix works.

        Thanks again,
        Tom

        Show
        Tom Liu added a comment - Hi Maarten, Thanks for fixing this. I've checked out the trunk and verified that the fix works. Thanks again, Tom
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        89d 19h 12m 1 Maarten Coene 05/Jan/11 22:58

          People

          • Assignee:
            Maarten Coene
            Reporter:
            Tom Liu
          • Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development