Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-4009

Fast @Converter loading in uber-jar

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.7.0
    • 2.8.0
    • camel-core
    • Patch Available

    Description

      Currently, the @Converter converters are loaded as follows

      for package in TypeConverter meta-inf resource
        get package url from classloader
        if url is jar
          for entries in jar
            if entry match package
              check annotation
      

      This is very inefficient approach when application is packaged into uber-jar as expensive iteration is performed multiple times over same jar.
      The attached patch changes loop into:

      for package in TypeConverter meta-inf resource
        get package url from classloader
        create map url -> package names
        for url in distinct url
          if jar
            for entries in jar
              for package in packages
                if entry match package
                  check annotation
      

      With this patch I was able to cut startup time significantly from 15sec spent on @Converter-s load to 2sec on 45MB 29k entries uber-jar.

      I understand that the solution is not pretty but resolves a very practical problem. Let me know if you want me to polish it and update the javadoc.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            arkadi Arkadi Shishlov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: