Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-743

Reordering mappings from domain in xml resulting in StackOverflowException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2 branch
    • 3.0M1
    • Core Library
    • None
    • 64 bit architecture (Core2 duo), Java 1.6, Tomcat 5.5.20

    Description

      Application worked fine on another server with similar software, but after moving it to the new server...
      First we've encountered StackOverflowException which should better throw an exception of something not being found (there's a comment about an infinite loop, so it's a known problem).
      We've made a nasty fix for that to see what's missing and found that class in one .map.xml references class in another .map.xml, but the latter not being loaded before the former (although in the xml they're specified in a correct order) configuration fails.

      TO THE POINT
      In the source file ConfigLoader.java I've found the root problem for this. DomainHandler there uses a HashMap for map locations. When loading the xml it adds mappings to that HashMap and after that it iterates over the map, loading mappings in the order they're in the map (not the order they're in the xml) and that became a problem in our new server (HashMap: This class makes no guarantees as to the order of the map).
      I've fixed it by changing line:
      mapLocations = new HashMap();
      into something like this:
      mapLocations = new ArrayMap();
      (Note, that the ArrayMap is made by me and based on ArrayList so the order of its entries doesn't change, it may not be very efficient, but for a few mappings in our projects it doesn't matter, because we have at most 3 in one domain)

      I think this may even be a more architectural problem, so I'm not sure if my fix is any good but it sure fixed our application's behaviour (no more StackOverflowException's or anything)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              inkredibl Marius Siegas
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: