GRAILS-10294: fix to avoid repeated recalculation and some sync blocks for locking

This commit is contained in:
Andy Clement
2013-07-29 08:38:22 -07:00
parent 283aa439da
commit 9c5f2851bc

View File

@@ -76,17 +76,22 @@ public class SystemPropertyConfiguredIsReloadableTypePlugin implements IsReloada
return ReloadDecision.PASS;
} else {
if (mostRecentReloadableDirs != reloadableDirs) {
includes.clear();
excludes.clear();
// update our cached information
StringTokenizer st = new StringTokenizer(reloadableDirs, ",");
while (st.hasMoreTokens()) {
String nextDir = st.nextToken();
boolean isNot = nextDir.charAt(0) == '!';
if (isNot) {
excludes.add(nextDir.substring(1));
} else {
includes.add(nextDir);
synchronized (includes) {
if (mostRecentReloadableDirs != reloadableDirs) {
includes.clear();
excludes.clear();
// update our cached information
StringTokenizer st = new StringTokenizer(reloadableDirs, ",");
while (st.hasMoreTokens()) {
String nextDir = st.nextToken();
boolean isNot = nextDir.charAt(0) == '!';
if (isNot) {
excludes.add(nextDir.substring(1));
} else {
includes.add(nextDir);
}
}
mostRecentReloadableDirs = reloadableDirs;
}
}
}
@@ -111,26 +116,28 @@ public class SystemPropertyConfiguredIsReloadableTypePlugin implements IsReloada
File file = new File(uri);
String path = file.toString();
for (String exclude : excludes) {
if (path.contains(exclude)) {
if (debug) {
System.out.println("SystemPropertyConfiguredIsReloadableTypePlugin: " + typename
+ " is not being made reloadable");
synchronized (includes) {
for (String exclude : excludes) {
if (path.contains(exclude)) {
if (debug) {
System.out.println("SystemPropertyConfiguredIsReloadableTypePlugin: " + typename
+ " is not being made reloadable");
}
return ReloadDecision.NO;
}
}
for (String include : includes) {
if (path.contains(include)) {
if (debug) {
System.out.println("SystemPropertyConfiguredIsReloadableTypePlugin: " + typename
+ " is being made reloadable");
}
return ReloadDecision.YES;
}
return ReloadDecision.NO;
}
}
for (String include : includes) {
if (path.contains(include)) {
if (debug) {
System.out.println("SystemPropertyConfiguredIsReloadableTypePlugin: " + typename
+ " is being made reloadable");
}
return ReloadDecision.YES;
}
}
// StringTokenizer st = new StringTokenizer(reloadableDirs, ",");
// while (st.hasMoreTokens()) {
// String nextDir = st.nextToken();