Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[FIXED JENKINS-14614] Removed unnecessary compilation of Groovy scripts.
  • Loading branch information
uhafner committed Aug 23, 2012
1 parent 027598d commit 6ef488d74979aaa7b84eb84e029f628b60dc35d2
Showing with 13 additions and 20 deletions.
  1. +13 −20 src/main/java/hudson/plugins/warnings/parser/GroovyExpressionMatcher.java
@@ -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.
*
@@ -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;

0 comments on commit 6ef488d

Please sign in to comment.