Skip to content

Commit

Permalink
GRAILS-9509 - improve reloading
Browse files Browse the repository at this point in the history
There is a problem with stale JVM state that isn't cleared up properly on reload.  Spring Loaded is going to address this but for now the simplest thing for us to do is the change represented here in this commit.

See comments at http://jira.grails.org/browse/GRAILS-9509 for more info.
  • Loading branch information
Jeff Brown committed Nov 15, 2012
1 parent 28da49a commit 963cc0b
Showing 1 changed file with 2 additions and 5 deletions.
Expand Up @@ -20,6 +20,7 @@
import org.codehaus.groovy.grails.commons.ClassPropertyFetcher; import org.codehaus.groovy.grails.commons.ClassPropertyFetcher;
import org.codehaus.groovy.grails.compiler.GrailsProjectWatcher; import org.codehaus.groovy.grails.compiler.GrailsProjectWatcher;
import org.springframework.beans.CachedIntrospectionResults; import org.springframework.beans.CachedIntrospectionResults;
import java.beans.Introspector;


/** /**
* Reloading agent plugin for use with the GrailsPluginManager. * Reloading agent plugin for use with the GrailsPluginManager.
Expand All @@ -37,11 +38,7 @@ public void reloadEvent(String typename, Class<?> aClass, String encodedTimestam
CachedIntrospectionResults.clearClassLoader(aClass.getClassLoader()); CachedIntrospectionResults.clearClassLoader(aClass.getClassLoader());
ClassPropertyFetcher.clearClassPropertyFetcherCache(); ClassPropertyFetcher.clearClassPropertyFetcherCache();
if (GrailsProjectWatcher.isActive()) { if (GrailsProjectWatcher.isActive()) {
try { Introspector.flushFromCaches(aClass);
Thread.sleep(2500); // wait for a bit, to reduce chance of any concurrent issues with the timing of the reload reflecting in the JVM
} catch (InterruptedException e) {
// ignore
}
GrailsProjectWatcher.firePendingClassChangeEvents(aClass); GrailsProjectWatcher.firePendingClassChangeEvents(aClass);
} }
} }
Expand Down

0 comments on commit 963cc0b

Please sign in to comment.