Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-14614] Removed unnecessary compilation of Groovy scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Aug 23, 2012
1 parent 027598d commit 6ef488d
Showing 1 changed file with 13 additions and 20 deletions.
Expand Up @@ -36,31 +36,22 @@ public class GroovyExpressionMatcher implements Serializable {
public GroovyExpressionMatcher(final String script, final Warning falsePositive) {
this.script = script;
this.falsePositive = falsePositive;

compileScript();
}

private void compileScript() {
GroovyShell shell = new GroovyShell(WarningsDescriptor.class.getClassLoader());
try {
compiled = shell.parse(script);
}
catch (CompilationFailedException exception) {
LOGGER.log(Level.SEVERE, "Groovy dynamic warnings parser: exception during compiling: ", exception);
private void compileScriptIfNotYetDone() {
synchronized (script) {
if (compiled == null) {
GroovyShell shell = new GroovyShell(WarningsDescriptor.class.getClassLoader());
try {
compiled = shell.parse(script);
}
catch (CompilationFailedException exception) {
LOGGER.log(Level.SEVERE, "Groovy dynamic warnings parser: exception during compiling: ", exception);
}
}
}
}

/**
* Compiles the script.
*
* @return this
*/
protected Object readResolve() {
compileScript();

return this;
}

/**
* Creates a new annotation for the specified match.
*
Expand All @@ -69,6 +60,8 @@ protected Object readResolve() {
* @return a new annotation for the specified pattern
*/
public Warning createWarning(final Matcher matcher) {
compileScriptIfNotYetDone();

Binding binding = new Binding();
binding.setVariable("matcher", matcher);
Object result = null;
Expand Down

0 comments on commit 6ef488d

Please sign in to comment.