Uploaded image for project: 'Ivy'
  1. Ivy
  2. IVY-1545

Cycle in parent POM ancestry yields StackOverflowError in PomModuleDescriptorParser

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.0, 2.5.0-rc1
    • Fix Version/s: 2.5.0-rc1
    • Component/s: Maven Compatibility
    • Labels:
      None

      Description

      If the parent-hierarchy of a POM contains a cycle, or the artifact references itself as its parent, a StackOverflowError as PomModuleDescriptorParser recursively attempts to walk the parent ancestry (see stack trace below). It does this while it looks for properties in parent POMs. Obviously the artifact and/or parent structure is bad (contains a cycle) and needs to be corrected, but it would be helpful if Ivy threw a more meaningful error in this case.

      This can be exposed with two new tests I authored, ResolveTest#testErrorResolveMaven2ParentPomWithCycle() and ResolveTest#testErrorResolveMaven2SelfAsParent().

      My solution is to pushNewCopyContext on entry to parseDescriptor, then get/add a new LinkedHashSet to track parents seen in a walk, and throw a CircularDependencyException should we encounter a cycle.

      java.lang.StackOverflowError
      at java.lang.String.checkBounds(String.java:370)
      at java.lang.String.<init>(String.java:415)
      at java.lang.String.<init>(String.java:481)
      at java.io.UnixFileSystem.canonicalize0(Native Method)
      at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:172)
      at java.io.File.getCanonicalPath(File.java:618)
      at java.io.FilePermission$1.run(FilePermission.java:221)
      at java.io.FilePermission$1.run(FilePermission.java:209)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.io.FilePermission.init(FilePermission.java:209)
      at java.io.FilePermission.<init>(FilePermission.java:285)
      at sun.net.www.protocol.file.FileURLConnection.getPermission(FileURLConnection.java:225)
      at sun.net.www.protocol.jar.JarFileFactory.getPermission(JarFileFactory.java:156)
      at sun.net.www.protocol.jar.JarFileFactory.getCachedJarFile(JarFileFactory.java:126)
      at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:81)
      at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
      at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:150)
      at java.net.URLClassLoader.getResourceAsStream(URLClassLoader.java:233)
      at javax.xml.parsers.SecuritySupport$4.run(SecuritySupport.java:94)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.xml.parsers.SecuritySupport.getResourceAsStream(SecuritySupport.java:87)
      at javax.xml.parsers.FactoryFinder.findJarServiceProvider(FactoryFinder.java:283)
      at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:255)
      at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:121)
      at org.apache.ivy.util.XMLHelper.getDocBuilder(XMLHelper.java:228)
      at org.apache.ivy.util.XMLHelper.parseToDom(XMLHelper.java:222)
      at org.apache.ivy.plugins.parser.m2.PomReader.<init>(PomReader.java:121)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:119)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:109)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager$MyModuleDescriptorProvider.provideModule(DefaultRepositoryCacheManager.java:826)
      at org.apache.ivy.core.cache.ModuleDescriptorMemoryCache.getStale(ModuleDescriptorMemoryCache.java:68)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager.getStaledMd(DefaultRepositoryCacheManager.java:843)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager.cacheModuleDescriptor(DefaultRepositoryCacheManager.java:1358)
      at org.apache.ivy.plugins.resolver.BasicResolver.parse(BasicResolver.java:538)
      at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:273)
      at org.apache.ivy.plugins.resolver.ChainResolver.getDependency(ChainResolver.java:103)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseOtherPom(PomModuleDescriptorParser.java:394)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:139)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:109)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager$MyModuleDescriptorProvider.provideModule(DefaultRepositoryCacheManager.java:826)
      at org.apache.ivy.core.cache.ModuleDescriptorMemoryCache.getStale(ModuleDescriptorMemoryCache.java:68)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager.getStaledMd(DefaultRepositoryCacheManager.java:843)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager.cacheModuleDescriptor(DefaultRepositoryCacheManager.java:1358)
      at org.apache.ivy.plugins.resolver.BasicResolver.parse(BasicResolver.java:538)
      at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:273)
      at org.apache.ivy.plugins.resolver.ChainResolver.getDependency(ChainResolver.java:103)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseOtherPom(PomModuleDescriptorParser.java:394)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:139)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:109)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager$MyModuleDescriptorProvider.provideModule(DefaultRepositoryCacheManager.java:826)
      at org.apache.ivy.core.cache.ModuleDescriptorMemoryCache.getStale(ModuleDescriptorMemoryCache.java:68)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager.getStaledMd(DefaultRepositoryCacheManager.java:843)
      at org.apache.ivy.core.cache.DefaultRepositoryCacheManager.cacheModuleDescriptor(DefaultRepositoryCacheManager.java:1358)
      at org.apache.ivy.plugins.resolver.BasicResolver.parse(BasicResolver.java:538)
      at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:273)
      at org.apache.ivy.plugins.resolver.ChainResolver.getDependency(ChainResolver.java:103)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseOtherPom(PomModuleDescriptorParser.java:394)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:139)
      at org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser.parseDescriptor(PomModuleDescriptorParser.java:109)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jaikiran jaikiran pai
                Reporter:
                brett_s_r Brett Randall
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4h
                  4h
                  Remaining:
                  Remaining Estimate - 4h
                  4h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified