groovy

Improve the caching logic in GroovyClassLoader

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.5, 1.7-beta-2
  • Fix Version/s: 1.6.6, 1.7-rc-1
  • Component/s: class generator
  • Labels:
    None
  • Number of attachments :
    0

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 {}')

Activity

Hide
Roshan Dawrani added a comment -

Fixed

Show
Roshan Dawrani added a comment - Fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: