Skip to content
Permalink
Browse files

[JENKINS-27664] Better Performance of EclipseParser.

Tune the regular expression used in the EclipseParser to not backtrack
through the whole log output.
  • Loading branch information...
TobiX committed Mar 10, 2016
1 parent 6b50ca1 commit 167f35f42c58b0a587a3def816ab9ea54792d84f
@@ -8,6 +8,7 @@

import hudson.plugins.analysis.util.model.Priority;


/**
* A parser for Eclipse compiler warnings.
*
@@ -16,7 +17,11 @@
@Extension
public class EclipseParser extends RegexpDocumentParser {
private static final long serialVersionUID = 425883472788422955L;
private static final String ANT_ECLIPSE_WARNING_PATTERN = "\\[?(WARNING|ERROR)\\]?\\s*(?:in)?\\s*(.*)(?:\\(at line\\s*(\\d+)\\)|:\\[(\\d+)).*(?:\\r?\\n[^\\^]*)+(?:\\r?\\n(.*)([\\^]+).*)\\r?\\n(?:\\s*\\[.*\\]\\s*)?(.*)";
private static final String ANT_ECLIPSE_WARNING_PATTERN =
"\\[?(WARNING|ERROR)\\]?\\s*(?:in)?\\s*(.*)(?:\\(at line\\s*(\\d+)\\)|:\\[(\\d+)).*" +
"(?:\\r?\\n[^\\^\\n]*){1,3}" +
"\\r?\\n(.*)([\\^]+).*" +
"\\r?\\n(?:\\s*\\[.*\\]\\s*)?(.*)";

/**
* Creates a new instance of {@link EclipseParser}.
@@ -188,5 +188,20 @@ public void issue7077all() throws IOException {
number++;
}
}

/**
* Parses a warning log which doesn't contain any Eclipse warnings, but
* shows some pretty bad performance when matching the regular expression.
*
* @throws IOException
* if the file could not be read
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-27664">Issue 27664</a>
*/
@Test(timeout = 10000)
public void issue27664() throws IOException {
Collection<FileAnnotation> warnings = createParser().parse(openFile("issue27664.txt"));

assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 0, warnings.size());
}
}

@@ -0,0 +1,20 @@
[WARNING] xxx.java:[226,37] [deprecation] getBoolean(String,boolean) in Sample has been deprecated
[WARNING] xxx.java:[228,37] [deprecation] getBoolean(String,boolean) in Sample has been deprecated
[WARNING] xxx.java:[230,37] [deprecation] getBoolean(String,boolean) in Sample has been deprecated
[WARNING] xxx.java:[232,37] [deprecation] getBoolean(String,boolean) in Sample has been deprecated
[WARNING] xxx.java:[186,48] [deprecation] getString(String,String) in Sample has been deprecated
[WARNING] xxx.java:[343,66] [deprecation] getInt(String,int) in Sample has been deprecated
[WARNING] xxx.java:[36,35] [deprecation] getString(String,String) in Sample has been deprecated
[WARNING] xxx.java:[39,35] [deprecation] getString(String,String) in Sample has been deprecated
[WARNING] xxx.java:[34,33] [deprecation] getString(String,String) in Sample has been deprecated
[WARNING] xxx.java:[27,47] [deprecation] Sample2 in com.example has been deprecated
[WARNING] xxx.java:[299,41] [deprecation] getString(String,String) in Sample has been deprecated
[WARNING] xxx.java:[36,48] [deprecation] getString(String,String) in Sample has been deprecated
[WARNING] xxx.java:[23,41] [deprecation] Sample2 in com.example has been deprecated
[WARNING] xxx.java:[91,31] [deprecation] getString(String,String) in Sample has been deprecated
[WARNING] xxx.java:[212,66] [deprecation] add(int,TimeUnit) in Date has been deprecated
[WARNING] xxx.java:[213,68] [deprecation] subtract(int,TimeUnit) in Date has been deprecated
[WARNING] xxx.java:[261,61] [deprecation] subtract(int,TimeUnit) in Date has been deprecated
[WARNING] xxx.java:[324,61] [deprecation] add(int,TimeUnit) in Date has been deprecated
[WARNING] xxx.java:[330,61] [deprecation] add(int,TimeUnit) in Date has been deprecated
[WARNING] xxx.java:[27,48] [deprecation] getString(String,String) in Sample has been deprecated

0 comments on commit 167f35f

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.