Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3874

Improve the caching logic in GroovyClassLoader

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.5, 1.7-beta-2
    • 1.6.6, 1.7-rc-1
    • class generator
    • None

    Description

      GroovyClassLoader#parseClass(String) internally generates a dummy file name for the script text passed to it and uses that file name to cache the class it generates. It uses System.currentTimeMillis() to come up with a unique dummy file name.

      However, sometimes it happens that consecutive parseClass(String) calls with different script text may take place during the same milli-second causing GCL to following to happen:

      // say dummy file name is script4576677673878.groovy. The class gets cached againt this file name.
      GCL#parseClass('class A {}') 
      
      // following returns the class A because this call is happening within the same milli-sec and hence has the same file name
      GCL#parseClass('class B {}') 
      

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            roshandawrani Roshan Dawrani
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: